I couldn't find an answer to my question.
我无法找到我的问题的答案。
I have 2 mysql servers.
我有两个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?
我可以复制一个数据库吗?
2 个解决方案
#1
38
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复制一个数据库,可以在/etc/my.cnf中设置replicate-do-db,或者将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/replicationoptions-slave.html #option_mysqld_replicate-do-db。
#2
0
Adding these lines to the /etc/my.conf file of the slave machine solved my problem. Thanks.
将这些行添加到/etc/ myc /。机器的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并启动从机。
#1
38
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复制一个数据库,可以在/etc/my.cnf中设置replicate-do-db,或者将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/replicationoptions-slave.html #option_mysqld_replicate-do-db。
#2
0
Adding these lines to the /etc/my.conf file of the slave machine solved my problem. Thanks.
将这些行添加到/etc/ myc /。机器的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并启动从机。