Friday, 26 July 2013

SQL Server alwayson step by step

We need at least 2 node, join the node1,node2 to domain, install stand-alone SQL Server 2012 on Node1 and Node2,remember dun choose the failover cluster installation
 Check Node1 SQL Server installed successfully.
 Node1 and Node2 still not clustered, the alwayson feature can't be enabled.
Check Node2 stand-alone SQL Server installed and alwayson feature can't be enabled.
 Create Node1 and Node2 cluster with failover cluster manager
 Add node1 and node2 to the cluster
 set Cluster IP address.


 Node1 and Node2 successful Clustered.
 
 Open SQL Server configuration manager, enable alwayson feature on node1 and restart SQL Server service.
 Open SQL Server configuration manager, enable alwayson feature on node2 and restart SQL Server service.
 Create a testing database AlwaysonTestDB on Node1
 Must be full recovery mode
 before configure the alwayson , do a full backup of AlwaysonTestDB

 Right click [Availability Groups] from SSMS and [New Availability Group Wizard]
 Set group name as group_alwayson
 Select the testing database AlwaysonTestDB
 Choose yes from Readable Secondary

 Configure SQL Server alwayson group IP and port, frontend application can use this IP to connect to database.
 Add node2 as a secondary replication SQL Server service.
 set secondary readable to yes.
 Specify a shared folder accessible by node1 and node2


 Alwayson group created successfully, check from SSMS panel, Node1 is the primary, Node2 is the secondary.
 Check from Node2 SSMS, the AlwaysonTestDB Synchronized.
 do a testing on node1, create a table t and insert sample data.
 Connect to the alwayson group IP from another SQL Server SSMS(it's not node1 and node2)
 Connect successful and also can search the testing data.
 shutdown node1 to test failover.
 The alwayson  IP still can connect, data can search also. now we insert a new record to table t.
insert into t select 4,'d', because node1 has been shutdown, so it should be inserted to node2
 once node1 start up again, the new record has sync from node2 to  Node1 already, good.
 But now the node1 become secondary, Node2 is primary node.

 
 
 
 Looks like it's a really good feature for SQL Server read-write split.
 

No comments:

Post a Comment