Docker

Install SQL server on Linux CentOS redhat create multiple Docker in laptop using VMware Workstation – Part 1

Advertisements

Install SQL server on Linux CentOS Redhat create multiple Docker in laptop using VMware Workstation

What is Docker container https://www.docker.com/resources/what-container

In simple container is an image or package that will have binaries, configurations etc of the application to run on. Example – In a single OS you can run multiple containers, like CentOS SQL 2017 and 2019 version etc. It is very easy to install, once the image pulled and stored locally, creating SQL server is in a seconds, the advantage is you can create your own images based on the organization standards and store it in Docker HUB. Docker is a container engine developed by Docker to run a containers.

Being SQL server database administrator, mostly we will not worked on Linux platform, I have supported Oracle couple of years and have knowledge of Linux platform.

Following is the 6 steps we are going to test and do ourselves in laptop.

  1. Install VMware workstation and CentOS
  2. Install SQL server on Linux CentOS
  3. Create and install multiple Docker SQL server
  4. Create volumes with persist data for SQL server database files
  5. Customize base SQL server image with Docker file

Creating customized SQL container based the organization standard and push to Docker hub.

Create multiple container from Docker file template by using custom SQL server images.

Create multiple SQL server containers creation by using Docker compose with YML script.

  1. Backup and restore SQL server databases from Linux to windows

Software needed:

Software Free URL
VMware workstation 30 days trail https://my.vmware.com/web/vmware/downloads
CentOS Free https://www.centos.org/download/
Docker images Free We can pull from internet

 

Download latest VMware workstation and install. – This can be found in my failover cluster post.

CentOS-7-x86_64-DVD-1908 https://mirror.umd.edu/centos/7/isos/x86_64/

 

  1. Install VMware workstation and CentOS

 

Create and install CentOS on VMware workstation.

File – Create new virtual machine –Custom –I will install OS later – Linux choose CentOS 64 bit

— Type and path –Allocate CPU and RAM – Use Bridge network – remaining all recommended

— click customize hardware – click CD/DVD and map / mount the OS downloaded file.

Power On the machine – click enter – select language – Choose installation destination – Software select should be server with GUI – Enable the network – Provide the root password.

Refer how to install CentOS on VMware workstation: https://www.youtube.com/watch?v=LsXQwnnL4bI

  1. Install SQL server on Linux CentOS

Install SQL server in the Linux CentOS not into the container.

Try connect it from SSMS into the Linux SQL from your laptop using port 1433.

 

# Let's check if mssql-server repository already exists? 

sudo ls /etc/yum.repos.d | grep mssql-server.repo

# If it does, we need to check contents of this repository and remove that, otherwise we will face issues during the install

sudo cat/etc/yum.repos.d/mssql-server.repo

sudo rm -rf /etc/yum.repos.d/mssql-server.repo

# Configure and Download SQL Server Repository

sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config...
sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2019.repo

# Install SQL Server using below commands

yum makecache fast
sudo yum install -y mssql-server

# Configure SQL Server and Setup SA password

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

Choose edition and licsence and SA password

opt/mssql/bin/sqlservr: /lib64/libc.so.6: version `GLIBC_2.18' not found required by /opt/mssql/bin/../lib/libc++abi.so.1
Initial setup of Microsoft SQL Server failed. Please consult the ERRORLOG

journalctl --since "2020-02-02 00:00:00" --until "2020-02-02 23:30:00"

/var/opt/mssql/log/

# Restart SQL Server Services

systemctl restart mssql-server
systemctl status mssql-server

# Configure repository and install Sqlcmd and other Tools to internally connect to newly installed SQL Server

sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config...
sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/7/prod.repo

sudo yum install -y mssql-tools unixODBC-devel

#Set Environment Tools to your Path Environment

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


# Connect to SQL Server using sqlcmd tool 

sqlcmd -S centos-muthu -U SA -P G0d$peed123
sqlcmd -S localhost -U SA
1> select top 1 name from sys.databases;
2> go
name
--------------------------------------------------------------------------------------------------------------------------------
master

(1 rows affected)
1>


# Connect to SQL Server Remotely using SQL Server Authentication

SSMS - Error and Resolution 

# Enable Firewall port 1433 


sudo firewall-cmd --zone=public --add-port=1433/tcp --permanent
sudo firewall-cmd --reload

Open SSMS and try to connect by IP and hostname


# Enable and start SQL Server Agent services
sudo /opt/mssql/bin/mssql-conf set sqlagent.enabled true
systemctl restart mssql-server
systemctl status mssql-server

 

I’m currently working as a SQL server DBA in one of the top MNC. I’m passionate about SQL Server And I’m specialized in Administration and Performance tuning. I’m an active member of SQL server Central and MSDN forum. I also write articles in SQL server Central. For more Click here

Leave a Reply

Your email address will not be published. Required fields are marked *

+ 77 = 80