标签:sla lin event ima select 执行 2-2 exec 查看
原文:002.MySQL高可用主从复制部署1 [root@Master ~]# yum list installed | grep mysql #查看是否存在其他MySQL组件 2 [root@Master ~]# yum -y remove mysql-libs.x86_64 #为避免冲突引发报错,卸载已存在的组件 3 [root@Master ~]# wget http://repo.mysql.com/mysql-community-release-el6-7.noarch.rpm 4 [root@Master ~]# rpm -ivh mysql-community-release-el6-7.noarch.rpm 5 [root@Master ~]# yum install mysql-community-server -y 6 [root@Master ~]# chkconfig --list | grep mysqld #查看MySQL是否加入启动项 7 [root@Master ~]# chkconfig mysqld on
1 [root@Master ~]# service mysqld start 2 [root@Master ~]# mysql_secure_installation 3 [root@Master ~]# service iptables stop 4 [root@Master ~]# chkconfig iptables off 5 [root@Master ~]# vi /etc/sysconfig/selinux 6 SELINUX=disabled
1 [root@Master ~]# vi /etc/my.cnf 2 [mysqld] 3 …… 4 server-id=1 #设置主服务器master的id 5 log-bin=mysql-bin #配置二进制变更日志命名格式
1 # 不同步哪些数据库 2 binlog-ignore-db = mysql 3 binlog-ignore-db = test 4 binlog-ignore-db = information_schema 5 # 只同步哪些数据库,除此之外,其他不同步 6 binlog-do-db = mysqltest
1 [root@Master ~]# mysql -uroot -p 2 Enter password: 3 mysql> grant replication slave on *.* to ‘repl_user‘@‘172.24.8.11‘ identified by ‘x12345678‘; 4 mysql> flush privileges; 5 [root@Master ~]# service mysqld restart 6 [root@Master ~]# mysql -uroot -p 7 Enter password: 8 mysql> show master status;
1 [root@Master ~]# vi /etc/my.cnf 2 [mysqld] 3 server-id=2 #设置从服务器slave的id 4 log-bin=mysql-bin #如果此slave是其他slave的master,则此项也必须开启 5 relay_log=mysql-relay-bin #配置二进制relay日志命名格式 6 log_slave_updates=1 #表示slave将复制事件写进自己的二进制日志 7 read_only=1
1 [root@Slave01 ~]# service mysqld restart 2 [root@Slave01 ~]# mysql -uroot -p 3 Enter password: 4 mysql> change master to master_host=‘172.24.8.10‘, 5 -> master_user=‘repl_user‘, 6 -> master_password=‘x12345678‘, 7 -> master_log_file=‘mysql-bin.000001‘, 8 -> master_log_pos=120; 9 mysql> show slave status\G #查看slave状态 10 …… 11 Slave_IO_State: 12 Master_Host: 172.24.8.10 13 Master_User: repl_user 14 Master_Port: 3306 15 Connect_Retry: 60 16 Master_Log_File: mysql-bin.000001 17 Read_Master_Log_Pos: 120 18 Relay_Log_File: =mysql-relay-bin.000001 19 Relay_Log_Pos: 4 20 Relay_Master_Log_File: mysql-bin.000001 21 Slave_IO_Running: No 22 Slave_SQL_Running: No 23 …… 24 Exec_Master_Log_Pos: 120 25 Relay_Log_Space: 120 26 …… 27 Seconds_Behind_Master: NULL 28 Master_SSL_Verify_Server_Cert: No 29 Master_Info_File: /var/lib/mysql/master.info 30 SQL_Delay: 0 31 SQL_Remaining_Delay: NULL 32 Slave_SQL_Running_State: 33 Master_Retry_Count: 86400 34 ……
1 [root@Slave01 ~]# service mysqld restart 2 [root@Slave01 ~]# mysql -uroot -p 3 Enter password: 4 mysql> start slave; 5 mysql> show slave status\G #查看slave状态 6 …… 7 Slave_IO_State: Waiting for master to send event 8 Master_Host: 172.24.8.10 9 Master_User: repl_user 10 Master_Port: 3306 11 Connect_Retry: 60 12 Master_Log_File: mysql-bin.000001 13 Read_Master_Log_Pos: 120 14 Relay_Log_File: =mysql-relay-bin.000001 15 Relay_Log_Pos: 283 16 Relay_Master_Log_File: mysql-bin.000002 17 Slave_IO_Running: YES 18 Slave_SQL_Running: YES 19 …… 20 Exec_Master_Log_Pos: 120 21 Relay_Log_Space: 120 22 …… 23 Master_Info_File: /var/lib/mysql/master.info
1 [root@Master ~]# mysql -uroot -p 2 Enter password: 3 mysql> create database mysqltest; 4 mysql> use mysqltest; 5 mysql> create table user(id int(5),name char(10)); 6 mysql> insert into user values (00001,‘zhangsan‘); 7 在Slave从服务器上进行验证: 8 [root@Master ~]# mysql -uroot -p 9 Enter password: 10 mysql> show databases; 11 mysql> select * from mysqltest.user;
1 mysql> reset slave;
标签:sla lin event ima select 执行 2-2 exec 查看
原文地址:https://www.cnblogs.com/lonelyxmas/p/10329188.html