do we can manualy using this methode ?
master : 10.11.32.180
slave : 10.11.32.190
virtual_ip : 10.11.32.222
domain : your_domain
-----------------MASTER------------------
(Master & Slave )
sudo apt update && sudo apt upgrade -y
sudo apt install apache2 -y
sudo apt install php libapache2-mod-php php-mysql -y
sudo apt install mariadb-server mariadb-client -y
Database:
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
sudo systemctl restart mysql
sudo mysql
CREATE USER 'wpuser'@'%' IDENTIFIED BY 'password';
GRANT ALL ON . TO 'wpuser'@'%';
GRANT REPLICATION SLAVE ON . TO 'wpuser'@'%';
FLUSH PRIVILEGES;
show master status\G;
2.1 CREATE DATABASE wpdb DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
- Keepalived (Master & Slave )
sudo apt-get install keepalived -y
sudo nano /etc/sysctl.conf
net.ipv4.ip_nonlocal_bind=1
sudo sysctl -p
4.1 Master
sudo nano /etc/keepalived/keepalived.conf
global_defs {
router_id test1
}
vrrp_script chk_haproxy {
script "killall -0 haproxy"
interval 2
weight 2
}
vrrp_instance VI_1 {
virtual_router_id 51
advert_int 1
priority 100
state MASTER
interface ens33
virtual_ipaddress {
virtual_ip dev ens33
}
authentication {
auth_type PASS
auth_pass 123456
}
track_script {
chk_haproxy
}
}
sudo service keepalived start
- GlusterFS (Master & Slave )
sudo nano /etc/hosts
sudo add-apt-repository ppa:gluster/glusterfs-7
sudo apt update
sudo apt install glusterfs-server -y
sudo systemctl start glusterd.service
sudo systemctl enable glusterd.service
5.1 Master
sudo gluster peer probe slave
sudo gluster peer status
sudo gluster volume create volume1 replica 2 master:/gluster-storage slave:/gluster-storage force
sudo gluster volume start volume1
sudo gluster volume status
sudo mount -t glusterfs master:/volume1 /var/www/html
sudo nano /etc/fstab
master:/volume1 /var/www/html glusterfs defaults,_netdev 0 0
WordPress
cd /var/www/html
sudo wget http://wordpress.org/latest.tar.gz
sudo tar xzf latest.tar.gz
sudo mv wordpress/* .
sudo chown -R www-data:www-data /var/www/html
Port Forwarding
80,443
HTTPS
sudo apt install python3-certbot-apache -y
sudo certbot --apache -d <domain> -d <www.domain>
------------------------SLAVE--------------
- Database:
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
sudo mysql
CHANGE MASTER TO MASTER_HOST='10.11.32.180',
MASTER_USER='wpuser',
MASTER_PASSWORD='password',
MASTER_LOG_FILE=' ',
MASTER_LOG_POS=your_position;
start slave;
show slave status\G;
1.2 Create user_read_only
sudo mysql
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'password';
GRANT SELECT on wpdb.* to 'wpuser'@'localhost';
FLUSH PRIVILEGES;
- Keepalived
sudo nano /etc/keepalived/keepalived.conf
global_defs {
router_id test2
}
vrrp_script chk_haproxy {
script "killall -0 haproxy"
interval 2
weight 2
}
vrrp_instance VI_1 {
virtual_router_id 51
advert_int 1
priority 99
state BACKUP
interface ens33
virtual_ipaddress {
virtual_ip dev ens33
}
authentication {
auth_type PASS
auth_pass 123456
}
track_script {
chk_haproxy
}
}
sudo service keepalived start
- GlusterFS
sudo gluster peer probe node1
sudo gluster peer status
sudo gluster volume create volume1 replica 2 node1:/gluster-storage node2:/gluster-storage force
sudo mount -t glusterfs slave:/volume1 /var/www/html
sudo nano /etc/fstab
slave:/volume1 /var/www/html glusterfs defaults,_netdev 0 0
- HTTPS
sudo apt install python3-certbot-apache -y
sudo certbot --apache -d <domain> -d <www.domain>