1、主 host:www IP:192.168.9.124从 host:www1 IP:192.168.9.123#下载 mysqlwget http:/ #安装 mysqltar xzf mysql-5.1.58-linux-i686-glibc23.tar.gzuseradd mysqlmv mysql-5.1.58-linux-i686-glibc23 /usr/local/mysqlchown -R root .chown -R mysql datacp support-files/my-f /etc/fbin/mysqld_safe -user=mysql #授权 192.168.9.1
2、23 登陆 mysqlmysql flush privileges; #刷新权限表mysql exit;在从服务器测试www1# mysql -u root -h 192.168.9.124 -pwwwmysql FLUSH TABLES WITH READ LOCK; (主库加锁)记录日志和偏移量mysql show master status ; mysqldump -p -all-database -lock-all-tables db.sqlwww1scp -P root192.168.9.124:/root/db.sql .# 修改从 f #server-id=2master-hos
3、t=192.168.9.124master-user=slavemaster-password=123456master-port=3306log-bin=mysql-bin-重启 mysqllsof -i:3306 |xargs kill -9/usr/local/mysql/bin/mysqld_safe -user=mysql (主库解锁)mysqlshow master status ;www1mysql slave stop;mysql CHANGE MASTER TO MASTER_HOST=192.168.9.124, MASTER_USER=root,MASTER_PASSWO
4、RD=123456,MASTER_LOG_FILE=mysql-bin.000001,MASTER_LOG_POS=548; (后面 log_file log_pos 参照主库的日志名称和偏移量)mysql slave start ;查状态mysql show master status;mysql show slave status;mysql show processlist ;www-A INPUT -s 192.168.9.123 -p tcp -dport 3306 -j ACCEPT 放行192.168.9.123连接 3306端口-A INPUT -p tcp -dport 22 -j ACCEPT #允许 ssh-A INPUT -j DROP #拒绝所有