Vous êtes sur la page 1sur 15

Demo Flow

 Review Prerequisites.
 Complete a best-practices installation of SQL Server 2016 on an Azure VM, utilizing a Marketplace
image.

Prerequisites
 You will need access to an Azure Subscription in order to create and utilize the virtual machine
described in this lab

Duration
 TBD

Demo: Best-Practices Installation of SQL Server 2016 Database Engine


utilizing an Azure Virtual Machine Template
Perform these steps to build an Azure Virtual Machine running SQL Server 2016

1. Browse to https://portal.azure.com/
a. Log in with the Microsoft Account that has access to the Azure Subscription you plan to
utilize for this demo.
2. Click on the New button in the upper-left area of the screen
3. In the Search the marketplace box under New, type "SQL Server 2016" and hit Enter

4. From the search results, click the SQL Server 2016 CTP3 Evaluation on Windows Server 2012 R2
template

5. Review the information about this VM image shown in the next pane.
6. If necessary, change the Select a deployment model pickbox to Resource Manager, then click the
Create button.

8. Set all options for creating a new virtual machine according to the following steps:
a. In the Basics pane:
i. Enter desired virtual machine Name, along with a User Name and Password which
will be created as a local account on the VM.
ii. Select the Subscription this VM will be built in, if you have multiple subscriptions
available.
iii. Type the name for a new Resource Group; for the purposes of this demo, it should
match the name assigned to the VM
iv. Select a Location that is geographically closest to your location. This denotes the
Azure Region where this VM will be created.
v. Click the OK button.

b. In the Choose a size pane:


i. Click the View All link to see all VM sizes available.
ii. Click the DS1 Standard machine type, and click the Select button.

c. In the Settings pane:


i. Select Standard as the Disk Type.
ii. Note that a New Storage Account is being created. Make a note of this name.
iii. Note that a new Virtual Network is being created. Make a note of this name.
iv. The Public IP Address and Network Security Group default to the same name as the
VM. These can be left as-is.
v. Under Monitoring, set Diagnostics to Disabled.
vi. Availability Set can be left on None.
vii. Click OK.

d. On the Summary screen, review all of the settings/configuration for the new VM
e. Click OK to begin deployment of the Virtual Machine

f. While provisioning of the VM is in-progress, it will be visible on the Virtual Machines screen
of the Azure portal, where its Status can be monitored.

9. Connect to the new Virtual Machine


a. After VM creation is complete, click on it in the Virtual Machines screen of the Azure portal.
b. Click on the Connect button in the toolbar below the VM's name.

c. This will download an .rdp file preconfigured to connect to the VM via its public IP address.
d. Optional: Save this .rdp file for repeated use.
e. Open the .rdp file to connect to the VM (it may take some time for the machine to accept
connections, so be patient)
f. Log in with the username and password entered during Step 8 while creating the machine.
You will need to use the machine name as the domain name to log in. In the example here,
we would use the username SQL16Azure\LocalDBA.
10. For Polybase support, Install Oracle JRE 7 Update 51 (64-bit) or higher (Java)
a. You may need to add oracle.com to IE's Trusted Sites list and/or disable IE Enhanced
Security Configuration for Administrators to complete this task.
b. Browse to http://www.oracle.com/technetwork/java/javase/downloads/index.html
i. Alternatively, www.oracle.com/java, then click Java for Developers, then, under
Browse by Category, click Java SE
c. Click the Java Download graphic

(as of this writing, JDK 8 Update 66 is current)


d. Accept the license agreement, and select the x64 Windows installation

e. After downloading and launching the installer, click Next on the first screen.
f. Click Next, accepting the default installation setup
g. Click Next to accept the default destination folder.
h. Click Close after the installation has completed
11. Perform remaining component installation steps
a. Using SQL Server Configuration Manager, ensure that the SQL Server engine service is
running before continuing.
b. Right-click on the Start button, and select Programs and Features from the context menu.
c. Select Microsoft SQL Server 2016 CTP3.0 (64-bit), and then click on the Uninstall/Change
button.

d. Click Add
e. If you are asked for installation media, browse to C:\SQLServer_13.0_Full
f. Click Next on the Product Updates screen.
g. Click Next on the Install Setup Files screen.
h. On the Installation Type screen, select Add Features to an existing instance of SQL Server
2016 CTP3.0 and click Next.
i. Select Advanced Analytics Extensions and PolyBase Query Service for External Data to
install. Click Next.

j. Click Next on the Feature Rules page.


k. For the purposes of this demo, the new Service Account assignments can remain at their
default local system values. In a regular installation, these services should be configured to
run with minimally-privileged Active Directory user accounts. Click Next.
l. Click Next on the PolyBase Configuration page (defaults are fine here).
m. Review the Installation Settings and click Install on the Ready to Install page.

n. After installation completes, click Close to close the installation wizard.


