Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Secondary "db3" Always On
USE [master]
GO
drop availability group AG1;
drop endpoint [Hadr_endpoint]
drop CERTIFICATE aoag_certificate
drop master key;
drop user aoag_user_db3
drop login aoag_login_db3
CREATE LOGIN aoag_login_db3 WITH PASSWORD = 'XXXXXX1!, DEFAULT_DATABASE=[master], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF'
CREATE USER aoag_user_db3 FOR LOGIN aoag_login_db3
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'XXXXXX1!'
CREATE CERTIFICATE aoag_certificate
AUTHORIZATION aoag_user_db3
FROM FILE = '/var/opt/mssql/shared/aoag_certificate.cert'
WITH PRIVATE KEY (
FILE = '/var/opt/mssql/shared/aoag_certificate.key',
DECRYPTION BY PASSWORD = 'XXXXXX1!'
)
CREATE ENDPOINT [Hadr_endpoint]
STATE=STARTED
AS TCP (
LISTENER_PORT = 5022,
LISTENER_IP = ALL
)
FOR DATA_MIRRORING (
ROLE = ALL,
AUTHENTICATION = CERTIFICATE aoag_certificate,
ENCRYPTION = REQUIRED ALGORITHM AES
)
GRANT CONNECT ON ENDPOINT::Hadr_endpoint TO [aoag_login_db3];
ALTER AVAILABILITY GROUP [AG1] JOIN WITH (CLUSTER_TYPE = NONE)
ALTER AVAILABILITY GROUP [AG1] GRANT CREATE ANY DATABASE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment