Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 106

SQL Server

DBA Co-op Project


(Group 2)
(Requirement 2.3:
SQL Server 2016 Virtual Machines)

Jay Liu
E: LJJYX@yahoo.com C: 647-833-5887

1
2.3 Setup SQL Server 2016 and AlwaysOn

2.3.1 Setup SQL Server 2016


1. Installing SQL Server 2016 instance
2. Installing SSMS 2016

2.3.2 Post Configuration


1. Instance authentication & security
2. Network configurations
3. Instance default & customization setup

2
2.3 Setup SQL Server 2016 and AlwaysOn

2.3.3 Setup AlwaysOn Environment


1. List of environment and pre-checking
2. Configure Quorum, Backup Folder and Recovery Mode
3. Add Failover Feature and create cluster into Server

2.3.4 AlwaysOn
1. Enable AlwaysOn
2. Prepare AlwaysOn Database Orders
3. Setup Replicas
4. Configure Failover Cluster (Manual Failover)
5. Testing Failover (Auto Failover)

3
2.3.1.1 - Installing SQL Server 2016 instance

For this lab environment, all setup files are under the path:
[C:\Software\SQL Server 2016]

- SQLServer2016-DeveloperEdition
- SSMS2016-Setup
- SQLServer2016SP2-KB4052908-x64-ENU.exe

4
2.3.1.1 - Installing SQL Server 2016 instance

Install SQL2016PRD instance on PRD-PP-1216 VM server


Install SQL2016DR instance on RPT-DR-1216 VM server

The following instructions are for instance SQL2016PRD as example:

- Run Setup.exe from folder below in PRD-PP-1216 VM server local


drive path:
“C:\Software\SQL Server 2016\SQLServer2016-DeveloperEdition”

5
2.3.1.1 - Installing SQL Server 2016 instance

- Launch the setup.exe

6
2.3.1.1 - Installing SQL Server 2016 instance
- On the left-hand side, Click “Installation”
- On the right-hand side, click “New SQL Server stand-alone
installation or add features to an existing installation”
2.3.1.1 - Installing SQL Server 2016 instance

- In Product Key, leave it as [Developer] edition, click next


2.3.1.1 - Installing SQL Server 2016 instance
- Accept the term, next, and then Next

9
2.3.1.1 - Installing SQL Server 2016 instance
- Do not check Product Updates, and Next
2.3.1.1 - Installing SQL Server 2016 instance
- Check Install Rules, warning is ok > Next

11
2.3.1.1 - Installing SQL Server 2016 instance
- Make selections as shown, including the [Database Engine Services] (sub
item: [Replication] and [Full-Text]), and [Client Tools Connectivity], then Next

12
2.3.1.1 - Installing SQL Server 2016 instance
- Instance Configuration, use [SQL2016PRD] as named Instance,
then Next
2.3.1.1 - Installing SQL Server 2016 instance
- In Server Configuration, set [SQL2K8\SQL Service] as start-up
account for Engine and Agent with password “Vic2006”.
- Account Name > Browse… > Pop-up Window
2.3.1.1 - Installing SQL Server 2016 instance
- Switch to [Collation] tab to confirm collation, Next
2.3.1.1 - Installing SQL Server 2016 instance

- in Database Engine Configuration, choose Mixed Mode, then


type password “Vic2006” for [sa]

- Add [SQL2K8\SQLDBAGRP], [SQL2K8\SQLSRVGRP]


and [SQL2K8\Administrator] for the SQL administrators

- Data Directories, TempDB and FILESTREAM setups are


optional for our practices. Click Next

16
2.4a.1.1 - Installing SQL Server 2016 instance
- In [Data Directories] tab, change backup, data, log default folders for
user DB, Next
2.4a.1.1 - Installing SQL Server 2016 instance
- Change [TempDB] default folders, Next
2.4a.1.1 - Installing SQL Server 2016 instance
- in Ready to Install, click Install to start, Next
2.4a.1.1 - Installing SQL Server 2016 instance
- Installation Progress
2.4a.1.1 - Installing SQL Server 2016 instance
- Confirm all succeeded, then restart
2.4a.1.1 - Installing SQL Server 2016 instance
- Confirm all succeeded, then restart
2.4a.1.1 - Installing SQL Server 2016 instance
- Restart the server
2.4a.1.2 - Installing SSMS 2016 on PROD-PP-1216

