Install and configure Microsoft SQL server on RHEL/CentOS for vCloud Director

Christian Müller
15. March 2018
Reading time: 3 min
Install and configure Microsoft SQL server on RHEL/CentOS for vCloud Director

[et_pb_section bb_built=”1″][et_pb_row][et_pb_column type=”4_4″][et_pb_text _builder_version=”3.0.105″ background_layout=”light”]

The VMware vCloud Director needs a MSSQL or an Oracle Database server to run. This article will describe how to install a MSSQL Server Express on RHEL/CentOS for testing and developing purposes.

1. Add the MSSQL server repository for RHEL

wget https://packages.microsoft.com/config/rhel/7/mssql-server.repo -O /etc/yum.repos.d/mssql-server.repo 
2. Install the MSSQL Server to your RHEL or CentOS

2. Install Microsoft MSQL server to your RHEL or CentOS

yum install mssql-server –y

3. Run the MSSQL configuration script

/opt/mssql/bin/mssql-conf setup

Select MSSQL Express. Its free and vCloud Director runs fine with it (only test&dev).

If you get this error:

ValueError: unknown locale: UTF-8

Add locales and try again.

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
source ~/.bash_profile

4. Add the MSSQL tools repository for RHEL

wget https://packages.microsoft.com/config/rhel/7/prod.repo -O /etc/yum.repos.d/prod.repo

5. Install MSSQL tools and unixODBC developer package

yum install -y mssql-tools unixODBC-devel

6.  Make the MSSQL command tool (sqlcmd) usable directly in shell

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

7. Now open port 1433 in the integrated firewall or stop the firewall service (firewalld)

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

OR

systemctl stop firewalld
systemctl disable firewalld

8. Connect to your local MSSQL Server using your Credentials

sqlcmd -S 127.0.0.1 -U SA

9. Run the following scripts to create and configure the database. /YOURPATH/ must be owned by the mssql user.

USE [master] 
GO 
CREATE DATABASE [vcloud]ON PRIMARY 
(NAME = N'vcloud', FILENAME = N'/YOURPATH/vcloud.mdf', SIZE = 100MB, FILEGROWTH = 10% ) 
LOG ON 
(NAME = N'vcdb_log', FILENAME = N'/YOURPATH/vcloud.ldf', SIZE = 1MB, FILEGROWTH = 10%) 
COLLATE Latin1_General_CS_AS 
GO


USE [vcloud] 
GO 
ALTER DATABASE [vcloud] SET SINGLE_USER WITH ROLLBACK IMMEDIATE; 
ALTER DATABASE [vcloud] SET ALLOW_SNAPSHOT_ISOLATION ON; 
ALTER DATABASE [vcloud] SET READ_COMMITTED_SNAPSHOT ON WITH NO_WAIT;
ALTER DATABASE [vcloud] SET MULTI_USER; 
GO

10. Create the Service User for vCloud Director and make him owner of the vCloud Database

USE [vcloud]
GO 
CREATE LOGIN [vcloud] WITH PASSWORD = 'vcloudpass', DEFAULT_DATABASE =[vcloud], DEFAULT_LANGUAGE =[us_english], CHECK_POLICY=OFF 
GO 
CREATE USER [vcloud] for LOGIN [vcloud] 
GO

USE [vcloud] 
GO 
sp_addrolemember [db_owner], [vcloud] 
GO

Now you can use this for your vCloud Director. Have fun!

 

 

Sources:

https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-red-hat

http://pubs.vmware.com/vcd-820/topic/com.vmware.ICbase/PDF/vcd_820_install.pdf

[/et_pb_text][/et_pb_column][/et_pb_row][/et_pb_section]