AntDB Installation and Deployment Documentation - P1
Tags: database
Published: 2023-07-11 10:28:42

## Revision History

| Version| Revision Notes| Date| Author
|----------|----------|----------|----------
| v1.0| First draft, based on AntDB version 6.3.2| 2022-8-23| Shanshan Ma / Zhishu Yin / Xiuming Yu
| v1.1| Add section on installation using tarball| 2022-12-26| Pu Qun
| | | | 

## Overview

The node types of AntDB cluster are gtmcoord (master and slave), coordinator, datanode (master and slave). ADBMGR is the cluster management node of AntDB, users can use this node to finish the cluster installation and deployment after installing and deploying ADBMGR. There are mainly five major steps.

* add host is to add all the host information in the cluster to the host table, which exists in ADBMGR to facilitate the management of cluster hosts.
* deploy deploys the binaries to all hosts in the cluster.
* start agent starts the agent process on the hosts, one agent per host.
* add node adds all nodes in the cluster (including gtmcoord, coordinator, datanode) to the node table, which exists on ADBMGR to facilitate the management of all types of nodes in the cluster.
* init all initializes the cluster, and once the initialization is complete, users can log in to the cluster to perform operations.

The following will introduce the installation and deployment of AntDB in detail, starting from the environment preparation.

## Pre-installation Preparation

This section introduces the hardware devices and operating system that need to be prepared before installing AntDB.

### Operating System

This section introduces the common operating system versions that AntDB is compatible with.

| Operating System Versions| Description
|----------|----------
| Red Hat Enterprise Linux| 7.5 and above
| CentOS| 7.5 and above
| Ubuntu| 16.04 and above

### Hardware Environment

This section describes the hardware configuration required to install AntDB.

| Basic Environment| Configuration Contents
|----------|----------
| CPU| Recommended not less than 16 cores
| Physical Memory| More than 32G
| Hard disk remaining space| 10% redundancy according to actual business needs

### Installation files

Please obtain the installation package from the delivery person.

## Linux Environment Configuration

This section describes the configuration of the Linux system before installing AntDB, including user creation, dependency installation, and system parameter adjustment.

### User Configuration

#### New User Creation

Create a new normal user, such as uatadb, on all hosts where AntDB is to be installed (or use an existing normal user). New user reference For example:

```
useradd -d /home/uatadb uatadb
passwd uatadb
```

#### Configure the user limit parameters

Edit the /etc/security/limits.conf file and configure the antdb user parameters.

```
antdb soft nproc 65536
antdb hard nproc 65536
antdb soft nofile 278528
antdb hard nofile 278528
antdb soft stack unlimited
antdb soft core unlimited
antdb hard core unlimited
antdb soft memlock 250000000
antdb hard memlock 250000000
```

After saving the file, execute su - antdb to switch to antdb user and execute ulimit -a to check if it takes effect.

#### Configure user sudo privileges

If security allows, it is recommended to add sudo privileges to the antdb user. Execute visudo for the root user to edit the interface, find the line where Allow root to run any commands anywhere, and add below the line.

```
antdb ALL=(ALL) ALL
```

Save the file and exit. su - antdb Switch to the antdb user and execute sudo id. Expect to be prompted for the user password and the output will be

```
uid=0(root) gid=0(root) groups=0(root)
```

indicates that sudo privileges were added successfully.

### System parameter adjustment

#### Turn off the firewall

Using the centos 7 operating system as an For example:

1.Disable the firewall service.

```
systemctl stop firewalld.service
```

2.Disabling the firewall self-start service.

```
systemctl disable firewalld.service
```

3.Checking the firewall status.

```
systemctl status firewalld.service
```

#### Shut down numa and tuned

Take redhat/centos 7 system as an example:

1.Shut down numa.

```
grubby --update-kernel=ALL --args="numa=off " # This command modifies this file:
```

```
/etc/grub2.cfg
grub2-mkconfig
```

2.Shut down the tuned service.

```
systemctl stop tuned
systemctl disable tuned
```

3.Reboot the host after the changes in this way take effect.

```
reboot
```

4.Verify the cmdline of grub after rebooting.

```
cat /proc/cmdline
```

5.Check numa

```
numactl --hardware
```

The expected result is Available: 1 nodes (0)

#### Turn off Transparent Huge Pages

The use of Transparent Huge Pages (THP for short) can cause performance problems, so it is recommended to turn them off.

1.Check the on status of Transparent Huge Pages.

```
cat /sys/kernel/mm/transparent_hugepage/enabled
```

If the result is \[always] madvise never, then Transparent Huge Pages is on and needs to be turned off; if the result is always madvise \[never], then Transparent Huge Pages is off and this step is skipped; 

2.Turn off Transparent Huge Pages.

```
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag Check Transparent Large Page Open Status
```

3.Check again that the Transparent Big Page is on.

```
cat /sys/kernel/mm/transparent_hugepage/enabled
```

#### Configure sysctl.conf

1.Modify the sysctl.conf file.

```
cat >> /etc/sysctl.conf << EOF
# add for antdb
kernel.shmmax=137438953472 137438953472
kernel.shmall=53689091
kernel.shmmni=4096
kernel.msgmnb=4203520
kernel.msgmax=65536
kernel.msgmni=32768
kernel.sem=501000 641280000 501000 12800

fs.aio-max-nr=6553600
fs.file-max=26289810
net.core.rmem_default=8388608
net.core.rmem_max=16777216
net.core.wmem_default=8388608
net.core.wmem_max=16777216
net.core.netdev_max_backlog=262144
net.core.somaxconn= 65535
net.ipv4.tcp_rmem=8192 87380 16777216
net.ipv4.tcp_wmem=8192 65536 16777216
net.ipv4.tcp_max_syn_backlog=262144
net.ipv4.tcp_keepalive_time=180
net.ipv4.tcp_keepalive_intvl=10
net.ipv4.tcp_keepalive_probes=3
net.ipv4.tcp_fin_timeout=1
net.ipv4.tcp_synack_retries=1
net.ipv4.tcp_syn_retries=1
net.ipv4.tcp_syncookies=1
net.ipv4.tcp_timestamps=1
net.ipv4.tcp_tw_recycle=1
net.ipv4.tcp_tw_reuse=1
net.ipv4.tcp_max_tw_buckets=256000
net.ipv4.tcp_retries1=2
net.ipv4.tcp_retries2=3
vm.dirty_background_ratio=5
vm.dirty_expire_centisecs=6000
vm.dirty_writeback_centisecs=500
vm.dirty_ratio=20
vm.overcommit_memory=0
vm.overcommit_ratio= 120
vm.vfs_cache_pressure = 100
vm.swappiness=10
vm.drop_caches = 2
vm.min_free_kbytes = 2048000
vm.zone_reclaim_mode=0
kernel.core_uses_pid=1
kernel.core_pattern= /data/antdb/core/core-%e-%p-%s-%t
fs.suid_dumpable=1
kernel.sysrq=0
EOF
```

The path of kernel.core\_pattern needs to be modified according to the actual environment information. 

2.execute the following command to make the above parameters effective.

```
sysctl -p
```