AlwaysON下迁移数据库----无需破坏HADR

Move database without breaking alwaysON

 

This post is going to show the database movement from one drive to another drive, without breaking the database from alwaysON configuration. An application has created the database to both primary and secondary replica servers to the default location of C drive.

There are methods like detach/attach, backup/restore & alter database. For alwaysON HADR servers, the best method is Alter database. Since it is in the mirror/sync mode. Detach/attach will not work and backup/ restore, we need to break databases from the HADR.

Note:

It’s a two node synchronous replica, if you have more replica, you should plan each well.

If you have any standalone database (Without adding DBs into HADR), you need to plan for the downtime. Since, the secondary replica servers need to take down.

In primary, for high transaction system, make sure you have good space for transaction files.

 

Steps:

Before going to start the database movement, write the script for each step and you can write a dynamic SQL for larger number databases. That’s what I did. It will minimize the time.

 

ALTER DATABASE <DB name> SET HADR suspend

  • Change the Readable secondary to ‘NO’ for all the secondary replicas, otherwise you will get an error.

Right click the primary replica alwaysON group –> properties –> Readable secondary  –> No

To use ALTER DATABASE, the database must be in a writable state in which a checkpoint can be executed.

 

  • Note down all the files and file location from the system tables.

 

select db_name(a.database_id),a.name,a.physical_name,size/128.0 AS CurrentSizeMB,*

from sys.master_files a join sys.databases b

on a.database_id =b.database_id

–where a.physical_name like ‘c%’

–and a.database_id >4

–and type_desc <>’rows’

order by a.name

 

  • On the mirror server run the “ALTER DATABASE <DB name> MODIFY FILE” command. You need to run this for each database.

 

use master

ALTER DATABASE <DB_name> MODIFY FILE (NAME =<logical name>

,FILENAME =’F:\SQL_DATA\DB_name.mdf’)

 

  • On the secondary replica server stop the SQL Server instance.

 

  • Move the database file (MDF & LDF) files to the changed location (Cut & Paste).
  • Start the SQL Server instance and check the file locations using the above query.

 

  • In primary replica server resume the database by using the following ALTER DATABASE statement:

 

ALTER DATABASE <DB name> SET HADR Resume.

 

  • Change the Readable secondary to ‘Yes’

Fail over and repeat the steps for the partner server.

Additionally, if you add any files in the primary and the folder name is incorrect in the secondary, the database will go into suspend mode.

Just check the error log, you can get more info on, why the database is suspended mode.

Error: 5123, Severity: 16, State: 1.

CREATE FILE encountered operating system error 3(The system cannot find the path specified.) while attempting to open or create the physical file ‘L:\SQL_log\DB_name.ndf’.

 

Created the folder and resume the database, the resume database command will create a file.

ALTER DATABASE <db name> SET HADR RESUME;


转自:http://www.sqlservercentral.com/blogs/sql-server-blog-forum/2016/08/03/alwayson-move-database-without-breaking-hadr/


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
热辅助探测与测距(Heat-Assisted Detection and Ranging,HADR)是一种结合了红外热成像和激光雷达技术的高级探测和测距方法。 在HADR系统中,红外热成像技术被用来实时捕捉目标的热辐射信息。红外热成像技术可以通过检测目标周围的热辐射来识别目标的位置、形状和大小等特征。这种技术特别适用于夜间或低能见度条件下的目标探测。 激光雷达则用于测量目标与传感器之间的距离。激光雷达通过发射激光束并测量激光束被目标反射后返回传感器的时间来计算目标的距离。激光雷达能够提供高精度和高分辨率的测距结果,在目标探测和感知中具有重要作用。 通过结合红外热成像和激光雷达,HADR系统可以实现对目标的多模态信息获取。红外热成像提供了目标的热特征,可以用于区分目标和背景。激光雷达提供了目标与传感器的准确距离信息,能够用于目标跟踪和位置估计。 HADR可以应用于许多领域,如智能交通、环境监测和安防监控等。在智能交通中,HADR可以用于车辆和行人探测、距离测量和行为分析。在环境监测中,HADR可以用于火灾探测、气体泄漏监测和地质灾害预警等。在安防监控中,HADR可以用于边境监控、入侵检测和人员追踪等。 总之,HADR是一种结合了红外热成像和激光雷达技术的探测和测距方法,具有广泛的应用前景。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值