always-on中的数据库进行某些设置,如设置为单用户模式、修改隔离级别等时会报错如下:
MSG 1468, LEVEL 16, STATE 1
THE OPERATION CANNOT BE PERFORMED ON DATABASE “TESTDB” BECAUSE IT IS INVOLVED IN A DATABASE MIRRORING SESSION OR AN AVAILABILITY GROUP. SOME OPERATIONS ARE NOT ALLOWED ON A DATABASE THAT IS PARTICIPATING IN A DATABASE MIRRORING SESSION OR IN AN AVAILABILITY GROUP.
MSG 5069, LEVEL 16, STATE 1
ALTER DATABASE STATEMENT FAILED.
解决方法:将DB踢出高可用组后进行设置,设置完成后再加回来(不要随意在生产库执行)
1. Drop the database from the Availability Group.
ALTER AVAILABILITY GROUP [TestAG] REMOVE DATABASE [TestDB];
2. Put the database in Single User Mode.(非必须,设置隔离级别等一些操作时需要)
ALTER DATABASE [TestDB] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
3. Modify the Transaction Isolation Level
ALTER DATABASE [TestDB] SET READ_COMMITTED_SNAPSHOT ON;
ALTER DATABASE [TestDB] SET ALLOW_SNAPSHOT_ISOLATION ON;
4. Turn Multi User back on
ALTER DATABASE [TestDB] SET MULTI_USER;
ALTER DATABASE [TestDB] SET MULTI_USER;
5. Add the database back to the Availability Group
ALTER AVAILABILITY GROUP [TestAG] ADD DATABASE [TestDB];
6. Reconnect the Secondary database to the Availability Group so it starts syncing again
ALTER DATABASE [TestDB] SET HADR AVAILABILITY GROUP = [TestAG];
Once that is complete, you should be done! It may seem like a lot of work at first, but in reality most of those statements should execute pretty quickly.
Now, there’s one thing I want to point out to save you some trouble. Be sure to disable any transaction log backup jobs for this database while it is out of the Availability Group. If you don’t, you may be doing some database restores.
http://www.sqlnuggets.com/blog/change-the-isolation-level-of-an-availability-group-database/