activate Service Broker on a database in an Availability Group
-
09-03-2021 - |
Domanda
I found some older posts dealing with this(5 yrs old or more), but I am confused on the process or if this information is out of date, hence my new question. I am on sql 2016 SP2-CU11 enterprise.
I need to enable service broker on a database that is in an availability group. Its 1.8TB in size, so I really don't want to take it totally out of the AG and reseed it all over again with a fresh backup if I can avoid it. Some older posts say you have to completely remove and add the db back in the AG, others reference just running some code to create endpoints, and routes which I have never run across before.
Is the process below the only way to enable service broker on a DB in an AG where it is not enabled?
remove the secondary copy of the DB, then the primary copy from the AG.
Run below code to activate service broker:
ALTER DATABASE XXXXXX SET ENABLE_BROKER; GO
Take a full backup, restore it to the secondary with no recovery.
join the DB to the AG on the secondary.
Soluzione
First, create and configure the service broker endpoint
select * from sys.tcp_endpoints
Create a new end point for the service broker:
CREATE ENDPOINT [Avaruu5alus]
STATE = STARTED
AS TCP (LISTENER_PORT = 4022, LISTENER_IP = ALL )
FOR SERVICE_BROKER (AUTHENTICATION = WINDOWS)
GRANT CONNECT ON ENDPOINT::[Avaruu5alus] TO [PUBLIC]
SQL Server Broker is not Multisubnet aware. You need to set RegisterAllProvidersIP
to 0
Thereafter take the availability group offline and bring online again.
USE [master]
GO
ALTER DATABASE [Avaruu5alusDB] SET ENABLE_BROKER WITH NO_WAIT
GO