《MysqL实例MysqL主从配置》要点:
本文介绍了MysqL实例MysqL主从配置,希望对您有用。如果有疑问,可以联系我们。
MysqL应用假设你有两台数据库服务器,计划如下部署:
MysqL应用Master server ip: 10.0.0.1 Slave server ip: 10.0.0.2 Slave username: slaver Slave pw: 123456 Your data directory is: usr/local/MysqL/var
MysqL应用主库配置文件my.cnf [MysqLd]节下面加上:
MysqL应用server-ID = 1 relay-log = /usr/local/MysqL/var/MysqL-relay-bin relay-log-index = /usr/local/MysqL/var/MysqL-relay-bin.index log-error = /usr/local/MysqL/var/MysqL.err master-info-file = /usr/local/MysqL/var/MysqL-master.info relay-log-info-file = /usr/local/MysqL/var/MysqL-relay-log.info datadir = /usr/local/MysqL/var log-bin = /usr/local/MysqL/var/MysqL-bin
MysqL应用从库配置文件my.cnf [MysqLd]节下面加上
MysqL应用server-ID = 2 relay-log = /usr/local/MysqL/var/MysqL-relay-bin relay-log-index = /usr/local/MysqL/var/MysqL-relay-bin.index log-error = /usr/local/MysqL/var/MysqL.err master-info-file = /usr/local/MysqL/var/MysqL-master.info relay-log-info-file = /usr/local/MysqL/var/MysqL-relay-log.info datadir = /usr/local/MysqL/var
MysqL应用在主库上创建用户:
MysqL应用MysqL> grant replication slave on . to 'slaver'@'10.0.0.2' IDentifIEd by '123456';
MysqL应用值得注意的是,grant replication slave是全局 *** 作,不能对单个库 *** 作.
MysqL应用使用MysqLdump工具,导出主库数据,配好之前先手动同步主从库的数据:
MysqL应用MysqLdump -u root --all-databases --single-transaction --master-data=1 > masterdump.sql
MysqL应用然后在从库中导入: MysqL < masterdump.sql
MysqL应用接下来要告库从库去复制哪个主库,以及连接主库的信息: MysqL> CHANGE MASTER TO MASTER\_HOST='10.0.0.1',MASTER\_USER='slaver',MASTER\_PASSWORD='123456';
MysqL应用紧接着开启从库同步: MysqL> start slave;
MysqL应用可以通过下命的命令查看同步状态: MysqL> show slave status\G
MysqL应用最后执行完成之后,刚添加的用户出现怪异现像,任何帐号都能登陆而且不用密码,最后百思不得其解,大量搜索之后发现“重启MysqL即可”,然后和然后的然后,就可以了...
总结以上是内存溢出为你收集整理的Mysql实例MySQL主从配置全部内容,希望文章能够帮你解决Mysql实例MySQL主从配置所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)