如何在 SQL Azure Active Geo-Replication Secondary 上重新创建 user/login

How do I recreate a user/login on a SQL Azure Active Geo-Replication Secondary

我有一个 Premium P2 SQL Azure 数据库用于我的生产应用程序,出于安全原因,我创建了特定数据库 Schemas/Views/Roles 和特定数据库用户帐户,用于从 SSRS 查询中读取数据.

我们只调用服务器 PRIMARY 和我的数据库 MyApp

此设置脚本如下。

-- On Primary Master
CREATE LOGIN ssrsuser WITH password='******'

-- On Primary MyApp
CREATE USER ssrsuser FOR LOGIN ssrsuser 
CREATE ROLE [ssrsreader] AUTHORIZATION [db_owner]
GRANT SELECT ON SCHEMA :: [App] TO [ssrsreader]
GRANT SELECT ON SCHEMA :: [Reports] TO [ssrsreader]
EXEC sp_addrolemember 'ssrsreader', 'ssrsuser'

所以我们的用户给 Prod DB 带来了很多负载,我们决定是时候将报告功能移到辅助同步的从属数据库上了。

由于我们使用的是 SQL Azure 高级层,因此我们可以使用只读辅助副本启用 Active Geo-Replication。 In fact MS even say that it's suitable for read-only workloads such as reporting.

所以我设置了 SECONDARY 服务器,启用了播种,现在已经完成,我可以使用 SECONDARY 管理员用户和密码访问只读副本。

但是 SECONDARY 服务器没有 ssrsuser 的登录名,虽然我可以在 SECONDARY.master 中创建一个,但我不能 DROP RECREATE 用户因为 SECONDARY.MyApp 数据库处于只读模式。

有没有其他方法可以解决这个问题。我真的不想将 SECONDARY 服务器管理员用户和密码放入 SSRS 连接字符串中。

无需在用户数据库中为ssruser重新生成SID。由于复制,它已经存在。您需要做的就是将该 SID 与辅助服务器中主服务器中的登录相关联。本文提供了详细信息。 https://azure.microsoft.com/en-us/documentation/articles/sql-database-geo-replication-security-config/

希望对您有所帮助。