Setup Process: Difference between revisions

From PM Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
== Server Spec ==
== Server Specification ==


We’re assuming the following conditions were met for the system:
We’re assuming the following conditions were met for the system:
Line 16: Line 16:
Please follow these steps in this specific order.
Please follow these steps in this specific order.


== 1 - General Installation: ==
== General Installation ==


Here are the legworks that will need to be ran across all of the servers
Here are the legworks that will need to be ran across all of the servers
Line 55: Line 55:
  pip install supervisor
  pip install supervisor


== 2 - Code Deployment: ==
== Code Deployment: ==


There are several ways that you can deploy the code to the servers, git, deployhq, Jenkins, scp are some of the most common ways, or you can also just zip and upload via filezilla. I will not cover the code deployment in this tutorial. Here are the main things after you’ve already uploaded the code.
There are several ways that you can deploy the code to the servers, git, deployhq, Jenkins, scp are some of the most common ways, or you can also just zip and upload via filezilla. I will not cover the code deployment in this tutorial. Here are the main things after you’ve already uploaded the code.
Line 69: Line 69:
setenforce 0
setenforce 0


 
== Database Deployment ==
 
 
 
3 - Database Deployment


You can use PHPMySQL or plenty of other platforms out there to import the SQL file in the “DDL” folder. I recommend Heidi as it’s the tool that I use to export the SQL file in the development environment.
You can use PHPMySQL or plenty of other platforms out there to import the SQL file in the “DDL” folder. I recommend Heidi as it’s the tool that I use to export the SQL file in the development environment.


4 - Gearmand Deployment
== Gearmand Deployment ==


On the worker’s servers, we can launch gearmand by issuing this command
On the worker’s servers, we can launch gearmand by issuing this command
Line 83: Line 79:
In this command, we set it to listen on ALL IPs via port 8888 in this machine, this is very insecure. I recommend that we set it to only listen to private IP that can communicate with other machines in the network, ie 192.168.X.Y. One thing about gearmand is, its log file can get pretty big over time, so we definitely need to keep an eye on the log file to make sure it won’t take up too much space on the hard drive.
In this command, we set it to listen on ALL IPs via port 8888 in this machine, this is very insecure. I recommend that we set it to only listen to private IP that can communicate with other machines in the network, ie 192.168.X.Y. One thing about gearmand is, its log file can get pretty big over time, so we definitely need to keep an eye on the log file to make sure it won’t take up too much space on the hard drive.


5 - Supervisor Deployment
== Supervisor Deployment ==
 
On the worker’s machine, run this command  
On the worker’s machine, run this command  
“supervisord -c /var/www/html/www/etc/supervisord.conf”
“supervisord -c /var/www/html/www/etc/supervisord.conf”
Line 89: Line 86:
To monitor the processes, we can go to “http://Worker_Machine_IP:9400” with the username and password as “shuser” and “shuser”.
To monitor the processes, we can go to “http://Worker_Machine_IP:9400” with the username and password as “shuser” and “shuser”.


6 - Gearmand Monitor
== Gearmand Monitor ==
 
In order to be able to monitor the gearmand’s queue and its job, we need to install the following code.
In order to be able to monitor the gearmand’s queue and its job, we need to install the following code.
https://github.com/yugene/Gearman-Monitor
https://github.com/yugene/Gearman-Monitor
Line 95: Line 93:
Once all is done, we will need to add the gearmand’s server info into the _config.php file,  and that’s all needed to be done. Ie,
Once all is done, we will need to add the gearmand’s server info into the _config.php file,  and that’s all needed to be done. Ie,


$cfgServers[$i]['address'] = 'gearmand_server_ip_production:8888';
$cfgServers[$i]['address'] = 'gearmand_server_ip_production:8888';
$cfgServers[$i]['name'] = 'Production';
$cfgServers[$i]['name'] = 'Production';
++ $i;
++ $i;


$cfgServers[$i]['address'] = 'gearmand_server_ip_staging:8888';
$cfgServers[$i]['address'] = 'gearmand_server_ip_staging:8888';
$cfgServers[$i]['name'] = 'Staging';
$cfgServers[$i]['name'] = 'Staging';
++ $i;
++ $i;


$cfgServers[$i]['address'] = 'gearmand_server_ip_dev:8888';
$cfgServers[$i]['address'] = 'gearmand_server_ip_dev:8888';
$cfgServers[$i]['name'] = 'Development';
$cfgServers[$i]['name'] = 'Development';
++ $i;
++ $i;

Revision as of 15:06, 30 March 2023

Server Specification

We’re assuming the following conditions were met for the system:

  • At least 16Gb of ram
  • At least 200Gb SSD running on Raid10 for redundancy (I recommend to use NVMe for the best performance)
  • At least 10 CPU Cores
  • 1Gbps private ethernet connections between servers
  • CentOS 7 minimal install

Here is the recommended spec for the servers

  • 192Gb ram
  • 120Gb RAID1 SSD for the OS boot and 256Gb RAID1 NVMe for the data partition
  • 1Gbps NIC that will run on 2 VLAN, 1 for private network and 1 for public network
  • Dual E5-4650v2

