码迷,mamicode.com
首页 > 数据库 > 详细

Mysql主主配置

时间:2019-09-28 11:02:37      阅读:112      评论:0      收藏:0      [点我收藏+]

标签:col   pid   ges   user   pre   run   cte   recommend   span   

 1.vim /etc/my.cnf

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

server-id=1
log_bin=mysqlbin
relay_log=relaylog

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

 2.service mysqld restart

 3.进入 Mysql

mysql> grant all on *.* to tom@‘192.168.146.%‘ identified by ‘123‘;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

技术图片

 4.进入从服务器

 5.vim /etc/my.cnf

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

server-id=2
log_bin=mysqllog
relay_log=mysqlrelay

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

 6.进入从Mysql

mysql> stop slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> change master to master_host=‘192.168.146.6‘, master_user=‘tom‘,master_password=‘123‘,master_log_file=‘mysqlbin.000003‘,master_log_pos=315;
Query OK, 0 rows affected (0.39 sec)

mysql> start slave;
Query OK, 0 rows affected (0.00 sec)

mysql> show slave status \G;

  技术图片

 

 

 配置主主,从第6步在主服务器上重复操作

Mysql主主配置

标签:col   pid   ges   user   pre   run   cte   recommend   span   

原文地址:https://www.cnblogs.com/lslyw/p/11601801.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!