实现基于NFS共享的LAMP wordpress应用
nfs服务器端配置
yum -y install nfs-utils
systemctl start nfs
mkdir -p /data/wordpress/webdata
------------------------------
vim /etc/exports.d/wp.exports
/data/wordpress/webdata 192.168.26.0/24(rw)
systemctl restart nfs
-------------------------------
mysql_A服务器配置
yum -y isntall mariadb-server
mysql_secure_installation
mysql
CREATE DATABASE wordpress;
GRANT ALL ON wordpress.* TO wordpress@'192.168.26.18' IDENTIFIED BY 'wordpress';
GRANT REPLICATION SLAVE ON *.* TO repliuser@'192.168.26.%' IDENTIFIED BY 'centos';
FLUSH PRIVILEGES
mysql_B服务器配置
yum -y isntall mariadb-server
mysql_secure_installation
mysql
CREATE DATABASE wordpress;
GRANT ALL ON wordpress.* TO wordpress@'192.168.26.28' IDENTIFIED BY 'wordpress';
GRANT REPLICATION SLAVE ON *.* TO repliuser@'192.168.26.%' IDENTIFIED BY 'centos';
FLUSH PRIVILEGES
wordpress_A配置
wordpress-5.3-zh_CN.tar.gz
tar xf wordpress-5.3-zh_CN.tar.gz -C /var/www/html
chown -R /var/www/html/wordpress
yum -y install php-fpm php-mysqlnd php-json httpd
systemctl start httpd
mkdir /var/www/html/wordpress/wp-content/uploads
echo "192.168.26.37:/data/wordpress/webdata /var/www/html/wordpress/wp-content/uploads nfs _netdev 0 0" >> /etc/fstab
mount 192.168.26.37:/data/wordpress/webdata /var/www/html/wordpress/wp-content/uploads
----------------------------------------
vim /etc/httpd/conf.d/wp.conf
DirectoryIndex index.php
<virtualhost *:80>
ServerName "bokebi.A.org"
DocumentRoot "/var/www/html/wordpress"
<directory /var/www/html/wordpress>
require all granted
</directory>
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi:
</virtualhost>
-------------------------------------------
;listen = /run/php-fpm/www.sock
listen = 127.0.0.1:9000
systemctl restart httpd
systemctl start php-fpm.service
wordpress_B配置
wordpress-5.3-zh_CN.tar.gz
tar xf wordpress-5.3-zh_CN.tar.gz -C /var/www/html
chown -R /var/www/html/wordpress
yum -y install php-fpm php-mysqlnd php-json httpd
systemctl start httpd
mkdir /var/www/html/wordpress/wp-content/uploads
echo "192.168.26.37:/data/wordpress/webdata /var/www/html/wordpress/wp-content/uploads nfs _netdev 0 0" >> /etc/fstab
mount 192.168.26.37:/data/wordpress/webdata /var/www/html/wordpress/wp-content/uploads
----------------------------------------
vim /etc/httpd/conf.d/wp.conf
DirectoryIndex index.php
<virtualhost *:80>
ServerName "bokebi.B.org"
DocumentRoot "/var/www/html/wordpress"
<directory /var/www/html/wordpress>
require all granted
</directory>
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi:
</virtualhost>
-------------------------------------------
;listen = /run/php-fpm/www.sock
listen = 127.0.0.1:9000
systemctl restart httpd
systemctl start php-fpm.service
windows端设置
C:\Windows\System32\drivers\etc\hosts
192.168.26.18 bokebi.A.org
192.168.26.28 bokebi.B.org
公共设置-按步骤设置
按正常步骤完成安装步骤
主要注意填写连接数据库的地址bokebi.A.org填写为192.168.26.47
主要注意填写连接数据库的地址bokebi.B.org填写为192.168.26.27
=========================================================
vim /etc/my.cnf.d/server.cnf
[mysqld]
server_id=17
log_bin
auto_increment_offset=1
auto_increment_increment=2
---------------------------------------
systemctl restart mariadb.service
---------------------------------------
[root@master ~]
MariaDB [(none)]> SHOW MASTER LOGS;
+--------------------+-----------+
| Log_name | File_size |
+--------------------+-----------+
| mariadb-bin.000001 | 245 |
+--------------------+-----------+
1 row in set (0.00 sec)
=========================================================
vim /etc/my.cnf.d/server.cnf
[mysqld]
server_id=27
log_bin
auto_increment_offset=2
auto_increment_increment=2
---------------------------------------
systemctl restart mariadb.service
---------------------------------------
[root@master ~]
MariaDB [(none)]> HELP CHANGE MASTER TO;
MariaDB [(none)]> CHANGE MASTER TO
-> MASTER_HOST='192.168.26.47',
-> MASTER_USER='repliuser',
-> MASTER_PASSWORD='centos',
-> MASTER_PORT=3306,
-> MASTER_LOG_FILE='mariadb-bin.000001',
-> MASTER_LOG_POS=245,
-> MASTER_CONNECT_RETRY=10;
Query OK, 0 rows affected (0.01 sec)
----------------------------------------
MariaDB [(none)]> START SLAVE;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> SHOW SLAVE STATUS\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.26.17
Master_User: repliuser
Master_Port: 3306
Connect_Retry: 10
Master_Log_File: mariadb-bin.000001
Read_Master_Log_Pos: 406
Relay_Log_File: mariadb-relay-bin.000003
Relay_Log_Pos: 692
Relay_Master_Log_File: mariadb-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 406
Relay_Log_Space: 988
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 17
1 row in set (0.00 sec)
-------------------------------------
MariaDB [(none)]> SHOW MASTER LOGS;
+--------------------+-----------+
| Log_name | File_size |
+--------------------+-----------+
| mariadb-bin.000001 | 245 |
+--------------------+-----------+
1 row in set (0.00 sec)
=========================================================
MariaDB [(none)]> HELP CHANGE MASTER TO;
MariaDB [(none)]> CHANGE MASTER TO
-> MASTER_HOST='192.168.26.27',
-> MASTER_USER='repliuser',
-> MASTER_PASSWORD='centos',
-> MASTER_PORT=3306,
-> MASTER_LOG_FILE='mariadb-bin.000001',
-> MASTER_LOG_POS=245,
-> MASTER_CONNECT_RETRY=10;
Query OK, 0 rows affected (0.01 sec)
-------------------------------------
MariaDB [(none)]> START SLAVE;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> SHOW SLAVE STATUS\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.26.27
Master_User: repliuser
Master_Port: 3306
Connect_Retry: 10
Master_Log_File: mariadb-bin.000001
Read_Master_Log_Pos: 245
Relay_Log_File: mariadb-relay-bin.000002
Relay_Log_Pos: 531
Relay_Master_Log_File: mariadb-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 245
Relay_Log_Space: 827
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 27
1 row in set (0.00 sec)
测试实验结果
- 浏览器访问bokebi.B.org 登陆能查看bokebi.A.org站点创建上传的文章