有熟悉 myqsl 的朋友吗,麻烦给看下这个配置有问题吗?

2016-06-05 18:28:36 +08:00
 qcloud
两台数据库服务器,在搞主主同步,主服务器已经配置完毕,启动正常,但是从服务器就是启动失败,大家看看我这个从服务器配置有问题吗?
https://ooo.0o0.ooo/2016/06/05/575400af39eb5.png
报错日志
https://ooo.0o0.ooo/2016/06/05/575402713de42.png
933 次点击
所在节点    问与答
2 条回复
notgod
2016-06-05 18:49:34 +08:00
mysqld: unknown variable ‘ master-host=

Are you trying to setup on replication on mysql5.5+ ? ok. then that ’ s the issue.

The following options are removed in MySQL 5.5. If you attempt to start mysqld with any of these options in MySQL 5.5, the server aborts with an unknown variable error.

– master-host
– master-user
– master-password
– master-port

Solution, comment the master- related variables.
Do following,
On Master:
mysql>GRANT REPLICATION SLAVE ON *.* TO ‘ slave_user ’@’%’ IDENTIFIED BY ‘‘; (Replace with a real password!)
mysql>FLUSH PRIVILEGES;
mysql>FLUSH TABLES WITH READ LOCK;
mysql>SHOW MASTER STATUS;
# get the DB dump.
mysql>UNLOCK TABLES;

On Slave:
# import the DB dump
mysql>stop slave;
mysql>CHANGE MASTER TO MASTER_HOST=’ prod_master ’, MASTER_USER=’ slave_user ’, MASTER_PASSWORD=’‘, MASTER_LOG_FILE=’ mysql-bin.0xx ‘, MASTER_LOG_POS=33421;
mysql>start slave;

Ref: http://dev.mysql.com/doc/refman/5.5/en/replication-options-slave.html
notgod
2016-06-05 18:50:49 +08:00
由於 mysql 5.5 開始不支援 my.cnf 裡 master-host 等的設定
所以不能把 master 的參數設定到裡頭
只能透過 sql 指令的方式建立 replication 連結
不然會看到下面錯誤訊息


Installing MariaDB/MySQL system tables in '/home/mysql/data' ...
130208 7:08:31 [ERROR] /usr/local/mysql/bin/mysqld: unknown variable 'master-host=192.168.100.1'
130208 7:08:31 [ERROR] Aborting


以下是針對 slave 的操作步驟:

install mysql
start mysql
restore db
SQL : slave stop
SQL : change master to master_host='192.168.100.1', master_port=3306, master_user='repl', master_password='xxxxxxx';
SQL : slave start

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/283670

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX