Setting up SQL Server on Red Hat Linux in AWS - Part 1


By:   |   Updated: 2018-04-30   |   Comments (1)   |   Related: More > Amazon AWS


Problem

Microsoft introduced SQL Server 2017 on Linux and many of us would like to see and use SQL Server 2017 on Linux in the cloud (AWS/Azure). SQL Server 2017 on Linux is not introduced as part of the managed services in AWS or Azure, hence we can install SQL Server 2017 on Linux in EC2 machines and run on a cloud server. In this tip, I will show how to install and configure Red Hat Enterprise Linux 7.4 in an EC2 instance server.

Solution

We will discuss the prerequisites to install and configure the SQL Server 2017 on Linux in cloud using Red Hat Enterprise Linux 7.4 in EC2 instance server in Amazon Web services Elastic Compute Cloud (EC2) environment. The goal is to setup SQL Server 2017 on Linux in the cloud as SQL Server 2017 on Linux is not introduced as part of managed services in AWS or Azure.

Hardware and software requirements

Cloud computing requirements are equal to on-premises, but before you begin to create the Red Hat Enterprise Linux 7.4 EC2 instance in AWS you need to create a virtual environment in the could – virtual private could (VPC), subnets, etc. For an on-premises data center we are responsible to get all required hardware, software, storage, and licenses etc., and in cloud computing basically you are renting the hardware, software, storage and licensing (however, if you have your own license then you can use your own), Amazon AWS provides a wide range of Elastic Compute Cloud (EC2) instance selections as per the business requirements.

Planning Red Hat Enterprise Linux 7.4 in EC2

The first step to build our Red Hat Enterprise Linux 7.4 in Elastic Compute Cloud (EC2) Instance is that we need to create a virtual private could (VPC) with availability zones (subnets) and all other requirements in Amazon AWS. I explained in detail how to build an Enterprise Environment in AWS in this tip. After you all the requirements in place, follow the below steps to install Red Hat Enterprise Linux 7.4 in Elastic Compute Cloud (EC2) Instance.

Step # 1 – Create EC2 Instance in AWS Management Console

Amazon Elastic Compute Cloud (EC2) also called an EC2 Instance is a cloud-based server. In cloud-based servers, you can build a Red Hat Enterprise Linux 7.4 server. In EC2 you can create a Red Hat Enterprise Linux 7.4 using the free tier or you can pay as you go on an hourly basis. To calculate your hourly charges click here.

You can build your server with a few clicks as per your requirements. Amazon offers a wide range of selections for instance types to best fit your needs. You can compare various types of instance combinations of memory, storage, networking and CPU capacity. For more info you can visit Amazon AWS site here.

To create the Red Hat Enterprise Linux 7.4 server EC2 Instance click on services (top left side), and under Compute select EC2.

To create Red Hat Enterprise Linux 7.4 server EC2 Instance click on services (top left side), and under the Compute select EC2.

On the Resource Groups, click on Launch Instance.

On Resource Group dialog box click on Lunch Instance.

Or click on Services (top left side) and under the Compute select EC2 and then on the left side under EC2 Dashboard click on Instances then click on down arrow on Launch Instance.

Or click on services (top left side) and under the Compute select EC2 -> left side under the EC2 Dashboard click on Instances then click on down arrow Lunch instance.

Select appropriate Amazon Machine Image (AMI) as shown below. Here I am selecting Red Hat Enterprise Linux 7.4 (HVM), SSD Volume Type - ami-0b1e356e.

Select appropriate Amazon Machine Image (AMI) as shown below. Here I am selecting Red Hat Enterprise Linux 7.4 (HVM), SSD Volume Type - ami-0b1e356e

On Choose Instance Type page, select the instance type and hit Next: Configure Instance Details. (For more information click here).

On Choose an Instance Type Page, Select Instance Type and Hit Configure Instance Details. (For more information Click Here)

On the Configure Instance Details page enter number of instances needed to be created then select Network VPCs, select Subnet, IAM role, Shutdown behavior and click on Next: Add Storage.

On Configure Instance details page enter number of Instances need to be created then; Select Network VPCs, Select Subnet, IAM role, Shutdown behavior and click on Add Storage.

On the Configure Instance Details page, the Tenancy option by default will run on a shared hardware instance. You can also choose to run your instance on dedicated servers. For more information on dedicated click here and more for more information on dedicated instances click here.  Then click Next: Add Storage.

On Configure Instance details page, select tenancy by default the server will run on shared – run a shared hardware Instance.
You can choose to run your instance on physical servers fully dedicated for your use. The use of host tenancy will request to launch instances onto dedicated hosts for more information click here while the use of dedicated tenancy will launch instances as Dedicated instance click here. You can launch an instance of a tenancy of the host or dedicated into a Dedicated VPC.


On the Add Storage page, click on Add new Volume (in free tier there will be 30 GBs of storage available) and select Volume Type and click Next: Add Tags.

Note: you can additional storage by clicking on Add New Volume.

On Add Storage page, click on Add new Volume (In free tier there will be 30 GBs storage available) and select Volume type and click Add Tags.