Launch SSMS 2016 from path: [C:\Software\SQL Server 2016]

Double click [SSMS2016-Setup.exe] from the folder above and then click
Install, restart after completion

To access SSMS 2016 application easily, send it to the Desktop as a


shortcut.
2.3.2 Post Configuration

1. Instance authentication & security


- Start-up account in SQL
- SQL Server system admin login (sa)
- Local system admin

2. Network configurations
- Network Protocols
- TCP/IP Port
- SQL Server Browser

3. Instance default & customization setup


- Memory
- Processor
- Security
- Connections
- Database Default settings
- Advanced - Trigger Firing
2.3.2.1 Post Configuration - Instance authentication & security
Start-up account in SQL
- Launch SSMS, and connect to instance SQL2016PRD
- [Security] > [Logins] > [SQLSRVGRP] is added in the instance as of
login.
- Right click [SQLSRVGRP] > Properties > Server Roles > [sysadmin] is
checked, then check [General], [User Mapping], [Securables] and [Status]
2.3.2.1 Post Configuration - Instance authentication & security
- Disable SQL Server system admin login (sa)
- [Security] > [Logins] > [sa]
- Right click [sa] > Properties > Status > Choose [Disable] > Click [OK] to
make the change
2.3.2.1 Post Configuration - Instance authentication & security
- Local system admin
- [Security] > [Logins] > [NT AUTHORITY\SYSTEM] is there.
- Right click [NT AUTHORITY\SYSTEM] > Properties > Server Roles >
check the [sysadmin] server role.
2.3.2.2 Post Configuration - Network configurations
- Network Protocols
Launch SQL Server 2016 Configuration Manager
2.3.2.2 Post Configuration - Network configurations
- Network Protocols
Go to [SQL Server Network Configuration] > Protocols for
[SQL2016PRD] > enable [Shared Memory], [Named Pipes] and
[TCP/IP] > restart instance
2.3.2.2 Post Configuration - Network configurations
- TCP/IP Port
Double-click on TCP/IP protocol > TCP/IP Configuration page launched >
Click on IP Addresses tab > To see the TCP Dynamic Ports number, restart
the Engine and Agent Services first
2.3.2.2 Post Configuration - Network configurations
- SQL Server Browser
SQL Browser is required to be running if remote access tries to connect to
named instances.
[SQL Server Configuration Manager] > [SQL Server Browser] service > if
service is stopped > right click > Properties > Service tab > change [Start
Mode] > Automatic > then start the Browser service

33
2.3.2.2 Post Configuration - Network configurations
- SQL Server Browser
[SQL Server Configuration Manager] > [SQL Browser] service > right click
> Start > check to see if it is set to Auto-Start

34
2.3.2.3 Post Configuration - Instance default & customization setup
- Memory
Launch [SSMS] > SQL2016PRD > Properties > Memory in the left-hand

35
2.3.2.3 Post Configuration - Instance default & customization setup
- Memory
SSMS > SQL2016PRD > Properties > Processor > Leave this page with no
change

36
2.3.2.3 Post Configuration - Instance default & customization setup
- Security
SSMS > SQL2016PRD > Properties > Security > Failed logins audit log is
selected > The instance needs to be restarted.

37
2.3.2.3 Post Configuration - Instance default & customization setup
- Connection
SSMS > SQL2016PRD > Properties > Connection > [Maximum number of
concurrent connections] is set to 0 (0 = unlimited) > [Allow remote connections to
this server] is checked

38
2.3.2.3 Post Configuration - Instance default & customization setup
- Database Default settings
SSMS > SQL2016PRD > Properties > [Database Settings] > Change the Data,
Log and Backup folders as below.
NOTE: This has been setup when installing SQL2016PRD instance in Data
Directories.

