SQL Server High Availability Instances for Linux Quick Start Guide
Introduction
This quick start guide describes how to set up MSSQL HA instance using DxEnterprise on Linux. Using this guide, the user will configure storage for a DxEnterprise Vhost, create the Vhost, and add a SQL instance to the Vhost.
Prerequisites
-
DxEnterprise installed on at least two VMs or bare-metal servers and joined into a cluster. For installation instructions, please reference the DxEnerprise Linux Installation Quick Start Guide.
-
Microsoft SQL Server installed on each VM. For information about installing SQL Server on Linux, please reference: Microsoft - SQL Server Linux Setup.
-
An additional VM for iSCSI storage.
Configure the iSCSI Initiator
DxEnterprise supports any storage that is SCSI-3 Persistent Reservation compliant. These steps will guide the user through configuring an iSCSI Initiator so its storage will be presented to the servers (nodes) in the DxEnterprise cluster.
Please ensure proper presentation of storage to nodes. If there is storage that is not managed by this DxEnterprise cluster presented to the nodes, it is possible to overwrite or corrupt the data held on that storage.
- Red Hat/CentOS
- Ubuntu
- SLES
-
Enable the iSCSI initiator.
systemctl enable iscsi
-
Open the service configuration file with a text editor such as
nano
orvim
.vim /usr/lib/systemd/system/iscsi.service
-
Modify the lines
ExecStart=/sbin/iscsiadm -m node --loginall=automatic
andExecReload=-/sbin/iscsiadm -m node --loginall=automatic
, replacing--loginall=automatic
with-l
in both lines.
-
Install and enable the iSCSI initiator.
apt install -y open-iscsi
systemctl enable open-iscsi -
Open the service configuration file with a text editor such as
nano
orvim
.vim /lib/systemd/system/open-iscsi.service
-
Modify the line
ExecStart=/sbin/iscsiadm -m node --loginall=automatic
, replacing--loginall=automatic
with-l
.[Unit]
Description=Login to default iSCSI targets
Documentation=man:iscsiadm(8) man:iscsid(8)
Wants=network-online.target remote-fs-pre.target
After=network-online.target iscsid.service
Before=remote-fs-pre.target
DefaultDependencies=no
Conflicts=shutdown.target
Before=shutdown.target
# Must have some pre-defined targets to login to
ConditionDirectoryNotEmpty=|/etc/iscsi/nodes
# or have a session to use via iscsid
ConditionDirectoryNotEmpty=|/sys/class/iscsi_session
[Service]
Type=oneshot
RemainAfterExit=true
# iscsiadm --login will return 21 if no nodes are configured,
# and 15 if a session is alread logged in (which we do not
# consider an error)
SuccessExitStatus=15 21
# Note: iscsid will be socket activated by iscsiadm
ExecStart=/sbin/iscsiadm -m node -l
ExecStart=/lib/open-iscsi/activate-storage.sh
ExecStop=/lib/open-iscsi/umountiscsi.sh
ExecStop=/bin/sync
ExecStop=/lib/open-iscsi/logout-all.sh
[Install]
WantedBy=sysinit.target
Alias=iscsi.service
-
Install and enable the iSCSI initiator.
zypper install open-iscsi
systemctl enable open-iscsi
Obtain the IP address of the iSCSI initiator using a command such as ip addr
before proceeding to the next section.
Configure iSCSI Target for All Nodes
Run the following commands on every node participating in the DxEnterprise cluster:
-
Discover the storage, replacing
<target>
with the IP of the initiator.iscsiadm -m discovery -t sendtargets -p <target_ip>
-
Log into the target.
iscsiadm -m node -login
-
Locate the new storage device's path.
iscsiadm -m session -P3
infoThe attached disk should be visible at or near the bottom of the output. For example:
Attached scsi disk sdb State: running
Configure the Disks in DxEnterprise
DxEnterprise leverages native file system (NTFS/ext4/xfs) and shared storage technology to coordinate access to a pool of disk resources in the cluster. Managing a disk puts that disk under DxEnterprise control.
-
After the shared disks are configured on each node, manage the disks using DxEnterprise. To manage a disk, use the command
dxcli add-disk
.tipThe command
dxcli get-disks
can be used to look up adisk_id
of interest.Example
dxcli add-disk 50842140-be32-d3a7-45d4-3999bf3ad3a8 "Cluster Disk 1"
-
Create a volume on the managed disk using the command
dxcli create-volume
.Example
dxcli create-volume 50842140-be32-d3a7-45d4-3999bf3ad3a8,1073741824
-
Format a volume on the managed disk using the command
dxcli format-volume
.tipThe command
dxcli get-disk-detail <disk_label>
may be used to look up a volume ID of interest.Example
dxcli format-volume 3409ed39-60c1-4f49-8186-dfface26e2a1 EXT4 Volume1 4096 quick_format:true compression:false
-
Assign a mount point to the volume using the command
dxcli set-mountpoint
.Example
dxcli set-mountpoint 3409ed39-60c1-4f49-8186-dfface26e2a1 /mnt/volume1
Configure the Vhost
DxEnterprise uses Virtual Hosts (Vhosts) to provide failover support and high availability. A Vhost virtualizes the network name and IP address associated to a particular SQL Server Instance, file share, and/or service. Instead of using the network name and IP address of a physical server, a Vhost is created and assigned a unique name/virtual IP-address pair. Clients access the databases associated with an instance via the Vhost name or IP address; they do not need to know which node is running the SQL instance.
-
To add a Vhost to the DxEnterprise cluster, use the command
dxcli cluster-add-vhost
.cautionWhen a Vhost is configured, the user will need to specify at least one node to participate in the Vhost. It is recommended to create A and PTR records for each Vhost in DNS for resolution as well as add Vhost entries to each node’s local hosts file.
Example
dxcli cluster-add-vhost vhost1 192.168.1.10 dxemssql1,dxemssql2
-
Assign the disks to the Vhost using the command
dxcli vhost-set-diskgroup
.infoA diskgroup is a logical set of disks that are added to a Vhost. When a disk is added to a Vhost diskgroup, the disk will be set online on the active node and offline on all other nodes. If there is a failure of a disk within the diskgroup, the Vhost will failover onto the next available node in the cluster.
Example
dxcli vhost-set-diskgroup VHOST1 50842140-be32-d3a7-45d4-3999bf3ad3a8
-
OPTIONAL: Encrypt the SQL Server sysadmin password for DxEnterprise using the
dxcli encrypt-text
. The encrypted password will be used to add the SQL instance in the next step.Example
dxcli encrypt-text p@ssw0rd
-
Add a SQL instance to the Vhost using the command
dxcli add-instance
.infoAssigning a SQL Server instance to a Vhost creates a managed instance. When a SQL Server instance is added to a Vhost, DxEnterprise virtualizes the network name and IP address associated with the SQL Server instance creating a Virtual SQL Server instance. Clients can then access the Virtual SQL Server instance via the Vhost\instance name.
Example
dxcli add-instance vhost1\mssqlserver 1433 /mnt/volume1/data /mnt/volume1/log sa 6pnFaDrRS+W/F+dkRuPKAA==