Thursday 21 December 2017

SQL Server 2017 Installation on linux


1.  Introduction


This document is to install and configure  sql server on Rhel server . It provides a step-by-step procedure in configuring of sql server on linux flavor.

2.  Requirements of Packages for Installation on RHEL 7


  • Minimum of 3.25 GB of RAM.
  • Minimum of 4 GB of disk space
  • XFS (default on RHEL) or EXT4 file system
  • Network connectivity to the Internet to download the package
  • 1433 TCP port open on the firewall for SQL Server connections
  • A hostname of less than 15 characters.
  • wget is a required package to run the configuration script.


3.     INSTALL SQL SERVER ON RHEL

  • Connect to the RHEL virtual machine or linux server and log on to the server by keying username and password
  • Switch to root user (superuser)
Step 1:

Su root
Password :*****







  • Download the Microsoft SQL Server Red Hat repository into the RHEL Server

Step 2:

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

Step 3:

install SQL Server on RHEL by using the below command





sudo yum install -y mssql-server



From the above command the required packages and sql server installation will completed as successfully


Step 4:

Once SQL Server installation gets completed successfully, kindly run the configuration script. During the configuration setup, It will ask you to;

  • Select the SQL Server Edition which you want to install
  • Accept the SQL Server License terms
  • Key “sa” password












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



         Once you issue the above command it will ask to choose the edition of the server.
            Like express,standard,entrerprise..so depend on the licence enter the edition
            Then accept the license terms.
            It will prompt for sql server system administrator password.


Step 5:

Now verify, whether the SQL Server instance is running on RHEL Server or not.

      systemctl status mssql-server

Step 6:
  • To allow remote connections, open the SQL Server port on the firewall on RHEL. The default SQL Server port is TCP 1433. If you are using FirewallD for your firewall, you can use the following command;

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

Step 7:
  • Let’s apply the firewall configuration right now on the runtime.
1
               sudo firewall-cmd –reload






4.    INSTALL SQL SERVER COMMAND-LINE TOOLS ON RHEL



The mssql-tools package contains Command Line utilities & Bulk Import-Export utilities. The SQLCMD utility allows users to connect to, send Transact-SQL batches from, and output rowset information from SQL Server instances. The BCP utility bulk copies data between an instance of Microsoft SQL Server and a data file in a user-specified format. Installing SQL Server Tools will also install the Microsoft ODBC driver and all its dependencies by default.



Su – root


Step 1:
Download the Microsoft Red Hat repository configuration file.



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


Step 2:

  • Install the SQL Server Common Line Tools  with the unixODBC developer package run the following command;
  •  

sudo yum install -y mssql-tools unixODBC-devel









During the installation of the tool, it will prompt you to accept the license terms for MSSQL-Tools and Microsoft ODBC driver

  • By default, sqlcmd program is not in your environment variable PATH. So, you can take opt/mssql-tools/bin and add it to the Bash_profile path. Let’s run the below command. This enables you to run the tools without specifying the full path.

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

After the successful installation we need to verify the database connectivity on linux machine using command line tools




sqlcmd -S <Host Name OR IP> -U <Username> -P<P@ssw0rd>


OUT PUT AS BELOW:









5.    Install SQL Server Agent


1
       sudo yum install mssql-server-agent




  • Once you install the SQL Server Agent package successfully, you need to restart the SQL Server to enable the SQL Server Agent.

         sudo systemctl restart mssql-server


  • Reconnect/Refresh the SQL Server instance to check the current status of SQL Server Agent.



Creating database on linux server :

Sqlcmd –s <hostname or ip address> -U sa –Q ‘create database sampledb’

Output :



List of databases on sqlserver.

Command

Sqlcmd –s <hostname> -U sa –p <password>
Ø  Select name from sys.databases
Ø  go



No comments:

Post a Comment

Featured post

Postgres commads

 [oracle@Tesdb ~]$ systemctl status postgresql-15 ● postgresql-15.service - PostgreSQL 15 database server    Loaded: loaded (/usr/lib/system...