mysql 复制 - 一个数据库上的从服务器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8605318/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
mysql replication - slave server on one database
提问by sabansaulic
I couldn't find an answer to my question.
我找不到我的问题的答案。
I have 2 mysql servers.
我有 2 个 mysql 服务器。
- Master server
- Slave server
- 主服务器
- 从服务器
Now i want to add another Slave server but i have other website running on that server.
现在我想添加另一个从服务器,但我在该服务器上运行了其他网站。
Can i replicate just one database?
我可以只复制一个数据库吗?
回答by Frank Fang
Yes you can
是的你可以
If you want to replicate just one database from master, you can set replicate-do-db
in your /etc/my.cnf
or set replicate-do-db
as mysql argument, for example:
如果您只想从 master 复制一个数据库,您可以replicate-do-db
在您的/etc/my.cnf
或设置replicate-do-db
为 mysql 参数中进行设置,例如:
replicate-do-db=db01
If you have multi databases to be replicated, /etc/my.cnf
should be like this:
如果你有多个数据库要复制,/etc/my.cnf
应该是这样的:
replicate-do-db=db01
replicate-do-db=db02
If you just want slave to ignore some database, you can set replicate-ignore-db
:
如果你只是想让 slave 忽略一些数据库,你可以设置replicate-ignore-db
:
replicate-ignore-db=db01
More details on MySQL document: http://dev.mysql.com/doc/refman/5.1/en/replication-options-slave.html#option_mysqld_replicate-do-db
有关 MySQL 文档的更多详细信息:http: //dev.mysql.com/doc/refman/5.1/en/replication-options-slave.html#option_mysqld_replicate-do-db
回答by Omair Anwer
Adding these lines to the /etc/my.conf file of the slave machine solved my problem. Thanks.
将这些行添加到从机的 /etc/my.conf 文件解决了我的问题。谢谢。
replicate-do-db=Refill
However, please note that after doing this i had to restart both the databases and update the new file name and position from the master server by typing below command:
但是,请注意,在执行此操作后,我必须重新启动两个数据库并通过键入以下命令从主服务器更新新文件名和位置:
mysql> show master status;
Add this information to your MySQL on slave machine and start slave.
将此信息添加到从机上的 MySQL 并启动从机。