/etc/init.d/iptables stop
172.25.85.2 server2 master
172.25.85.3 server3 slave1.server2/3:A->B yum install mysql-server -y /etc/init.d/mysqld start mysql_secure_installation server2: vim /etc/my.cnf [mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysql# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0server-id=1log-bin=mysql-bin
[mysqld_safe]
log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid /etc/init.d/mysqld restart mysql -p show master status; cd /var/lib/mysql mysqlbinlog mysql-bin.000001 mysql -p ##密码是redhat grant replication slave on *.* to jing@'172.25.85.3' identified by 'redhat'; server3: /etc/init.d/mysqld start mysql -h 172.25.85.2vim /etc/my.cnf
[mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysql# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0server-id=2
[mysqld_safe]
log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid /etc/init.d/mysqld restart mysql -p change master to master_host='172.25.85.2',master_user='jing',master_password='redhat',master_log_file='mysql-bin.000001',master_log_pos=257 ; ##此时master对应status是257 start slave; show slave status\G; 检测: server2: mysql -p create database westos; create table usertb( username varchar(25) not null, passwd varchar(25) not null); insert into usertb value('zhang', 'zhang'); insert into usertb value('weijing','weijing'); server3; server2: delete from usertb where username='weijing'; server3: server2: update usertb set passwd=password('444'); server3: 2. server3: (A->B->C) vim /etc/my.cnf datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysql# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0server-id=2log-bin=mysql-binlog-slave-updates ##配置从服务器的更新是否写入二进制日志
[mysqld_safe]
log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid /etc/init.d/mysqld restart mysql -p show master status; grant replication slave on *.* to jing@'172.25.85.4' identified by 'redhat'; server4: yum install mysql-server -y mysql -h 172.25.85.3 -ujing -predhat vim /etc/my.cnf[mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysql# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0server-id=3
[mysqld_safe]
log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid /etc/init.d/mysqld restart mysql -p change master to master_host='172.25.85.3',master_user='jing',master_password='redhat',master_log_file='mysql-bin.000001',master_log_pos=258 ; start slave; show slave status\G;show slave status\G;
server2: scp mysql-bin.000001 root@172.25.85.4:/var/lib/mysql mysqlbinlog mysql-bin.00000 server4: mysql -p create database westos; cd /var/lib/mysql mysqlbinlog mysql-bin.000001 --start-position=344 --stop-position=924 | mysql -predhat mysql -p show tables; select * from usertb;