搭建MYSQL数据库MHA高可用
#使用半同步复制,GTID,mycat,MHA,一主二从模式搭建
mycat 10.0.0.157
mysql-master 10.0.0.158
mysql-slave1 10.0.0.159
mysql-slave2 10.0.0.160
MHA 10.0.0.51 (此机器是centos7)
#三台机器的mysql使用二进制脚本安装
[root@mysql-master ~]#ls
anaconda-ks.cfg install_mysql.sh mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz
[root@mysql-master ~]#bash install_mysql.sh
1) 离线安装MYSQL
2) 在线安装MYSQL
3) 退出
请按要求输入操作选项:1
离线安装MYSQL
请输入安装文件名:mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz
#准备二进制日志目录
[root@mysql-master data]#for i in 10.0.0.{158..160} ;do ssh root@$i "hostname;mkdir /data/mysqllog;chown -R mysql.mysql /data/mysqllog" ;done
mysql-master
mysql-slave1
mysql-slave2
#mysql-master 10.0.0.158 配置
[root@mysql-master data]#vim /etc/my.cnf
[mysqld]
datadir=/data/mysql
skip_name_resolve=1
socket=/data/mysql/mysql.sock
log-error=/data/mysql/mysql.log
pid-file=/data/mysql/mysql.pid
log_bin=/data/mysqllog/binlog
binlog_checksum=NONE
default_authentication_plugin=mysql_native_password
server-id=158
gtid_mode=ON
enforce_gtid_consistency=ON
plugin-load-add="semisync_master.so"
rpl_semi_sync_master_enabled=ON
rpl_semi_sync_master_timeout=3000
[client]
socket=/data/mysql/mysql.sock
[root@mysql-master data]#service mysqld restart
Shutting down MySQL. [ OK ]
Starting MySQL. [ OK ]
#创建同步账号
[root@mysql-master ~]#mysql -p123456
mysql> create user repluser@"10.0.0.%" identified by "123456";
Query OK, 0 rows affected (3.01 sec)
mysql> grant replication slave on *.* to repluser@"10.0.0.%";
Query OK, 0 rows affected (0.00 sec)
#创建数据库shopxo,及同步账号
mysql> create database shopxp;
Query OK, 1 row affected (0.01 sec)
mysql> create user shopxo@'10.0.0.%' identified by '123456';
Query OK, 0 rows affected (0.01 sec)
mysql> grant all on shopxo.* to shopxo@'10.0.0.%';
Query OK, 0 rows affected (0.00 sec)
#配置 mysql-slave1 10.0.0.159 mysql-slave2 10.0.0.160 (步骤相同此处省略mysql-slave2)
[root@mysql-slave1 ~]#vim /etc/my.cnf
[mysqld]
datadir=/data/mysql
skip_name_resolve=1
socket=/data/mysql/mysql.sock
log-error=/data/mysql/mysql.log
pid-file=/data/mysql/mysql.pid
server-id=159
log_bin=/data/mysqllog/binlog
read-only
plugin-load-add="semisync_slave.so"
rpl_semi_sync_slave_enabled=ON
binlog_checksum=NONE
default_authentication_plugin=mysql_native_password
gtid_mode=ON
enforce_gtid_consistency=ON
[client]
socket=/data/mysql/mysql.sock
[root@mysql-slave1 ~]#service mysqld restart
Shutting down MySQL. [ OK ]
Starting MySQL. [ OK ]
[root@mysql-slave2 ~]#mysql -p123456
mysql> CHANGE MASTER TO MASTER_HOST='10.0.0.158',
-> MASTER_USER='repluser',
-> MASTER_PASSWORD='123456',
-> MASTER_PORT=3306,
-> MASTER_AUTO_POSITION=1;
Query OK, 0 rows affected, 8 warnings (0.01 sec)
mysql> start slave;
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for source to send event
Master_Host: 10.0.0.158
Master_User: repluser
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: binlog.000002
Read_Master_Log_Pos: 662
Relay_Log_File: mysql-slave2-relay-bin.000002
Relay_Log_Pos: 864
Relay_Master_Log_File: binlog.000002
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: 662
Relay_Log_Space: 1073
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: 158
Master_UUID: f0639d0f-2ea3-11ed-b276-000c29cc3cb4
Master_Info_File: mysql.slave_master_info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Replica has read all relay log; waiting for more updates
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set: f0639d0f-2ea3-11ed-b276-000c29cc3cb4:1-2
Executed_Gtid_Set: f0639d0f-2ea3-11ed-b276-000c29cc3cb4:1-2
Auto_Position: 1
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
Master_public_key_path:
Get_master_public_key: 0
Network_Namespace:
1 row in set, 1 warning (0.00 sec)
#配置mycat 10.0.0.157
[root@mycat ~]#yum -y install java
[root@mycat ~]#java -version
openjdk version "1.8.0_342"
OpenJDK Runtime Environment (build 1.8.0_342-b07)
OpenJDK 64-Bit Server VM (build 25.342-b07, mixed mode)
[root@mycat ~]#wget http://dl.mycat.org.cn/1.6.7.4/Mycat-server-1.6.7.4-release/Mycat-server-1.6.7.4-release-20200105164103-linux.tar.gz
[root@mycat ~]#mkdir /apps
[root@mycat ~]#tar xf Mycat-server-1.6.7.4-release-20200105164103-linux.tar.gz -C /apps
[root@mycat ~]#vim /etc/profile.d/mycat.sh
PATH=/apps/mycat/bin:$PATH
[root@mycat ~]#source /etc/profile.d/mycat.sh
[root@mycat ~]#mycat start
Starting Mycat-server...
[root@mycat ~]#mycat status
Mycat-server is running (23554).
#连接测试
[root@localhost ~]#mysql -uroot -p123456 -h 10.0.0.156 -P8066
mysql> show databases;
+----------+
| DATABASE |
+----------+
| TESTDB |
+----------+
1 row in set (0.01 sec)
[root@mycat ~]#vim /apps/mycat/conf/server.xml
<property name="serverPort">3306</property>
<property name="handlelDistributedTransactions">0</property> #将上面行放在此行前面
......
<user name="root" defaultAccount="true">
<property name="password">123456</property>
<property name="schemas">shopxo</property>
<property name="defaultSchema">shopxo</property>
<!--No MyCAT Database selected 错误前会尝试使用该schema作为schema,不设置则为null,报错 -->
<!-- 表级 DML 权限设置 -->
<!--
<privileges check="false">
<schema name="TESTDB" dml="0110" >
<table name="tb01" dml="0000"></table>
<table name="tb02" dml="1111"></table>
</schema>
</privileges>
-->
</user>
<user name="user">
<property name="password">user</property>
<property name="schemas">shopxo</property>
<property name="readOnly">true</property>
<property name="defaultSchema">shopxo</property>
</user>
[root@mycat ~]#vim /apps/mycat/conf/schema.xml
<?xml version="1.0"?>
<!DOCTYPE mycat:schema SYSTEM "schema.dtd">
<mycat:schema xmlns:mycat="http://io.mycat/">
<schema name="shopxo" checkSQLschema="false" sqlMaxLimit="100" dataNode="dn1">
</schema>
<dataNode name="dn1" dataHost="localhost1" database="shopxo" />
<dataHost name="localhost1" maxCon="1000" minCon="10" balance="1"
writeType="0" dbType="mysql" dbDriver="native" switchType="1" slaveThreshold="100">
<heartbeat>select user()</heartbeat>
<writeHost host="host1" url="10.0.0.158:3306" user="mycat" password="123456">
<readHost host="host2" url="10.0.0.159:3306" user="mycat" password="123456" />
<readHost host="host3" url="10.0.0.161:3306" user="mycat" password="123456" />
</writeHost>
</dataHost>
</mycat:schema>
#去数据库主节点建立同步账号mycat
mysql> create user mycat@'10.0.0.%' identified by '123456';
Query OK, 0 rows affected (0.01 sec)
mysql> grant all on *.* to mycat@'10.0.0.%';
Query OK, 0 rows affected (0.00 sec)
[root@mycat ~]#mycat restart
Stopping Mycat-server...
Stopped Mycat-server.
Starting Mycat-server...
#配置MHA 10.0.0.151
[root@mha ~]# ll
total 124
-rw-------. 1 root root 1569 Sep 8 09:51 anaconda-ks.cfg
-rw-r--r--. 1 root root 1599 Sep 8 09:56 initial-setup-ks.cfg
-rw-r--r--. 1 root root 81024 Aug 29 2020 mha4mysql-manager-0.58-0.el7.centos.noarch.rpm
-rw-r--r--. 1 root root 36328 Aug 29 2020 mha4mysql-node-0.58-0.el7.centos.noarch.rpm
[root@mha ~]# yum -y install mha4mysql-node-0.58-0.el7.centos.noarch.rpm
[root@mha ~]# yum -y install mha4mysql-manager-0.58-0.el7.centos.noarch.rpm
#在管理节点建立配置文件
[root@mha ~]# vim /etc/mastermha/app1.cnf
[server default]
check_repl_delay=0
manager_log=/data/mastermha/app1/manager.log
manager_workdir=/data/mastermha/app1/
master_binlog_dir=/data/mysqllog/
master_ip_failover_script=/usr/local/bin/master_ip_failover
password=123456
ping_interval=1
remote_workdir=/data/mastermha/app1/
repl_password=123456
repl_user=repluser
report_script=/usr/local/bin/sendmail.sh
ssh_user=root
user=mhauser
[server1]
hostname=10.0.0.158
candidate_master=1
[server1]
hostname=10.0.0.159
[server2]
candidate_master=1
hostname=10.0.0.160
[root@mha ~]# vim /usr/local/bin/sendmail.sh
#!/bin/bash
echo "MHA is failover!" | mail -s "MHA Warning" root@10.0.0.156
[root@mha ~]# chmod +x /usr/local/bin/sendmail.sh
[root@mha ~]# vim /usr/local/bin/master_ip_failover
#!/usr/bin/env perl
# Copyright (C) 2011 DeNA Co.,Ltd.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
## Note: This is a sample script and is not complete. Modify the script based onyour environment.
use strict;
use warnings FATAL => 'all';
use Getopt::Long;
use MHA::DBHelper;
my (
$command, $ssh_user, $orig_master_host,
$orig_master_ip, $orig_master_port, $new_master_host,
$new_master_ip, $new_master_port, $new_master_user,
$new_master_password
);
my $vip = '10.0.0.100/24';
my $key = "1";
my $ssh_start_vip = "/sbin/ifconfig eth0:$key $vip";
my $ssh_stop_vip = "/sbin/ifconfig eth0:$key down";
GetOptions(
'command=s' => \$command,
'ssh_user=s' => \$ssh_user,
'orig_master_host=s' => \$orig_master_host,
'orig_master_ip=s' => \$orig_master_ip,
'orig_master_port=i' => \$orig_master_port,
'new_master_host=s' => \$new_master_host,
'new_master_ip=s' => \$new_master_ip,
'new_master_port=i' => \$new_master_port,
'new_master_user=s' => \$new_master_user,
'new_master_password=s' => \$new_master_password,
);
exit &main();
sub main {
if ( $command eq "stop" || $command eq "stopssh" ) {
# $orig_master_host, $orig_master_ip, $orig_master_port are passed.
# If you manage master ip address at global catalog database,
# invalidate orig_master_ip here.
my $exit_code = 1;
eval {
# updating global catalog, etc
$exit_code = 0;
};
if ($@) {
warn "Got Error: $@\n";
exit $exit_code;
}
exit $exit_code;
}
elsif ( $command eq "start" ) {
# all arguments are passed.
# If you manage master ip address at global catalog database,
# activate new_master_ip here.
# You can also grant write access (create user, set read_only=0, etc)here.
my $exit_code = 10;
eval {
print "Enabling the VIP - $vip on the new master - $new_master_host\n";
&start_vip();
&stop_vip();
$exit_code = 0;
};
if ($@) {
warn $@;
exit $exit_code;
}
exit $exit_code;
}
elsif ( $command eq "status" ) {
print "Checking the Status of the script.. OK \n";
ssh $ssh_user\@$orig_master_host \" $ssh_start_vip \"
;
exit 0;
}
else {
&usage();
exit 1;
}
}
sub start_vip() {
ssh $ssh_user\@$new_master_host \" $ssh_start_vip \"
;
}
# A simple system call that disable the VIP on the old_master
sub stop_vip() {
ssh $ssh_user\@$orig_master_host \" $ssh_stop_vip \"
;
}
sub usage {
print
"Usage: master_ip_failover --command=start|stop|stopssh|status --
orig_master_host=host --orig_master_ip=ip --orig_master_port=port --
new_master_host=host --new_master_ip=ip --new_master_port=port\n";
[root@mha ~]# chmod +x /usr/local/bin/master_ip_failover
#mysql上建立同步账号
mysql> create user mhauser@'10.0.0.%' identified by '123456';
Query OK, 0 rows affected (0.02 sec)
mysql> grant all on *.* to mhauser@'10.0.0.%';
Query OK, 0 rows affected (0.00 sec)
#master配置文件修改
[root@mysql-master ~]#vim /etc/my.cnf
skip_name_resolve=1
general_log
[root@mysql-master ~]#systemctl restart mysqld.service
#slave配置文件修改
[root@mysql-slave ~]#vim /etc/my.cnf
skip_name_resolve=1
general_log
relay_log_purge=0
[root@slave ~]#systemctl restart mysqld.service
[root@mha ~]# masterha_check_ssh --conf=/etc/mastermha/app1.cnf
[root@mha ~]# masterha_check_repl --conf=/etc/mastermha/app1.cnf
[root@mha ~]# nohup masterha_manager --conf=/etc/mastermha/app1.cnf --remove_dead_master_conf --ignore_last_failover &> /dev/null
[root@mha ~]# masterha_check_status --conf=/etc/mastermha/app1.cnf
app1 (pid:3765) is running(0:PING_OK), master:10.0.0.158
#修改mycat配置为vip地址
[root@mycat ~]#vim /apps/mycat/conf/schema.xml
<writeHost host="host1" url="10.0.0.100:3306" user="mycat" password="123456">
[root@mycat ~]#mycat restart
Stopping Mycat-server...
Stopped Mycat-server.
Starting Mycat-server...
[root@mycat ~]#mycat status
Mycat-server is running (25555).
apache部署shopxp网站
shopxo1 10.0.0.200
shopxo2 10.0.0.101
#安装配置 shopxo1/10.0.0.200和shopxo2/10.0.0.201 (此处只记录一台机器操作步骤,另一台操作相同)
#准备shopxo-v2.3.0.zip文件,可以wget下载,本次是本地上传
[root@Ubuntu2004 ~]#apt -y install apache2 php7.4-fpm libapache2-mod-php7.4 php7.4-mysql php7.4-json php7.4-xml php7.4-mbstring php7.4-zip php7.4-gd php7.4-curl
[root@shopxo2 www]#scp shopxo-v2.3.0.zip 10.0.0.200:/var/www
[root@shopxo2 www]#unzip shopxo-v2.3.0.zip
[root@shopxo2 www]#mv shopxo-v2.3.0/* html/
[root@shopxo2 www]#chown -R www-data. html/
[root@shopxo2 www]#systemctl restart apache2
#此处把网站长的数据库文件考到另一台服务器上替换,避免重复建表
[root@shopxo2 www]#scp html/config/database.php 10.0.0.200:/var/www/html/config
DNS主从配置
dns-master 10.0.0.153
dns-slave 10.0.0.154
#dns-master 10.0.0.153
#运行脚本安装dns
[root@dns-master ~]#bash install-dns.sh
#修改部分配置
[root@dns-master ~]#vim /etc/named.conf
// listen-on port 53 { localhost; };
// listen-on-v6 port 53 { ::1; };
[root@dns-master ~]#vim /var/named/shopxo.xo.zone
www A 10.0.0.200
www A 10.0.0.201
[root@dns-master ~]#rndc reload
server reload successful
#配置dns-slave 10.0.0.154
[root@dns-slave slaves]#bash install-dns.sh
[root@dns-slave slaves]#vim /etc/named.conf
// listen-on port 53 { localhost; };
// listen-on-v6 port 53 { ::1; };
[root@dns-slave slaves]#vim /etc/named.rfc1912.zones
zone "shopxo.xo" IN {
type slave;
masters { 10.0.0.153; };
file "slaves/shopxo.xo.slave";
};
[root@dns-slave ~]#cd /var/named
[root@dns-slave named]#rm shopxo.xo.zone
[root@dns-slave slaves]#systemctl restart named
NFS和备份服务器
#安装配置NFS
[root@nfs ~]#yum -y install nfs-utils
[root@nfs ~]#mkdir /data/www
#根据shopxo的两台服务器创建用户和组,注意id要相同
[root@nfs ~]#useradd -u 33 -g tape www-data
[root@nfs ~]#id www-data
uid=33(www-data) gid=33(tape) groups=33(tape) #由于rocky33组id是系统内存在的所以只能创建用户把组指过去
[root@nfs ~]#vim /etc/exports
# /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)
#
/data/www 10.0.0.0/24(rw,all_squash,anonuid=33,anongid=33)
[root@nfs www]#exportfs -r
[root@nfs www]#exportfs -v
/data/www 10.0.0.0/24(sync,wdelay,hide,no_subtree_check,anonuid=33,anongid=33,sec=sys,rw,secure,root_squash,all_squash)
#配置shopxo两台服务器进行远程目录挂载
[root@shopxo1 ~]#apt -y install nfs-kernel-server
[root@shopxo1 ~]#vim /etc/fstab
10.0.0.155:/data/www /var/www/html/public/static/upload/ nfs _netdev 0 0
[root@shopxo1 upload]#mount -a
[root@shopxo1 upload]#df -h
文件系统 容量 已用 可用 已用% 挂载点
udev 933M 0 933M 0% /dev
tmpfs 196M 1.1M 195M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 98G 5.3G 87G 6% /
tmpfs 977M 0 977M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 977M 0 977M 0% /sys/fs/cgroup
/dev/sda2 1.5G 205M 1.2G 15% /boot
tmpfs 196M 0 196M 0% /run/user/0
10.0.0.155:/data/www 70G 2.4G 68G 4% /var/www/html/public/static/upload
backup服务器基于rsync daemon 实现 sersync
#backup服务器配置10.0.0.156
[root@backup data]#dnf -y install rsync-daemon
[root@backup data]#vi /etc/rsyncd.conf
uid = root
gid = root
max connections = 0
ignore errors
exclude = lost+found/
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsyncd.lock
reverse lookup = no
[backup]
path = /data/backup/
comment = backup dir
read only = no
auth users = rsyncuser
secrets file = /etc/rsync.pas
[root@backup data]#mkdir -pv /data/backup
[root@backup data]#echo "rsyncuser:123456" > /etc/rsync.pas
[root@backup data]#chmod 600 /etc/rsync.pas
[root@backup data]#rsync --daemon
[root@backup data]#systemctl start rsyncd
#10.0.0.155客户端nfs服务器配置
[root@nfs ~]#ll
total 712
-rw-r--r-- 1 root root 727290 Jul 3 2021 sersync2.5.4_64bit_binary_stable_final.tar.gz
wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/sersync/sersync2.5.4_64bit_binary_stable_final.tar.gz
[root@nfs ~]#tar xf sersync2.5.4_64bit_binary_stable_final.tar.gz
[root@nfs ~]#cp -a GNU-Linux-x86 /usr/local/sersync
[root@nfs ~]#echo 'PATH=/usr/local/sersync:$PATH' > /etc/profile.d/sersync.sh
[root@nfs ~]#source /etc/profile.d/sersync.sh
[root@nfs ~]#rpm -q rsync &> /dev/null || dnf -y install rsync
[root@nfs ~]#yum -y install rsync
[root@nfs ~]#cp /usr/local/sersync/confxml.xml{,.bak}
[root@nfs ~]#vim /usr/local/sersync/confxml.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<head version="2.5">
<host hostip="localhost" port="8008"></host>
<debug start="false"/>
<fileSystem xfs="false"/>
<filter start="false">
<exclude expression="(.*)\.svn"></exclude>
<exclude expression="(.*)\.gz"></exclude>
<exclude expression="^info/*"></exclude>
<exclude expression="^static/*"></exclude>
</filter>
<inotify>
<delete start="true"/>
<createFolder start="true"/>
<createFile start="true"/>
<closeWrite start="true"/>
<moveFrom start="true"/>
<moveTo start="true"/>
<attrib start="true"/>
<modify start="true"/>
</inotify>
<sersync>
<localpath watch="/data/www/">
<remote ip="10.0.0.101" name="backup"/>
<!--<remote ip="192.168.8.39" name="tongbu"/>-->
<!--<remote ip="192.168.8.40" name="tongbu"/>-->
</localpath>
<rsync>
<commonParams params="-artuz"/>
<auth start="true" users="rsyncuser" passwordfile="/etc/rsync.pas"/>
<userDefinedPort start="false" port="874"/><!-- port=874 -->
<timeout start="false" time="100"/><!-- timeout=100 -->
<ssh start="false"/>
</rsync>
<failLog path="/tmp/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins execute once-->
<crontab start="false" schedule="600"><!--600mins-->
<crontabfilter start="false">
<exclude expression="*.php"></exclude>
<exclude expression="info/*"></exclude>
</crontabfilter>
</crontab>
<plugin start="false" name="command"/>
</sersync>
<plugin name="command">
<param prefix="/bin/sh" suffix="" ignoreError="true"/> <!--prefix /opt/tongbu/mmm.sh suffix-->
<filter start="false">
<include expression="(.*)\.php"/>
<include expression="(.*)\.sh"/>
</filter>
</plugin>
<plugin name="socket">
<localpath watch="/opt/tongbu">
<deshost ip="192.168.138.20" port="8009"/>
</localpath>
</plugin>
<plugin name="refreshCDN">
<localpath watch="/data0/htdocs/cms.xoyo.com/site/">
<cdninfo domainname="ccms.chinacache.com" port="80" username="xxxx" passwd="xxxx"/>
<sendurl base="http://pic.xoyo.com/cms"/>
<regexurl regex="false" match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"/>
</localpath>
</plugin>
</head>
[root@nfs ~]#echo 123456 > /etc/rsync.pas
[root@nfs ~]#chmod 600 /etc/rsync.pas
[root@nfs ~]#sersync2 -dro /usr/local/sersync/confxml.xml
#查看是否同步
[root@backup data]#cd backup/
[root@backup backup]#ll
total 4
drwxr-xr-x 2 33 tape 24 Aug 18 15:42 file
drwxr-xr-x 12 33 tape 186 Aug 18 15:42 images
-rwxr-xr-x 1 33 tape 1 Sep 8 08:54 index.html
drwxr-xr-x 3 33 tape 37 Aug 18 15:42 video
配置LVS服务器
#此处使用NAT模式,rr轮询算法
[root@LVS-server ~]#yum -y install ipvsadm.x86_64
#网络配置
VIP:192.168.0.200
DIP:10.0.0.161
[root@LVS-server ~]#ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:0c:29:94:d4:92 brd ff:ff:ff:ff:ff:ff
inet 10.0.0.161/24 brd 10.0.0.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:0c:29:94:d4:9c brd ff:ff:ff:ff:ff:ff
inet 192.168.0.200/24 brd 192.168.0.255 scope global noprefixroute eth1
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe94:d49c/64 scope link
valid_lft forever preferred_lft forever
[root@LVS-server ~]#ipvsadm -A -t 192.168.0.200:80 -s rr
[root@LVS-server ~]#ipvsadm -a -t 192.168.0.200:80 -r 10.0.0.200:80 -m
[root@LVS-server ~]#ipvsadm -a -t 192.168.0.200:80 -r 10.0.0.201:80 -m
[root@LVS-server ~]#ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.0.200:80 rr
-> 10.0.0.200:80 Masq 1 0 0
-> 10.0.0.201:80 Masq 1 0 0
#注意将shopxo1和shopxo2的网关指向10.0.0.161,LVS服务器
#修改DNS域名解析将两个www地址合并为一个192.168.0.200