39
2.3.2.3 Post Configuration - Instance default & customization setup
- Advanced - Trigger Firing
SSMS > SQL2016PRD > Properties > Advanced (left side) > [Allow Triggers to
Fire Others] > False
NOTE: Now we have checked/completed the instance properties settings, and
click OK. Restart the instance so that the changes will take place

40
2.3.2.3 Post Configuration - Instance default & customization setup

- Memory, Processor, Security, Connections


- Advanced - Trigger Firing,
- Server Audit - Enable default trace
- Server Configuration
- Server Security
- Service Area Configuration

41
2.3.3.1. List of environment and pre-checking:

1. Failover Cluster Sever Group


PROD-PP-1216 and RPT-DR-1216

2. Failover Availability Instances:


PROD-PP-1216\SQL2016PRD and
RPT-DR-1216\SQL2016DR

3. AlwaysOn Database: [Orders]

4. Cluster Quorum(shared): \\DC\QuorumShare

5. Shared AlwaysOn Database Folder:


\\PROD-PP-1216\SQL2016PRD

42
2.3.3.1. List of environment and pre-checking:

- Check, make sure Windows firewall are turned off in both PRD-PP-1216 and
RPT-DR-1216 servers:

43
2.3.3.1. List of environment and pre-checking:

- Check, make sure Named Pipes and TCP/IP are enabled in both instance
SQL2016PRD and SQL2016DR instance:

44
2.3.3.1. List of environment and pre-checking:
- Attached [Orders] database into [SQL2016PRD] instance
- Check, database [Orders]:Recovery model  Full / Compatibility level  SQL
Server 2016(130)
- Check, database [Orders] is not attached in RPT-DR-1216\SQL2016DR

45
2.3.3.2. Configure Quorum, Backup Folder and Recovery Mode
- Quorum is a configuration database accessible to all nodes on a shared location.
- Create [QuorumShare] folder on DC > properties > [Sharing] Tab > give full
control to [Everyone] > Add [SQL2K8\Administrator]

46
2.3.3.2. Configure Quorum, Backup Folder and Recovery Mode
- Give [Change] and [Read] permission to [SQL2K8\Administrator]

47
2.3.3.2. Configure Quorum, Backup Folder and Recovery Mode
- On PRD-PP-1216, use [SQL2016PRD] folder under C: drive
- Share out C:\ SQL2016PRD with proper permissions:​
Everyone with [Read​], [Read & execute], [List folder contents]

48
2.3.3.2. Configure Quorum, Backup Folder and Recovery Mode
- In RPT-DR-1216 C:\ Drive, create same folder structure [SQL2016PRD] with 3
subfolders - Backup, Data, Log.

49
2.3.3.3. Add Failover Feature and create cluster into Server
Install Failover Cluster feature in both PROD-PP-1216 and RPT-DR-1216:
- Open Server Manager
- Under [Manage] click [Add Roles and Features]

50
2.3.3.3. Add Failover Feature and create cluster into Server
Following the Wizard:
- Select destination server

51
2.3.3.3. Add Failover Feature and create cluster into Server
Following the Wizard:
- Take the default server roles selection > Next

52
2.3.3.3. Add Failover Feature and create cluster into Server
Following the Wizard:
- Select [Failover Clustering] > Add Features > Next

53
2.3.3.3. Add Failover Feature and create cluster into Server
Following the Wizard:
- Allow server restarts automatically > Install

54
2.3.3.3. Add Failover Feature and create cluster into Server
Following the Wizard:
- Allow the feature installing > Close after installed
- Repeat the steps above to install the Feature in RPT-DR-1216

55
2.3.3.3. Add Failover Feature and create cluster into Server
Before creating cluster, log off and log in with [SQL2K8\Administrator]
- [Server Manager] > [Tools] > [Failover Cluster Manager]

56
2.3.3.3. Add Failover Feature and create cluster into Server
- Right click [Failover Cluster Manager] > Create Cluster
- Follow the Wizard > Next

57
2.3.3.3. Add Failover Feature and create cluster into Server
- Browse two servers PROD-PP-1216 and RPT-DR-1216
- Following Wizard > Next > Agree to run the test
- Following Wizard > Next > Agree you have local admin permission

58
2.3.3.3. Add Failover Feature and create cluster into Server
- Take the default selection Yes to run configuration validation tests > Next
- Following Wizard > Next