12. Perform post-installation best practices settings changes for running SQL Server in Windows
Azure. As SQL Server was installed as part of the VM's template, we were unable to control the
initial TempDB settings, so there are additional steps in this section to configure TempDB.
a. Launch SQL Server Management Studio and connect to the installed SQL Engine instance
b. For these setting changes, the Advanced configuration options must be made available. Run
the following TSQL to enable these options:
exec sp_configure 'show advanced options', 1;
RECONFIGURE WITH OVERRIDE;
c. In order to set the Max Server Memory property to a proper non-default value, use the
following TSQL. For the DS1 VM size we are using, with 3.5 GB of RAM, we will set the max
server memory to two GB (2048 MB):
EXEC sp_configure 'max server memory (MB)', '2048';
RECONFIGURE WITH OVERRIDE;
d. Another best practice is changing the Maximum Degree of Parallelism away from the
default. Running the following TSQL will change the MaxDOP for the instance to the number
of processors available on the server (in this case, it will set it to one):
declare @cpu_Countdop int
select @cpu_Countdop=cpu_count
from sys.dm_os_sys_info;
exec sp_configure 'max degree of parallelism', @cpu_countdop;
RECONFIGURE WITH OVERRIDE;
e. Disable advanced configuration options:
exec sp_configure 'show advanced options', 0;
RECONFIGURE WITH OVERRIDE;
f. Change Recovery Model and File Size and Growth settings on the Model database, in order
to control the default settings used by user databases when they are created. Run the
following TSQL:
ALTER DATABASE model SET RECOVERY SIMPLE;
go
ALTER DATABASE model MODIFY FILE (NAME = modeldev, FILEGROWTH = 100MB)
go
ALTER DATABASE model MODIFY FILE (NAME = modellog, FILEGROWTH = 100MB)
go
g. Create a directory on the D: drive named TempDB; this will be used for storage of TempDB
files.
h. Run the following TSQL to configure TempDB in this dedicated space. It will set the total size
of the files to 2 GB.
declare @sql_statement nvarchar(4000),
@data_file_path nvarchar(100),
@drive_size_gb int,
@individ_file_size int,
@cpu_count int,
@number_of_files int

select @cpu_count = cpu_count


FROM sys.dm_os_sys_info dosi

SELECT @data_file_path = 'D:\TempDB\';

SELECT @drive_size_gb = 2
SELECT @number_of_files =
CASE WHEN @cpu_count > 8 THEN (@cpu_count/2)
ELSE 4
END;
SELECT @individ_file_size = (@drive_size_gb*1024)/(@number_of_files)

PRINT '-- TEMP DB Configuration --'


PRINT 'Temp DB Data Path: ' + @data_file_path
PRINT 'File Size in MB: ' +convert(nvarchar(25),@individ_file_size)
PRINT 'Number of files: '+convert(nvarchar(25), @number_of_files)

WHILE @number_of_files > 0


BEGIN
if @number_of_files = 1 -- main tempdb file, move and re-size
BEGIN
SELECT @sql_statement = 'ALTER DATABASE tempdb MODIFY FILE
(NAME = tempdev, SIZE = '+ convert(nvarchar(25), @individ_file_size) +
', filename =
'+nCHAR(39)+@data_file_path+'tempdb.mdf'+nCHAR(39)+',MAXSIZE =
'+ convert(nvarchar(25), @individ_file_size) + ', FILEGROWTH =
100MB);';
END
ELSE -- numbered tempdb file, add and re-size
BEGIN
SELECT @sql_statement = 'ALTER DATABASE tempdb ADD FILE (NAME =
tempdev0' + convert(nvarchar(25), @number_of_files)+',filename =
'+nCHAR(39)+@data_file_path+'tempdb0' + convert(nvarchar(25),
@number_of_files)+'.ndf'+nCHAR(39)+', SIZE = '+ convert(varchar(25),
@individ_file_size) + ', MAXSIZE = '+ convert(nvarchar(25),
@individ_file_size) + ', FILEGROWTH = 100MB);';
END

EXEC sp_executesql @statement=@Sql_Statement


PRINT @sql_statement

SELECT @number_of_files = @number_of_files - 1


END

-- Move Tempdb Log file


SELECT @sql_statement = 'ALTER DATABASE tempdb MODIFY FILE (NAME = templog, SIZE
= 50, filename = '+nCHAR(39)+@data_file_path+'tempdb.ldf'+nCHAR(39)+',MAXSIZE =
''UNLIMITED'', FILEGROWTH = 100MB);';

EXEC sp_executesql @statement=@Sql_Statement;


i. Create a directory on C: named Startup, and create a file named TempDBFolder.cmd inside.
This file should contain the following command:
mkdir "d:TempDB"
j. Utilizing Task Scheduler on the server, create a scheduled task to run this file at system
startup. The task should run as the SYSTEM account. This task will create the TempDB folder
on D: for SQL Server in the event that the temporary volume has been wiped.

Vous aimerez peut-être aussi