Installing SQL Server Agent on Ubuntu Server
In a previous tip I explained how to install SQL Server vNext on Ubuntu Linux server. Please have a look to get the background of SQL Server running on Ubuntu. Here I will explain how to install SQL Server Agent on an Ubuntu server, so that we can create SQL Server Agent Jobs to schedule repetitive tasks.
Recently, Microsoft released the updated version of SQL Server vNext CTP for Linux based operating systems. The latest version for SQL Server vNext is CTP 1.4. This update of SQL Server brings SQL Server Agent support to make a DBA's life easy. You can get the full list of features supported and learn about known issues of this version from this Microsoft link: SQL Server on Linux Release Notes.
SQL Server Agent Installation on Ubuntu Server
Before going ahead, you need to have SQL Server vNext running on an Ubuntu Server where we will install SQL Server Agent. I have followed the step by step method from Microsoft's online documentation to understand this installation. Let's start the SQL Server Agent installation on the Ubuntu Server.
Step 1: First, connect to the Ubuntu Server either using PuTTY or directly login to the Ubuntu server using a valid username and password. I used PuTTY to connect to the server.
You can see we have connected to our target machine where we are going to install SQL Server Agent.
Step 2: As per Microsoft, we need to have SQL Server CTP 1.4 to install SQL Server Agent whereas our SQL Server vNext is still running on CTP1.1. So first we need to upgrade to CTP 1.4 which configures the keys and repositories that we need when we install the mssql-server-agent package. Let's check the existing version of SQL Server installed on our Ubuntu server.
Step 3: We can see the version installed on this Ubuntu server is CTP 1.1, so we will start the upgrade process to bring this SQL Server to CTP 1.4 in order to install SQL Server Agent.
We will run the "sudo apt-get update" command to resynchronize the package index files from the their sources specified in /etc/apt/sources.list file. The update command fetched the packages from their locations and updates the packages to the newer version. Run the below command to update the source list.
#resynchronize the package index files sudo apt-get update
Execution will start with a series of package updates. Once execution is successful, the next step is to install the latest update of SQL Server vNext.
Step 4: Now we will upgrade SQL Server vNext to bring it to version CTP 1.4. Run the below command to start the process. This command will download the newest package and replace the binaries located under /opt/mssql/. The user generated databases and system databases will not be affected by this operation, but make sure to keep a backup of everything hosted on your SQL Server to be safe.
#Upgrade SQL Server sudo apt-get install mssql-server
Once the above command executes successfully we can check the latest version of SQL Server.
You can see the SQL Server version has now changed to CTP 1.4 in the below picture. Our next step is to install SQL Server Agent on this box.
Step 5: In order to install SQL Server Agent on your Ubuntu server, first you need to run "sudo apt-get update" to resynchronize the package index files from the their sources. As I have already updated these files, it is not mandatory for me to perform this action, but if you are already running with SQL Server vNext 1.4 version then you should run this command to get the latest files. Run the below command if you have not updated the package repositories.
sudo apt-get update
The apt-get update downloads the package lists from the repositories and "updates" them to get information on the newest versions of packages and their dependencies.
Step 6: Once the above command executes successfully, the next step is to install SQL Server Agent on Ubuntu. Run the below command to kick off the SQL Server Agent installation on this machine.
#Install SQL Server Agent sudo apt-get install mssql-server-agent
Once you press enter to execute the above command, the execution process will start to install the package. Once installation is successful, you will get the below screen to proceed with the next step.
You can notice there is an instruction showing in the dashed rectangle box in the above screenshot that says "Please restart mssql-server to enable Microsoft SQL Server Agent". So our next step is to restart this service to complete the installation.
Step 7: Run the below command to restart the SQL Server service and then check the status of this service to validate the restart step.
#Restart SQL Server service systemctl restart mssql-server #check the status of mssql-server service. systemctl status mssql-server
After the SQL Server service status has been restarted, we are done with the SQL Server Agent installation on the Ubuntu server. Now go ahead and configure SQL Server Agent Jobs on SQL Server vNext. In my next article, I will explain how to create jobs.
Step 8: If you want to validate that SQL Server Agent is running on this server, you can connect to the SQL Server instance using SSMS and expand the SQL Server Agent folder. You will see all SQL Server Agent subfolders as shown below.
- The next step is to start configuring SQL Server Agent Jobs as per your needs.
- I will explain the step by step process of SQL Server Agent job creation on a Linux server in my next tip.
- Explore more knowledge on SQL Server Database Administration Tips.
Last Updated: 2017-04-25
About the author
View all my tips