On the Add Tags page, click on Add another tag to add tags for this server. Then click Next: Configure Security Group.

On Add Tag page – click on Add Tag.

On Configure Security Group page, select Create a new security group to add a new one or Select an existing security group to use an existing security group and the click on Review and Launch.

On Configure Security Group page, click one Create New security group or select an existing security group and then select security group and click on Review and Launch.

On the Review Instance Launch page, review all configuration settings and hit Launch.

On review Instance launch page, review all configuration setting and hit launch.

On the Select an existing key pair or create a new key pair dialog box, select Create a new key pair or Choose an existing key pair and give the key pair a name and click on download to download the Key Pair. Here I have already downloaded the Key Pair and I am acknowledging that I have access to the selected private key files. (save the key pair in a secure location). Hit Launch Instances.

On select an existing key pair or create a new key pair dialog box click on create a new key pair or select an existing key pair and give key pair name and click on download to download key Pair. Here I have already downloaded and I am acknowledging that I have access to the selected private key files. (save the key pair in secured location). Hit launch instance.

On the Instances page the instance are shown and the instance state shows what is running.

On Instances page the Instance is initialized the status will be shown as passed and AWS Instance is up and running.

Step # 2 – How to connect Red Hat EC2 Instance via Puttygen

To connect Red Hat Enterprise Linux 7.4 EC2 instance using a Putty Session you need to convert the Pem file to PPK files using PuttyGen. To convert the Pem files to PPK files follow the below steps.

Window users need to install the PuTTy software on your machine or on the server to connect the Linux session from the Window machine or on the server.

The PuTTy software can be downloaded from www.putty.org website. You can download the entire package or just the puttygen and Putty utility.

To connect Red Hat Enterprise Linux 7.4 EC2 instance by Putty Session you need to convert the Pem file to PPK files using PuttyGen. To convert Pem files to PPK files follow below steps.

Window users need to install the PuTTy software in your laptop or on the server to connect the Linux session from window laptop or on the server.

PuTTy software can be downloading it from www.putty.org website; you can download the entire package or puttygen and Putty utility.

To connect Red Hat Enterprise Linux 7.4 EC2 instance by Putty Session you need to convert the Pem file to PPK files using PuttyGen. To convert Pem files to PPK files follow below steps.

Window users need to install the PuTTy software in your laptop or on the server to connect the Linux session from window laptop or on the server.

PuTTy software can be downloading it from www.putty.org website; you can download the entire package or puttygen and Putty utility.


Here I have downloaded the PuTTY and PuTTYGen and installed in my machine.

Step # 3 - How to convert Pem file to PPK file format

PuTTy doesn’t support the PEM format which AWS uses, so you need to convert the PEM file to PPK file (PPK stands for PuTTY Private Key). To convert the PEM files to PPK files follow the below steps.

To start PuttyGen utility type PuttyGen in the Windows start dialog box, once PuttyGen appears then open PuttyGen.

PuTTy doesn’t support PEM format which AWD use, so you need to convert the PEM file to PPK file (PPK stand for PuTTY Private Key). To convert the PEM files to PPK file follow below steps.

To start PuttyGen utility type PuttyGen in the windows start dialog box, once PuttyGen appear then open the PuttyGen. 



On the PuTTYgen dialog box, click on Load to locate the file and select the .pem files which you download from AWS when you built the EC2 instance. I had a Win2016.pem to load and convert to (Dot) PPK file.

 

On the PuTTYgen dialog box, click on load and locate the file and select the .pem files which you download from AWS. When you build up the EC2 instance. Earlier I have Win2016.pem to load and convert into (Dot) PPK file.

Note: You may be not able to see the pem file, if so select all files in drop down list after that your pem file and hit open.


Note: You may be not able to see the pem file, if so select all files in drop down list to find the pem file and hit Open.

On the PuTTYgen dialog box, click on load and locate the file and select the .pem files which you download from AWS. When you build up the EC2 instance. Earlier I have Win2016.pem to load and convert into (Dot) PPK file.

Note: You may be not able to see the pem file, if so select all files in drop down list after that your pem file and hit open.


On the PuTTYgen dialog box, the Pem file has successfully loaded; as the message indicates. Click Ok to save the file.

On the PuTTYgen dialog box, the Pem file has successfully loaded; as the message indicates click Ok to save the file.

On the PuTTYgen dialog box, click on Save private key to save file with a PPK format. 

On the PuTTYgen dialog box, click on “Save private key” to save file with PPK format.

You will get a warning messages as below, whether you want to save the key without a passphrase or not, select Yes and give a key name for your PPK file and click Save private key.

You will get a warning messages as below weather you want to save the key without a passphrase or not, select Yes and give a key  name for your ppk file and click save.

On the PuTTYgen dialog box, I have saved the file with the same file name as the original file name by changing the file format.

On the PuTTYgen dialog box, I have saved with the same file name the original file name by changing the file format.

Step # 4 - How to launch PuTTy terminal session

