-
Notifications
You must be signed in to change notification settings - Fork 0
Classic MySQL Master Slave RHEL8
This document demonstrates how to deploy a classic MySQL master-slave server based on a precompiled MyTopling.
Enterprise version users can contact customer service to obtain precompiled packages, and community version users can refer to Compilation Documentation to compile by themselves.
The demonstration environment of this document uses AlmaLinux 8.6 of the RedHat series to operate on a real machine, and is compatible with Alibaba Cloud Linux 3 and Rocky Linux 8.
uname -a
If it is lower than 5.14, you can use the following command to upgrade:
sudo yum install elrepo-release -y
# Note that after installing the kernel, modify the default kernel and restart
sudo yum -y --disablerepo="*" --enablerepo="elrepo-kernel" install kernel-ml
The command to modify the default start-up kernel:
# View the list of installed kernels
grubby --info=ALL | grep -E "^kernel|^index"
# Modify the default kernel according to the list printed in the previous article, the latest installed kernel is generally 0
grubby --set-default-index=<new_kernel_index>
reboot
sudo bash -c 'echo "<ip_of_master>" mytopling-instance-1.mytopling.in >> /etc/hosts'
sudo bash -c 'echo "<ip_of_slave>" mytopling-instance-2.mytopling.in >> /etc/hosts'
sudo bash -c 'echo "<ip_of_dcompact>" dcompact.mytopling.in >> /etc/hosts'
grep discard /etc/fstab
If the mount does not enable discard, the write operation of the SSD/NVMe disk will be greatly slowed down
sudo setenforce 0
sudo sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
sudo systemctl disable --now firewalld
This chapter (2.x) runs on two MyTopling hosts (hosts where the master database and slave database are located) separately.
# for powertools, RHEL8 needs to configure the corresponding registry to install gflags
sudo yum install yum-utils -y
sudo yum config-manager --set-enabled powertools
sudo yum install libaio gflags libcurl nfs-utils liburing -y
sudo yum install -y snappy zlib bzip2 lz4
Assume /disk1
is the formatted and mounted disk,
execute on mytopling-instance-1
:
mkdir -p /mnt/mynfs/datadir/mytopling-instance-1
execute on mytopling-instance-2
:
mkdir -p /mnt/mynfs/datadir/mytopling-instance-2
Execute on the two hosts separately:
echo "/mnt/mynfs *(rw,async,no_root_squash,fsid=1)" >> /etc/exports
# Increase the number of server threads
sudo sed -i 's|#\[nfsd\]|\[nfsd\]|g' /etc/nfs.conf
sudo sed -i 's/# threads=8/threads=64/g' /etc/nfs.conf
sudo systemctl enable --now nfs-server
Map the shared disk to the corresponding location, which is the same as the program installation location, or mount the disk to /mnt/mynfs
by yourself.
sudo mkdir /mnt/mynfs
# If your disk is not /disk1, replace disk1 with the actual mount location of your nvme disk
# Or you can directly mount the disk to /mnt/mynfs, then you don’t need to add content to fstab
sudo bash -c "echo '/disk1 /mnt/mynfs none defaults,bind 0 0'" >> /etc/fstab
mount -a
Install mytopling
# After running, /mnt/mynfs/opt/ should be the program file of MyTopling
tar xf mytopling-rhel8-haswell.tar.gz -C /mnt/mynfs/opt
There is no need to decompress the installation file on the dcompact server, which directly uses the executable file shared by the instance-1
server.
Execute the following commands in sequence on the dcompact server:
# Run the following command on the computing server
# Install dependencies
sudo yum install yum-utils -y
sudo yum config-manager --set-enabled powertools
sudo yum install libaio gflags libcurl nfs-utils liburing -y
sudo yum install -y snappy zlib bzip2 lz4
Optimize NFS client parameters and mount:
sudo echo "options sunrpc tcp_slot_table_entries=128" >> /etc/modprobe.d/sunrpc.conf
sudo echo "options sunrpc tcp_max_slot_table_entries=128" >> /etc/modprobe.d/sunrpc.conf
sudo sysctl -w sunrpc.tcp_slot_table_entries=128
Deploy the program and mount NFS:
sudo mkdir /mnt/mynfs/opt -p
sudo mkdir /mnt/mynfs/datadir/{mytopling-instance-1,mytopling-instance-2} -p
sudo bash -c 'echo "mytopling-instance-1.mytopling.in:/mnt/mynfs/datadir/mytopling-instance-1 /mnt/mynfs/datadir/mytopling-instance-1/ auto rw,nolock,noac,noatime,nofail,_netdev 0 0" >> /etc/fstab'
sudo bash -c 'echo "mytopling-instance-2.mytopling.in:/mnt/mynfs/datadir/mytopling-instance-2 /mnt/mynfs/datadir/mytopling-instance-2/ auto rw,nolock,noac,noatime,nofail,_netdev 0 0" >> /etc/fstab'
# executable program file
sudo bash -c 'echo "mytopling-instance-1.mytopling.in:/mnt/mynfs/opt /mnt/mynfs/opt/ auto ro,nolock,noac,noatime,nofail,_netdev 0 0" >> /etc/fstab'
sudo mount -a
# Start calculation process
sudo bash /mnt/mynfs/opt/mytopling-deploy/Classic-MySQL-Master-Slave-Replication-Dcompact/start-dcompact.sh
The required parameters have been set in the startup script, and binlog enables the GITD mode.
Execute on the host mytopling-instance-1.mytopling.in
sudo bash /mnt/mynfs/opt/mytopling-deploy/Classic-MySQL-Master-Slave-Replication-Dcompact/enterprise/start-mysqld-instance-1.sh
Execute on the host mytopling-instance-2.mytopling.in
sudo bash /mnt/mynfs/opt/mytopling-deploy/Classic-MySQL-Master-Slave-Replication-Dcompact/enterprise/start-mysqld-instance-2.sh
Directly execute /mnt/mynfs/opt/bin/mysql -uroot -S /var/lib/mysql/mysql.sock
to connect
At this point, the two databases are in the initial state, and the master-slave needs to be manually configured, which is the same as the standard MySQL setting mode.
If the slave library has no longer set downstream, you can modify the parameters in the script to close binlog.