巴黎的灯光下 发表于 2019-2-2 09:57:08

MySQL双主+Keepalived高可用2

二 实际部署2.1 安装MySQL1 # yum list installed | grep mysql        #查看是否存在其他MySQL组件2 # yum -y remove mysql-libs.x86_64        #为避免冲突引发报错,卸载已存在的组件

https://img2018.cnblogs.com/blog/680719/201811/680719-20181105120731676-457176832.png1 #yum localinstall mysql-commu* -y2 # chkconfig --list | grep mysqld                #查看MySQL是否加入启动项3 # chkconfig mysqld on

2.2 初始化MySQLhttps://common.cnblogs.com/images/copycode.gif
1 # service mysqld start2 # mysql_secure_installation3 # service iptables stop4 # chkconfig iptables off5 # vi /etc/sysconfig/selinux6 SELINUX=disabledhttps://common.cnblogs.com/images/copycode.gif


注意:以上操作在Master02主机上也需要执行。安装参考:http://www.cnblogs.com/007sx/p/7083143.html2.3 master01 my.cf配置https://common.cnblogs.com/images/copycode.gif
1 # vi /etc/my.cnf2 3 ……4 server-id=1                                #设置主服务器master的id5 log-bin=mysql-bin                        #配置二进制变更日志命名格式6 replicate-wild-ignore-table=mysql.%7 replicate-wild-ignore-table=test.%8 replicate-wild-ignore-table=information_schema.%https://common.cnblogs.com/images/copycode.gif


注意:master开启二进制日志后默认记录所有库所有表的操作,可以通过配置来指定只记录指定的数据库甚至指定的表的操作,具体在mysql配置文件的可添加修改如下选项:方法一:https://common.cnblogs.com/images/copycode.gif
1 # 不同步哪些数据库2 binlog-ignore-db = mysql3 binlog-ignore-db = test4 binlog-ignore-db = information_schema5 # 只同步哪些数据库,除此之外,其他不同步6 binlog-do-db = mysqltesthttps://common.cnblogs.com/images/copycode.gif


方法二:建议采用以下方式配置过滤:1 replicate-wild-ignore-table=mysql.%        #从库配置不同步表2 replicate-wild-do-table=test.%                #从库配置需要同步的表

提示:不要在主库使用binlog-ignore-db和binlog-do-db,也不要在从库使用replicate-wild-ignore和replicate-wild-do-table。2.4 创建账号https://common.cnblogs.com/images/copycode.gif
1 # mysql -uroot -p2 Enter password:3 mysql> grant replication slave on *.* to 'repl_user'@'172.24.8.11' identified by 'x12345678';4 mysql> grant all privileges on *.* to 'root'@'172.24.8.%'identified by 'x120952576' with grant option;5 mysql> flush privileges;6 # service mysqld restart7 # mysql -uroot -p8 Enter password:9 mysql> show master status;https://common.cnblogs.com/images/copycode.gif


https://img2018.cnblogs.com/blog/680719/201811/680719-20181105120732061-250818197.pngmaster01:file:mysql-bin.000001position:1202.5 smaster02 my.cf配置配置https://common.cnblogs.com/images/copycode.gif
1 # vi /etc/my.cnf2 3 server-id=2                                #设置主服务器master的id4 log-bin=mysql-bin                        #配置二进制变更日志命名格式5 replicate-wild-ignore-table=mysql.%6 replicate-wild-ignore-table=test.%7 replicate-wild-ignore-table=information_schema.%8 read_only=1https://common.cnblogs.com/images/copycode.gif


2.6 创建账号https://common.cnblogs.com/images/copycode.gif
1 # mysql -uroot -p2 Enter password:3 mysql> grant replication slave on *.* to 'repl_user'@'172.24.8.10' identified by 'x12345678';4 mysql> grant all privileges on *.* to 'root'@'172.24.8.%'identified by 'x120952576' with grant option;5 mysql> flush privileges;6 # service mysqld restart7 # mysql -uroot -p8 Enter password:9 mysql> show master status;https://common.cnblogs.com/images/copycode.gif

https://img2018.cnblogs.com/blog/680719/201811/680719-20181105120732437-1926552647.pngmaster02:file:mysql-bin.000001position:120
页: [1]
查看完整版本: MySQL双主+Keepalived高可用2