Sunday, July 29, 2018

Installation steps of SQL Server 2017 container image with Docker


           INSTALLATION OF  SQL SERVER DOCKER CONTAINER IMAGES



Docker: 

Docker is an open-source container platform provider written in GO programming language. It’s available for Linux, Windows, and MacOS. In addition, it also works in Azure and AWS environments. Containers allow developers to package up an application with all the parts it needs, such as libraries and other dependencies, and deliver it all out as one package. It’s something similar to Virtual Machines but without the guest operating system. They’re isolated, but they share Host OS. That makes them smaller and more lightweight.

Here we will use Docker to pull and run the SQL Server 2017 container image. Then connect with sqlcmd to create database and run queries. This image consists of SQL Server running on Linux based on Ubuntu 16.04. It can be used with the Docker Engine 1.8+ on Linux or on Docker for Mac/Windows.





Prerequisites: 

  • Docker Engine 1.8+ on any supported Linux distribution or Docker for Mac/Windows. 
  • Minimum of 2 GB of disk space
  • Minimum of 2 GB of RAM


Steps of Installation:


Pull the SQL Server 2017 Linux container image from Docker Hub.

sudo docker pull microsoft/mssql-server-linux:2017-latest




apt install docker.io




   sudo docker pull microsoft/mssql-server-linux:2017-latest










    To run the container image with Docker

    sudo docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=<YourStrong!Passw0rd>' \
   -p 1433:1433 --name sql1 \
   -d microsoft/mssql-server-linux:2017-latest





To view your Docker container. If the STATUS column shows a status of Up, then SQL Server is running in the container

sudo docker ps -a





      Change the SA password: 


sudo docker exec -it sql1 /opt/mssql-tools/bin/sqlcmd \

   -S localhost -U SA -P '<YourStrong!Passw0rd>' \

   -Q 'ALTER LOGIN SA WITH PASSWORD="<YourNewStrong!Passw0rd>"'





command to start an interactive bash shell inside your running container

sudo docker exec -it sql1 "bash" 




Once inside the container, connect locally with sqlcmd. Sqlcmd is not in the path by default, so you have to specify the full path.

/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P '<YourNewStrong!Passw0rd>'









To end your sqlcmd session, type QUIT .Your container continues to run after you exit the interactive bash shell.


Connect from outside the container


We can also connect to the SQL Server instance on Docker machine from any external Linux, Windows, or macOS tool that supports SQL connections.


sqlcmd -S 10.3.2.4,1433 -U SA -P '<YourNewStrong!Passw0rd>'


   
  SQL Server container can be  start,stop and remove  with the command 

sudo docker start sql1
sudo docker stop sql1

sudo docker rm sql1







     

Sunday, July 22, 2018

Installation of SQL Server in Ubuntu 18.04 Linux Platform




Please install Oracle virtual Machine in your laptop . Please follow the below link to install Ubuntu 18.04 in your virtual machine. 






Please follow the below steps to install SQL Server in Ubuntu 18.04



Step 1:

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add –






Step 2:







Step 3:
sudo apt-get update
sudo apt-get install -y mssql-server


Once you run this command you will get an error for downgrading openssl. You must downgrade openssl prior to 1.1.0 and then only you can install sql server in Ubuntu 18.04. Please check the below screen shot.




The steps after the openssl error

Step 4:

apt-get install -y libjemalloc1 libsss-nss-idmap0 libc++1 gawk curl




Step 5 :

curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -




Step 6 :

add-apt-repository "$(curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2017.list)"






Step 7:





Step 8:




Step 9 :

dpkg -i ca-certificates_20160104ubuntu1_all.deb




Step 10:

wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/openssl_1.0.2g-1ubuntu4_amd64.deb



Step 11

dpkg -i openssl_1.0.2g-1ubuntu4_amd64.deb




Step 12:

apt install -y libcurl3




Step 13:

apt-get update
apt-get install -y mssql-server




Step 14:

After the package installation finishes, run mssql-conf setup and follow the prompts to set the SA password and choose your edition.

sudo /opt/mssql/bin/mssql-conf setup






Step 15 : To chek SQL Server service is started or not

Systemctl status mssql-server





Step 16: 

Sudo apt-get install mssql-tools




Step 17 :


Bash path settings for SQLCMD tool

echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile

echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc






Step 18 :

Login to SQL Server using SQLCMD

Command : 

sqlcmd -S localhost -U SA -P





  Step 19: 

Active firewall and open port 1433 for communicating with application

command : sudo ufw enable 




Step 20: 

Sudo ufw allow 1433