59
2.3.3.3. Add Failover Feature and create cluster into Server
- Following the Wizard > Next > Run all tests
- Following the Wizard > Next > Ready to start the validation

60
2.3.3.3. Add Failover Feature and create cluster into Server
- Ignore warnings during the validation, let the test running
- When you see [Failover Cluster Validation Report] > Finish

61
2.3.3.3. Add Failover Feature and create cluster into Server
- Before creating the cluster, need to make sure VM using Domain IP address
starting with 10.10.10.xx instead of its own IP address: 192.168.xx.xx
- Go to [Control Panel] > [Network and Sharing Center] > [Change adapter
settings] > Disable Ethernet 2 and Ethernet 3

62
2.3.3.3. Add Failover Feature and create cluster into Server
- Create cluster name: [AG_Cluster]
- Network: 10.10.10.0/24, Address: 10.10.10.33
- 2 Nodes: PROD-PP-1216 and RPT-DR-1216
- NOTE: if IP address showing 192.168.xx.xx, make sure Ethernet 2 and
Ethernet 3 are disabled, cancel the wizard and recreate the cluster again.

63
2.3.3.3. Add Failover Feature and create cluster into Server
- Cluster [AG_Cluster] is created

64
2.3.3.3. Add Failover Feature and create cluster into Server
- In [AG_Cluster], the Witness is None
- Need to use the [QuorumShare] we created on DC to configure the Witness

65
2.3.3.3. Add Failover Feature and create cluster into Server
- [AG_Cluster.SQL2K8.com] > right click > More Action > Configure Cluster
Quorum Setting
- Following the Wizard > Next

66
2.3.3.3. Add Failover Feature and create cluster into Server
- In Select Quorum Configuration Option > choose the radio button [Select the
quorum witness] > choose radio button [Configure a file share witness]

67
2.3.3.3. Add Failover Feature and create cluster into Server
- Type in the path [\\DC\QuorumShare] > Next > Finished

68
2.3.3.3. Add Failover Feature and create cluster into Server
- When finish the configuration, the Witness will show as [\\DC\QuorumShare]
- As long as we create in PROD-PP-1216, there is no need to do all steps above
again in RPT-DR-1216

69
2.3.3.3. Add Failover Feature and create cluster into Server
- Go back to DC, verify the Witness information showing up under the folder
[QuorumShare]

70
2.3.4. AlwaysOn

We have setup the cluster environment for AlwaysOn, now we


will setup AlwaysOn as followings:

1. Enable AlwaysOn
2. Prepare AlwaysOn Database Orders
3. Setup Replicas
4. Testing Failover

When working on AlwaysOn, we can log back with username:


[SQLDBA1] or [SQLDBA2]

71
2.3.4.1. Enable AlwaysOn
In PROD-PP-1216\SQL2016PRD and RPT-DR-1216\SQL2016PRD
- Launch SQL Server Configuration Manager

72
2.3.4.1. Enable AlwaysOn

In [SQL Server Configuration Manager], right click on the SQL2016PRD


instance and choose Properties

73
2.3.4.1. Enable AlwaysOn
- Go to [AlwaysOn High Availablity] tab
- Enable AlwaysOn
- Restart the instance(Engine and Agent Services)

74
2.3.4.1. Enable AlwaysOn
- Restart the instance(Engine and Agent Services)
- Do the same thing in [RPT-DR-1216\SQL2016DR] instance

75
2.3.4.1. Enable AlwaysOn
- In SSMS, [PROD-PP-1216\SQL2016PRD] > right click > properties >
General > HADR is Enabled
- Check the same for [RPT-DR-1216\SQL2016DR] instance

76
2.3.4.1. Enable AlwaysOn
- Run the script below to check the cluster members:
select * from sys.dm_hadr_cluster_members

77
2.3.4.2. Prepare AlwaysOn Database Orders
- Create Full Backup in [PROD-PP-1216\SQL2016PRD] with the scripting:
BACKUP DATABASE Orders TO
DISK=‘C:\SQL2016PRD\Backup\Orders.Full.bak’ WITH COMPRESSION
- In [RPT-DR-1216\SQL2016DR], there is no database [Orders] attached

