Common Installation Tasks
These tasks are performed on all DB servers, no matter what role (master or slave) they are to perform.
Attach STORE
First of all, the STORE is connected to the machine, as described here: Mounting STORE - All Linux except for STORE (CentOS8/Win2019)
Install MySQL
Configure Repositories and Install mysql-community-server
CentOS 8.x comes with some default repositories, which we do not want. These are disabled, and the MySQL repository is installed. Then the MySQL Server is installed.
# Make sure liibaio is on dnf -y install libaio # Disable some default stuff dnf config-manager --disable mysql-connectors-community dnf config-manager --disable mysql-tools-community dnf -y module disable mysql # Install the Oracle MySQL repo and the client dnf -y install https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm dnf -y install mysql-community-server
Start MySQL
Next, the MySQL server is configured to autostart on boot, and started up:
systemctl enable mysqld.service systemctl start mysqld.service
Configure Firewall
Access to the MySQL Server is configured in the firewall:
firewall-cmd --zone=public --add-port=3306/tcp --permanent firewall-cmd --reload
Configure MySQL
Configuration Files
MySQL 8.x creates a configuration directory /etc/my.cnf.d when it installs. The jtel configuration files are stored here, but a reference must be added to this directory so that mysql loads the configuration files.
This is added with the following command:
cat <<EOFF >> /etc/my.cnf # # * IMPORTANT: Additional settings that can override those from this file! # The files must end with '.cnf', otherwise they'll be ignored. # !includedir /etc/my.cnf.d/ EOFF
The next command downloads the main configuration file for the mysql server. This file contains a lot of well commented settings which can be tweaked if required. The main parameter to be changed is the RAM usage of the sever. See below.
wget -P /etc/my.cnf.d http://cdn.jtel.de/downloads/configs/jtel-enhanced-8.cnf
Restart Server
Now, the MySQL must be restarted:
systemctl restart mysqld.service
Configure Users
After the first restart, user access must be setup.
MySQL 8.x saves a generated random password for the root user in the file /var/log/mysqld.log
This password must be extracted. Often, it contains special characters which cannot be input on the command line within a script. For the following command the password is input manually. Note, that <password> refers to the NEW password you want to assign to the root account.
CAUTION PASSWORD
mysqladmin -u root -p password '<password>'
The following commands configure the further users required:
CAUTION PASSWORD
mysql -u root -p<password> -v -e"CREATE USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '<password>'" mysql -u root -p<password> -v -e"GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION" mysql -u root -p<password> -v -e"FLUSH PRIVILEGES"
MySQL 5.6
ACHTUNG: <password> mit den entsprechenden Passwort ersetzen.
mysqladmin -u root password '<password>' mysql -u root -p<password> -v -e"CREATE USER 'root'@'%' IDENTIFIED BY '<password>'" mysql -u root -p<password> -v -e"GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION" mysql -u root -p<password> -v -e"FLUSH PRIVILEGES"
Beide Varianten
Als nächstes wird noch ein zusätzliches Plugin-Modul dem MySQL Server hinzugefügt. Dieses Modul wird ab jtel Software Version 3.06 für die Kommunikation mit weiteren Softwarekomponenten benötigt. Bei Neuinstallationen soll es aber auch dann installiert werden, wenn geplant ist, ältere Revisionen der Software einzuspielen, damit einem späteren Update nichts im Wege steht. Dies erfolgt durch folgende Befehle:
cp /home/jtel/shared/JTELCarrierPortal/Libraries/jtel_udf_udpsend/jtel_udf_udpsend.so /usr/lib64/mysql/plugin/ chown root:root /usr/lib64/mysql/plugin/jtel_udf_udpsend.so chmod 755 /usr/lib64/mysql/plugin/jtel_udf_udpsend.so chcon system_u:object_r:lib_t:s0 /usr/lib64/mysql/plugin/jtel_udf_udpsend.so
cp /home/jtel/shared/JTELCarrierPortal/Libraries/jtel_udf_udpsend/dummy/jtel_udf_udpsend.so /usr/lib64/mysql/plugin/ chown root:root /usr/lib64/mysql/plugin/jtel_udf_udpsend.so chmod 755 /usr/lib64/mysql/plugin/jtel_udf_udpsend.so chcon system_u:object_r:lib_t:s0 /usr/lib64/mysql/plugin/jtel_udf_udpsend.so
Um die zusätzliche Funktion den SQL Prozeduren verfügbar zu machen, muss noch folgender Befehl ausgeführt werden (<password> mit den entsprechenden Passwort ersetzen):
mysql -u root -p<password> -v -e"DROP FUNCTION IF EXISTS udpsend" mysql -u root -p<password> -v -e"CREATE FUNCTION udpsend RETURNS STRING SONAME 'jtel_udf_udpsend.so'"
Wichtiger Hinweis
Die oben aufgelisteten SQL Befehle müssen auf einem Datenbankserver ausgeführt werden, bevor er Teil eines Replikationsverbundes wird. Soll das UDP Plugin auf bestehenden DATA-Server nachgerüstet werden, so muss eine andere Vorgehensweise gewählt werden:
- Das Modul muss auf allen Server des Verbunden (Sowohl Master als auch Slaves) in das Plugin-Verzeichnis kopiert werden (Siehe Code Block "UDP Send Plugin installieren").
- Die Registrierung des Plugins dar nur auf dem Master Server erfolgen. Da der Befehl durch Replikation auch auf den Slaves ausgeführt wird, ist es nicht erforderlich, den Befehl auch dort auszuführen.
ACHTUNG: Wird der Befehl ausgeführt ohne dass das UDP Plugin auf allen Servern des Verbundes vorhanden ist, verursacht dies einen Abbruch der Replikation, der nur durch einen händischen Eingriff repariert werden kann.
Anpassung my.cnf auf RAM des Servers
Damit der Server den zur Verfügung gestellten RAM vollständig nutzt, muss eine Konfiguration angepasst werden mit vi.
Diese Einstellung sollte ca. 3/4 des RAMs des Servers entsprechen, wobei 3-4 GB für mysql und andere Prozesse übrig bleiben sollten.
# For 8 GB RAM innodb_buffer_pool_size = 5120M # For 12 GB RAM innodb_buffer_pool_size = 8192M # For 16 GB RAM innodb_buffer_pool_size = 12288M ... # From 16 GB simply take 3/4 of the RAM
MySQL Neustart
Als letztes wird der MySQL Server neu gestartet, damit alle Einstellungen übernommen werden:
service mysqld restart