LAMP 环境同步:
主:CENTOS 从 :WINDOWS
MYSQL 同步
设置主服务器
<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
[root@centos etc]# cat /etc/my.cnf
[mysqld]
server-id=1
log-bin
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
配置从服务器:
C:\APMServ<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />5.2.6\MySQL5.1\my.ini
[mysqld]
basedir=C:/APMServ5.2.6/MySQL5.1
datadir=C:/APMServ5.2.6/MySQL5.1/data
port=3306
interactive_timeout=240
wait_timeout=240
server-id=2
master-host=192.168.0.185
master-port=3306
master-user=admin
master-password=123456
master-connect-retry=60
replicate-do-db=dvbbs
mysql>show master status; 查看主服务器状态.
mysql>show slave status\G ;查看从服务器状态
APACHE 同步
[root@centos etc]# cat rsyncd.conf
uid = root
gid = root
use chroot = no
max connections = 20
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
[web]
path = /var/www/html/bbs/
ignore errors
read only = yes
hosts allow = 192.168.0.0/24
hosts deny = 0.0.0.0/32
LINUX 下同步:
编写同步脚本:
#!/bin/sh
while true
do
/usr/bin/rsync -av 192.168.0.185::web /bbs/ >dev/null 2>&1
sleep 20
done
WINDOWS 下同步:
Windows setup cwRsync_3.1.0_Installer.zip 软件..
编写同步脚本:
@echo off
:1
echo 同步中
rsync -av 192.168.0.185::web \bbs\
ping 127.0 -n 2 >nul 2>nul
goto 1
转载于:https://blog.51cto.com/frankzhao/249418