78
2.3.4.3. Setup Replicas
- In [PROD-PP-1216\SQL2016PRD] > Expand [AlwaysOn High Availability​
] > Right click [Availability Groups] > New Availability Group Wizard

79
2.3.4.3. Setup Replicas
- Give the group name: [AG-CLUSTER]
- Note: the name is [AG-CLUSTER], different from cluster name:
[AG_Cluster]

80
2.3.4.3. Setup Replicas
- Check [Orders] for the AlwaysOn database

81
2.3.4.3. Setup Replicas
- Check [Automatic Failover] > Set [Readable Secondary] to Yes >- Add
Replica

82
2.3.4.3. Setup Replicas
- Add Replica to [RPT-DR-1216\SQL2016DR] as the secondary from
Network Servers

83
2.3.4.3. Setup Replicas
- Configure the secondary replica
- Check [Automatic Failover] and [Synchronous Commit] > Set [Readable
Secondary] to Yes > Next

84
2.3.4.3. Setup Replicas
- Check [Endpoint]

85
2.3.4.3. Setup Replicas
- Check [Backup Preference], set to [Primary]

86
2.3.4.3. Setup Replicas
- In [Listener] > Type in Listener DNS Name [AG_LSN_2016] >
Port: 1433 > Scroll down > Add IP Address

87
2.3.4.3. Setup Replicas
- Add IP Address: 10.10.10.38 > OK

88
2.3.4.3. Setup Replicas
- Check [Listener] information we entered > Next

89
2.3.4.3. Setup Replicas
- Select [Full] > Browse > select the shared backup folder path: [\\Prod-pp-
1216\SQL2016PRD\Backup]

90
2.3.4.3. Setup Replicas
- Check the [Validation] page > Next

91
2.3.4.3. Setup Replicas
- [Finish] the setup

92
2.3.4.3. Setup Replicas
- Install successfully and [Close] the wizard

93
2.3.4.3. Setup Replicas
- Refresh and check AlwaysOn for database [Orders] on both PROD-PP-
1216 and RPT-DR-1216

94
2.3.4.3. Setup Replicas
- Check from [Failover Cluster Manager], see the information from [Roles]

95
2.3.4.3. Setup Replicas
- Check from [Failover Cluster Manager], see the information from
[Nodes]

96
2.3.4.4. Configure Failover Cluster (Manual Failover)
- In [PROD-PP-1216] SSMS, right click [AG-CLUSTER] > Failover >
Next

97
2.3.4.4. Configure Failover Cluster (Manual Failover)
- Select [RPT-DR-1216\SQL2016DR] as new Failover Primay > Next

98
2.3.4.4. Configure Failover Cluster (Manual Failover)
- Connect to [RPT-DR-1216\SQL2016DR] as Failover availability replica
- Before making this configuration, need to login with
[SQL2K8\Administrator], or any logins which have [sysadmin] role in
[RPT-DR-1216\SQL2016DR]

99
2.3.4.4. Configure Failover Cluster (Manual Failover)
- Connect to [RPT-DR-1216\SQL2016DR] with [SQL2K8\SQLDBA1] as login

100
2.3.4.4. Configure Failover Cluster (Manual Failover)
- Verified the information and [Finish] the configuration

101
2.3.4.4. Configure Failover Cluster (Manual Failover)
- Completed successfully and [Close] the configuration

102
2.3.4.4. Configure Failover Cluster (Manual Failover)
- After the configuration, we can see [PROD-PP-1216\SQL2016PRD] becomes
[Secondary] and [RPT-DR-1216\SQL2016DR] becomes [Primary]

103
2.3.4.5. Testing Failover (Auto Failover)
- Pause the VM [RPT-DR-1216] and check [PROD-PP-1216\SQL2017PRD]
- AG-CLUSTER in SQL2016PRD change the status from [Resolving] to
[Primary]

104
2.3.4 AlwaysOn
We are done for the AlwaysOn configuration
and tested failover, and it works as expected.​

105
Q&A

Thanks and See You Next Time

106

You might also like