Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
mssql_alwayson_groups [2019/11/05 15:20] – [Configuration] andonovj | mssql_alwayson_groups [2019/11/09 19:58] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 4: | Line 4: | ||
In order to configure a AlwaysOn Group in SQL Server you firstly must configure: | In order to configure a AlwaysOn Group in SQL Server you firstly must configure: | ||
- | * Failover Windows Cluster | + | * Failover Windows Cluster |
* 2 SQL Stand-alone Binary installations | * 2 SQL Stand-alone Binary installations | ||
Line 51: | Line 51: | ||
- Specify Database -> Specify the databases you wish in that Group -> Next | - Specify Database -> Specify the databases you wish in that Group -> Next | ||
- Specify Replicas -> Choose which Server to be primary and which Secondary and other configuration settings -> Next | - Specify Replicas -> Choose which Server to be primary and which Secondary and other configuration settings -> Next | ||
- | - Select Data Synchronization -> Choose the approriate -> Next | + | - Select Data Synchronization -> Choose the approriate |
- Validation -> Validate that the checks passed -> Next | - Validation -> Validate that the checks passed -> Next | ||
- Summary -> Next | - Summary -> Next | ||
Line 58: | Line 58: | ||
The result of the configuration should be something like that: | The result of the configuration should be something like that: | ||
- | {{ :alwaysonconfigurationdone.jpg?400 |}} | + | {{ :alwaysonconfigurationdonedb2.jpg?400 |}} |
+ | You can use also the following script for manual configuration in the Appendix. | ||
+ | After all that you should have all databases selected throughout the configuration in restoring mode ON the second machine: | ||
+ | {{ : | ||
+ | |||
+ | I know that from security point of view, this isn't the best, but I try to make it working and later will improve security, I promise. | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | =====Fixing Issues===== | ||
+ | There were couple little problems, as always. | ||
+ | |||
+ | ====Wrong Service User==== | ||
+ | The default user didn't have right to access the DCOM, therefore I had to change the user which was used from Local user to SQLDOM\Administrator. | ||
+ | |||
+ | ====AlwaysOn Group Listener==== | ||
+ | The listener, I have decided to create it after I create the AlwaysOn group. So be sure to enable it after the creation if you didn't do it during. | ||
+ | |||
+ | ====Not Synchronizing==== | ||
+ | After the initial creation, the replicas were fine, but the database wasn't synching. So don't forgot to join the database to the group after that | ||
+ | |||
+ | |||
+ | =====Appendix===== | ||
+ | Manual AlwaysOn Script | ||
+ | <sxh bash> | ||
+ | --- YOU MUST EXECUTE THE FOLLOWING SCRIPT IN SQLCMD MODE. | ||
+ | :Connect 10.20.14.5 | ||
+ | |||
+ | IF (SELECT state FROM sys.endpoints WHERE name = N' | ||
+ | BEGIN | ||
+ | ALTER ENDPOINT [Hadr_endpoint] STATE = STARTED | ||
+ | END | ||
+ | |||
+ | GO | ||
+ | use [master] | ||
+ | GO | ||
+ | GRANT CONNECT ON ENDPOINT:: | ||
+ | GO | ||
+ | :Connect 10.20.14.5 | ||
+ | IF EXISTS(SELECT * FROM sys.server_event_sessions WHERE name=' | ||
+ | BEGIN | ||
+ | ALTER EVENT SESSION [AlwaysOn_health] ON SERVER WITH (STARTUP_STATE=ON); | ||
+ | END | ||
+ | IF NOT EXISTS(SELECT * FROM sys.dm_xe_sessions WHERE name=' | ||
+ | BEGIN | ||
+ | ALTER EVENT SESSION [AlwaysOn_health] ON SERVER STATE=START; | ||
+ | END | ||
+ | GO | ||
+ | :Connect WINNODEC | ||
+ | IF (SELECT state FROM sys.endpoints WHERE name = N' | ||
+ | BEGIN | ||
+ | ALTER ENDPOINT [Hadr_endpoint] STATE = STARTED | ||
+ | END | ||
+ | GO | ||
+ | use [master] | ||
+ | GO | ||
+ | GRANT CONNECT ON ENDPOINT:: | ||
+ | GO | ||
+ | :Connect WINNODEC | ||
+ | IF EXISTS(SELECT * FROM sys.server_event_sessions WHERE name=' | ||
+ | BEGIN | ||
+ | ALTER EVENT SESSION [AlwaysOn_health] ON SERVER WITH (STARTUP_STATE=ON); | ||
+ | END | ||
+ | IF NOT EXISTS(SELECT * FROM sys.dm_xe_sessions WHERE name=' | ||
+ | BEGIN | ||
+ | ALTER EVENT SESSION [AlwaysOn_health] ON SERVER STATE=START; | ||
+ | END | ||
+ | GO | ||
+ | :Connect 10.20.14.5 | ||
+ | USE [master] | ||
+ | GO | ||
+ | CREATE AVAILABILITY GROUP [SQLAWG] | ||
+ | WITH (AUTOMATED_BACKUP_PREFERENCE = SECONDARY, | ||
+ | DB_FAILOVER = OFF, | ||
+ | DTC_SUPPORT = NONE, | ||
+ | REQUIRED_SYNCHRONIZED_SECONDARIES_TO_COMMIT = 0) | ||
+ | FOR DATABASE [AlwaysOnDB1] | ||
+ | REPLICA ON N' | ||
+ | N' | ||
+ | GO | ||
+ | :Connect WINNODEC | ||
+ | ALTER AVAILABILITY GROUP [SQLAWG] JOIN; | ||
+ | GO | ||
+ | :Connect 10.20.14.5 | ||
+ | BACKUP DATABASE [AlwaysOnDB1] TO DISK = N' | ||
+ | GO | ||
+ | :Connect WINNODEC | ||
+ | RESTORE DATABASE [AlwaysOnDB1] FROM DISK = N' | ||
+ | GO | ||
+ | :Connect 10.20.14.5 | ||
+ | BACKUP LOG [AlwaysOnDB1] TO DISK = N' | ||
+ | GO | ||
+ | :Connect WINNODEC | ||
+ | RESTORE LOG [AlwaysOnDB1] FROM DISK = N' | ||
+ | GO | ||
+ | GO | ||
+ | </ | ||
=====Disable/ | =====Disable/ | ||
<sxh bash> | <sxh bash> |