Please follow these steps in this specific order.

General Installation

Here are the legworks that will need to be ran across all of the servers

yum -y install epel-release
rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum -y update && yum clean all
yum -y install httpd httpd-devel mod_ssl && yum clean all
yum -y install gcc make openssl-devel python34 python34-devel python34-setuptools python-pip python-setuptools nano wget vim\vim-enhanced bash-completion yum-utils git
yum groupinstall -y base && yum groupinstall -y 'Development Tools
yum clean all
yum-config-manager --enable remi-php74
yum install -y php php-devel php-pear php-common php-dba php-gd php-intl php-ldap php-mbstring php-mysqlnd php-odbc php-pdo php-pecl-memcache php-pgsql php-pspell php-recode php-snmp php-soap php-xml php-zip php-xmlrpc
printf "\n" | pecl install mongodb
echo short_open_tag=On >> /etc/php.ini
echo extension=mongodb.so >> /etc/php.ini
yum -y install libgearman libgearman-devel
cd /opt && git clone https://github.com/wcgallego/pecl-gearman.git
cd /opt/pecl-gearman && phpize && ./configure && make && make install
echo extension=gearman.so >> /etc/php.ini 
sed -i 's/allow_url_include = Off/allow_url_include = On/g' /etc/php.ini
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 200M/g' /etc/php.ini
sed -i 's/post_max_size = 8M/post_max_size = 200M/g' /etc/php.ini
sed -i 's/memory_limit = 128M/memory_limit = -1/g' /etc/php.ini
sed -i 's/max_execution_time = 30/max_execution_time = 1800/g' /etc/php.ini
echo date.timezone = America/New_York >> /etc/php.ini
sed -i 's/AllowOverride None/AllowOverride All/g' /etc/httpd/conf/httpd.conf 


yum install ntp ntpdate -y && ntpdate -u -s 0.centos.pool.ntp.org 1.centos.pool.ntp.org 2.centos.pool.ntp.org && \cp -r /usr/share/zoneinfo/America/New_York /etc/localtime
easy_install pip
pip install supervisor

Code Deployment:

There are several ways that you can deploy the code to the servers, git, deployhq, Jenkins, scp are some of the most common ways, or you can also just zip and upload via filezilla. I will not cover the code deployment in this tutorial. Here are the main things after you’ve already uploaded the code. Make sure the main folders (bin,ddl,etc,www) reside inside this directory, /var/www/html/. Make sure in the apache’s vhost config file, you point the DocumentRoot to /var/www/html/www/public for the backend, and /var/www/html/www for the frontend. Make sure to edit the .env for the backend to reflect the correct credentials to the MongoDB and MySQL Make sure to edit the config.php file to reflect the correct API server’s URL Make sure to edit the /var/www/html/www/public/index.php to add the correct URL of the frontend’s URL Run “composer require” to install all necessary 3rd party libraries Make sure you set permissions accordingly and disable selinux “chmod 755 -R /var/www/html/www/public” AND “chmod 755 -R “/var/www/html/www/writable” “chown apache:apache -R /var/www/html/www/public” AND “chown apache:apache -R /var/www/html/www/writable” setenforce 0

Database Deployment

You can use PHPMySQL or plenty of other platforms out there to import the SQL file in the “DDL” folder. I recommend Heidi as it’s the tool that I use to export the SQL file in the development environment.

Gearmand Deployment

On the worker’s servers, we can launch gearmand by issuing this command “gearmand --listen 0.0.0.0 --port 8888 --log-file /var/log/gearmand.log -d” In this command, we set it to listen on ALL IPs via port 8888 in this machine, this is very insecure. I recommend that we set it to only listen to private IP that can communicate with other machines in the network, ie 192.168.X.Y. One thing about gearmand is, its log file can get pretty big over time, so we definitely need to keep an eye on the log file to make sure it won’t take up too much space on the hard drive.

Supervisor Deployment

On the worker’s machine, run this command “supervisord -c /var/www/html/www/etc/supervisord.conf” This command will launch supervisord and kick start the worker’s processes. All changes can be made in the config file, such as increasing the workers for each process, change the http monitor port. To monitor the processes, we can go to “http://Worker_Machine_IP:9400” with the username and password as “shuser” and “shuser”.

Gearmand Monitor

In order to be able to monitor the gearmand’s queue and its job, we need to install the following code. https://github.com/yugene/Gearman-Monitor

On the frontend, make a new folder in /var/www/html, call it “gearmandmonitor”, we will need to pull the code from that repo and deploy it on server, make a new vhost in apache’s config file, and then run composer install so it can install all necessary libraries.

Once all is done, we will need to add the gearmand’s server info into the _config.php file, and that’s all needed to be done. Ie,

$cfgServers[$i]['address'] = 'gearmand_server_ip_production:8888';
$cfgServers[$i]['name'] = 'Production';
++ $i;
$cfgServers[$i]['address'] = 'gearmand_server_ip_staging:8888';
$cfgServers[$i]['name'] = 'Staging';
++ $i;
$cfgServers[$i]['address'] = 'gearmand_server_ip_dev:8888';
$cfgServers[$i]['name'] = 'Development';
++ $i;