Sqlserver offsite backup practices
Background of the project:
客户在线下IDC有一套业务系统运行在物理环境,winodws 2012 上运行着 Tomcat8+Sqlserver2014的企业内部流程系统,由于种种原因目前需要将线下的环境移植一份到某私有云内部环境中作为备份(如果线下环境遇到何种人为不可控的因素导致短时间内无法恢复的情况,私有云环境下的系统可以快速拉起业务,以尽可能短的时间恢复业务运行)。
Project Difficulties:
1)目的端私有云环境下,限制诸多,安全性考虑默认情况下所有的上行下行端口均不开放,也不能采用异地镜像方式导入,直接限制了软件环境的构建方式;
2)Sqlserver2014 的实时同步过程对于网络和磁盘的IO也有一定要求,实时同步的可靠性未经过实际环境的测试,不能确保同步链路的百分百稳定可靠;
Program to determine:
综上所述,各方面综合考虑后确认如下方案:
A.基础运行环境所需要的软件安装包,在其他环境中适配确认好,然后使用私有云内部部署的云盘工具上传,结合指定的可信任mirror源( https://opsx.alibaba.com/mirror/ )等进行基础环境的构建,并通过网内测试;
B.基础环境构建完毕后,将Tomcat运行的源码包压缩拷贝至目标服务器,解压,注意Tomcat环境的权限所属问题;
C.Sqlserver数据库发布订阅配置(PS:最好源环境和目标环境的用户名密码设置相同,避免后面配置时搞错;
D.文件级数据的定时同步计划,通过rsync+openssh加密传输的方式配合计划任务将文件数据定时同步至目标服务器中;
E.出于数据库同步链路可靠性考虑,最终决定将数据库源端启动维护计划,每天定时生成数据库的全量备份.bak文件并存储到rsync同步指定的目录下,将bak文件也复制一份到目标服务器,确保数据安全;
POC testing phase:
方案确认后即可按照既定的方案开展POC测试环节
基础环境的安装过程省略(需要注意的是安装过程中需要使用到哪些外部URL,需要哪些端口协同工作,这些需要提前确认好,后续需要通过防火墙策略申请开放。)
数据库订阅发布配置过程如下:
·目标环境安装好对应版本的数据库(此处sqlserver2014 EE ed2k://|file|cn_sql_server_2014_enterprise_edition_x64_dvd_3932882.iso|2898847744|A33CE10CD989083D1AD882DF0D56CFBE|/ )
·在配置发布订阅之前首先需要确保源端与目标端服务器之间可以通过对应的servername找到彼此,最直接的方式就是在源端和目标端服务器的hosts文件中添加相应的x.x.x.x sqlservername 记录,并测试可以通过sqlservername成功连接数据库,通过ip地址直接连接会报错
·数据确保可以通过sqlservername连接后即可开始配置,源端发布
- copy
- New Publication
- Follow the wizard to configure
- Snapshot storage location (the default location in the directory corresponding to the database instance, may be modified according to the actual situation may not be modified)
- Select the corresponding database
- Select the type of publication
- Published Type Description
Snapshot:
Publisher interval snapshot of published data sent to subscribers at a predetermined time.
Transactional publication:
After Subscribers receive the initial snapshot of the data published, the publisher will transfer transaction flow to the subscriber.
Peer Posted:
Peer released to support multi-master replication. Publisher transaction streamed to all peer topology party. All peer nodes can read and write to change, and all changes will be propagated to all nodes in the topology.
Merge publication:
receive the initial snapshot of the data published in the Subscriber after the Publisher and Subscriber can be updated independently published data. Change regularly merge. Microsoft SQL Server Compact Edition can only subscribe to merge publication.
-
Select the appropriate type of release and select the object needs to be published
- Screening remove unwanted data (not may not be added)
- Build and run the snapshot agent
- Security Settings (Configure proxy user name and password)
---- suggested configured as follows (the current test configuration no problem) ---- - To create a publication
- Specifies the name (according to the project names to get more reliable, of course, what to name does not affect the operation)
- Waiting for release creation
- View release has been created
- End goal to create a subscription
- Select Publisher (published item selection sql connection by looking Publisher)
- Select the location of the distribution agent (the proposed election issue push the server approach, the way highest success rate of the test run)
- Select the subscription database
- Security settings (similar to the same settings in the publication, a distinction publishing side and subscribing side)
---- ---- suggestion configured as follows - According to the actual operation mode confirmation (default continuous operation)
- Setting initialization time (default immediately)
- Create a subscription
- Subscribe to wait for the entry into force
- View subscription synchronization link case
So far sqlserver release subscription process has been completed.
• It is recommended configure scheduled maintenance tasks, scheduled .bak database backup, timing synchronization to the end goal. windows encryption synchronization process with reference to the next document.