我正在测试Server数据库镜像,下面是我的拓扑结构。
+-------------+--------------------------------------+-----------------+----------------------+----------------+---------------------+-------------------------+------------------------+-----------------------------+---------------------------+--------------------------+----------------------------+------------------------+-------------------------+------------------------------+------------------------+------------------------------+----------------------+---------------------------+--------------------------+---------------------------+
| database_id | mirroring_guid | mirroring_state | mirroring_state_desc | mirroring_role | mirroring_role_desc | mirroring_role_sequence | mirroring_safety_level | mirroring_safety_level_desc | mirroring_safety_sequence | mirroring_partner_name | mirroring_partner_instance | mirroring_witness_name | mirroring_witness_state | mirroring_witness_state_desc | mirroring_failover_lsn | mirroring_connection_timeout | mirroring_redo_queue | mirroring_redo_queue_type | mirroring_end_of_log_lsn | mirroring_replication_lsn |
+-------------+--------------------------------------+-----------------+----------------------+----------------+---------------------+-------------------------+------------------------+-----------------------------+---------------------------+--------------------------+----------------------------+------------------------+-------------------------+------------------------------+------------------------+------------------------------+----------------------+---------------------------+--------------------------+---------------------------+
| 1 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
| 2 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
| 3 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
| 4 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |
| 5 | A66E5470-F1ED-47D5-83F4-C86A1F8E7833 | 4 | SYNCHRONIZED | 1 | PRINCIPAL | 4 | 1 | OFF | 6 | TCP://NODE1.dev.com:5022 | NODE1 | | 0 | UNKNOWN | 40000000038100001 | 10 | NULL | UNLIMITED | 40000000038100001 | 40000000038100001 |
+-------------+--------------------------------------+-----------------+----------------------+----------------+---------------------+-------------------------+------------------------+-----------------------------+---------------------------+--------------------------+----------------------------+------------------------+-------------------------+------------------------------+------------------------+------------------------------+----------------------+---------------------------+--------------------------+---------------------------+请注意,安全级别已经关闭,我没有证人。我能在这个州做故障转移吗?我试过:
ALTER DATABASE AdventureWorks2016 SET PARTNER FAILOVER;但是得到了这个错误:
Msg 1477, Level 16, State 1, Line 26
The database mirroring safety level must be FULL to manually failover database
"AdventureWorks2016". Set safety level to FULL and retry.我也试过:
ALTER DATABASE AdventureWorks2016 SET PARTNER FORCE_SERVICE_ALLOW_DATA_LOSS;但是得到了这个错误:
Msg 1455, Level 16, State 2, Line 27
The database mirroring service cannot be forced for database "AdventureWorks2016" because
the database is not in the correct state to become the principal database.我检查了文档,似乎没有其他命令可以进行故障转移。这是否意味着在这种状态下故障转移是不可能的,而我必须改变安全级别?
发布于 2022-11-11 19:02:16
您正在使用(不推荐的特性)镜像,在“高性能”模式下(也就是异步模式)。根据医生们:
角色切换的唯一形式是强制服务(可能会丢失数据)。
因此,在失败时必须使用FORCE_SERVICE_ALLOW_DATA_LOSS是正确的,或者必须首先切换到“高安全模式”(也称为同步模式)。来自文献资料的ALTER DATABASE镜像命令的这一部分:
FORCE_SERVICE_ALLOW_DATA_LOSS仅在镜像服务器上可用,并且只能在以下所有条件下使用:
请注意,从上面的引号中可以看出,FORCE_SERVICE_ALLOW_DATA_LOSS必须在secondary镜像实例上运行,而不是在主实例上运行。
对于在异步模式下强制故障转移后返回到原始服务器的失败,文档继续:
强制服务暂停会话,暂时保留原始主体数据库中的所有数据。一旦原始主体处于服务状态并能够与新的主体服务器通信,数据库管理员就可以恢复服务。当会话恢复时,任何未发送的日志记录和相应的更新都会丢失。
Server A上有一个提交的事务在故障转移时还没有发送到Server B,那么“孤立”事务将导致Server A和Server B在数据分叉的情况下产生分叉。Server无法协调如何处理Server A上从未提交到Server B的已提交数据。这些数据应该合并到一起吗?如果有冲突呢?是否应该回滚Server A上提交的数据?SQL Server通过标识存在分叉来回答这些问题,并拒绝恢复同步。如果您在“高性能”(异步)模式下正常运行,那么您应该暂时切换到“高安全模式”(同步),然后失败,然后您可以切换回“高性能”(异步)模式。
将数据库保持在异步“高性能”模式并强制进行故障转移是一项任务,仅在准备丢失已提交的数据时才应使用,并且准备通过将完整备份还原到前主服务器来完全重新初始化镜像。
https://dba.stackexchange.com/questions/319533
复制相似问题