Database replication. 2 servers, Master database and the 2nd is read-only

和自甴很熟 提交于 2019-11-29 03:22:21

问题


Say you have 2 database servers, one database is the 'master' database where all write operations are performed, it is treated as the 'real/original' database. The other server's database is to be a mirror copy of the master database (slave?), which will be used for read only operations for a certain part of the application.

How do you go about setting up a slave database that mirrors the data on the master database? From what I understand, the slave/readonly database is to use the master db's transaction log file to mirror the data correct?
What options do I have in terms of how often the slave db mirrors the data? (real time/every x minutes?).


回答1:


What you want is called Transactional Replication in SQL Server 2005. It will replicate changes in near real time as the publisher (i.e. "master") database is updated.

Here is a pretty good walk through of how to set it up.




回答2:


SQL Server 2008 has three different modes of replication.

  • Transactional for one way read only replication
  • Merge for two way replication
  • Snapshot



回答3:


From what I understand, the slave/readonly database is to use the master db's transaction log file to mirror the data correct? What options do I have in terms of how often the slave db mirrors the data? (real time/every x minutes?).

This sounds like you're talking about log shipping instead of replication. For what you're planning on doing though I'd agree with Jeremy McCollum and say do transactional replication. If you're going to do log shipping when the database is restored every x minutes the database won't be available.

Here's a good walkthrough of the difference between the two. Sad to say you have to sign up for an account to read it though. =/ http://www.sqlservercentral.com/articles/Replication/logshippingvsreplication/1399/




回答4:


The answer to this will vary depending on the database server you are using to do this.

Edit: Sorry, maybe i need to learn to look at the tags and not just the question - i can see you tagged this as sqlserver.




回答5:


Transactional replication is real time.

If you do not have any updates to be done on your database , what you need is just retrieving of data say once a day : then use snapshot replication instead of transactional replication. In snapshot replication, changes will replicate when and as defined by the user say once in 24 hrs.



来源:https://stackoverflow.com/questions/12946/database-replication-2-servers-master-database-and-the-2nd-is-read-only

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!