As we have converted the pem file to a ppk file, now you can connect the PuTTY terminal session. To connect Red Hat Enterprise Linux 7.4 EC2 instance using PuTTy terminal sessions follow the below steps.

In the Windows start dialog box, type in putty to start the terminal session.

How to enter host name

Frist you need to enter your host name into host Name (or IP address) field. Amazon provided the format to connect to any Linux EC2 instance server. The format will be your user name followed by the IP address ([email protected] IP). To specify the appropriate user name for your Amazon instance (AMI) see the below or for more information click here.

These all user name formats are provided by Amazon AWS

Get the default user name for the AMI that you used to launch your instance.

  • For an Amazon Linux AMI, the user name is ec2-user.
  • For a Centos AMI, the user name is centos.
  • For a Debian AMI, the user name is admin or root.
  • For a Fedora AMI, the user name is ec2-user or fedora.
  • For a RHEL AMI, the user name is ec2-user or root.
  • For a SUSE AMI, the user name is ec2-user or root.
  • For an Ubuntu AMI, the user name is ubuntu or root.
  • Otherwise, if ec2-user and root don't work, check with the AMI provider.

Here I am connecting to a Red Hat Enterprise Linux 7.4 EC2 instance in AWS with non-default user name.

As we have converted the pem file to a ppk file, now you can connect the PuTTY terminal session. To connect Red Hat Enterprise Linux 7.4 EC2 instance using PuTTy terminal sessions follow below steps.

In the Windows start dialog box, type in putty to start the terminal session.
Here I am connecting to a Red Hat Enterprise Linux 7.4 EC2 instance in AWS with non-default user name.



Now click on plus sign (+) next to SSH in the PuTTy terminal session to expand this section. Then click on Auth (to authenticate the session using private key file), select your private key file (Example: ppk file) under the Private Key file for authentication (click on browse to search your directory where you stored the PPK authentication file).

Now click on plus sign (+) next to SSH in PuTTy terminal session to expand this section. Then click on Auth (to authenticate the session using private key file), select your private key file (Example: ppk file) under the Private Key file for authentication (click on browse to search your directory where you store the PPK authentication file).



On the PuTTY dialog box, we can see that the PPK file has been loaded for authenticating the session using the private key files.

On the PuTTY dialog box, we can see that the PPK file has been loaded for the authenticate of the session using private key files.

Step # 5 - How to login to Red Hat Enterprise Linux 7.4 on EC2

Finally, click on Open to start your SSH session.

Finally, click on Open to start your SSH session.

If you are logging on for the first time to Red Hat Enterprise Linux 7.4 on EC2 thru a PuTTy terminal session, you will receive the following alert shown in the image below. Click on Yes to continue.

Note: If you face any issues while you try to connect with a SSH terminal session, it’s due to needed rules not enable in your security group (for simplicity I have allowed all traffic, but in a real environment you should open only the appropriate ports attached to the instance).

If you are login first time to Red Hat Enterprise Linux 7.4 on EC2 thru the PuTTy terminal session, you will receive the following alert. Click on yes to continue.
If you have done all configurations appropriately, then you will get a new window appear as below displaying your command line SSH terminal session 
Note: If you face any issue while you try to connect SSH terminal session; it’s due to appropriate rule is not enable in your security group (for simplicity here I have allowed all traffic but in real environment you should open appropriate port) attached to the instance).


If you have done all configurations appropriately, then a new window will appear as shown below displaying your command line SSH terminal session.

Here I have run below command to update the server.

/* to update the server */
sudo yum update
			
Here I have run below command to update the server.
Here I have run below command to update the server.

Once the system update check is complete it will ask to download and install the update, hit the “y” to download and install all the packages.

Once the system update check is complete it will ask to download and install the update, hit the “y” to download and install all the packages.

After all downloads and update is complete the message Complete! will be displayed.

After all downloads and update is completed it will appear message as complete!

Conclusion

In this article we discussed how to build a Red Hat Enterprise Linux 7.4 in Elastic Compute Cloud (EC2), convert pem files into ppk format and connect to a Red Hat server using a Putty terminal window. In Part 2 of this series, we will walk thru how to install SQL Server 2017 on Linux and connect SQL Server 2017 in Linux using SQLCMD and SSMS.

Next Steps


Last Updated: 2018-04-30


get scripts

next tip button



About the author
MSSQLTips author Pinakin Patel Pinakin Patel is a SQL Server Admin / AWS Solutions Architect with experience in SQL Server 2000 to 2016.

View all my tips
Related Resources





Comments For This Article




Tuesday, August 06, 2019 - 11:47:36 AM - Ram Back To Top (81979)

I really appreciate you sharing a step by step configuration. Great info! 



download





Recommended Reading

Limitations of SQL Server Native Backup and Restore in Amazon RDS

Setting SQL Server Configuration Options with AWS RDS Parameter Groups

Serverless ETL using AWS Glue for RDS databases

Restore SQL Server database backup to an AWS RDS Instance of SQL Server

Troubleshoot Slow RDS SQL Servers with Performance Insights








get free sql tips
agree to terms


Learn more about SQL Server tools