Common Installation TasksThese tasks are performed on all DB servers, no matter what role (master or slave) they are to perform. Attach STOREFirst of all, the STORE is connected to the machine, as described here: Mounting STORE - All Linux except for STORE (CentOS8/Win2019) Install MySQLCentOS 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. Translations Ignore |
---|
Code Block |
---|
| # 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 MySQLNext, the MySQL server is configured to autostart on boot, and started up: Translations Ignore |
---|
Code Block |
---|
| systemctl enable mysqld.service
systemctl start mysqld.service |
|
Access to the MySQL Server is configured in the firewall: Translations Ignore |
---|
Code Block |
---|
| firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload |
|
Configuration FilesMySQL 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: Translations Ignore |
---|
Code Block |
---|
| 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. Functional Components of the RoleThe role DATA can be installed on one or more database servers. A setup with only one DATA server is only recommended for installations with a low agent count (< 30) and little or no reporting requirements. |
Function | Description | Access | Count | Redundancy Strategy |
---|
Primary | Alle Schreibzugriffe erfolgen hier. Des weiteren wird hier immer alle funktionellen Routinen ausgeführt, die Daten verändern. Insbesondere die Anrufverteilung erfolgt hier. | Schreiben und Lesen | 1 | Kann durch eine Active/Passive Konfiguration redundant ausgelegt werden |
Reporting | Erstellung komplexer Datenauswertungen. Diese Vorgänge erfordern mitunter ein hohes Maß an Speicher-, Berechnungs- und I/O Ressourcen. | Lesen | 0 - n | In sehr großen Systemen können verschiedene Gruppen Web-Server auf verschiedene Reporting-Slaves aufgeteilt werden. Des weiteren können mehrere Reporting-Slaves als Active/Active Cluster zusammengefasst werden |
Realtime Statistik | Berechnung der Echtzeitstatistiken in kurzen Intervallen für die angemeldeten Benutzer bzw. Supervisoren und Wallboards. | Lesen | 0 - n | In sehr großen Systemen können verschiedene Gruppen Web-Server auf verschiedene Statistik-Slaves aufgeteilt werden. Des weiteren können mehrere Statistik-Slaves als Active/Active Cluster zusammengefasst werden |
Kunden Abfragen | Erstellung kundenspezifischer Datenauswertungen. Die Auslagerung dieser Funktion in einem separaten System dient vor allen der Absicherung des Kernsystems | Lesen | 0 - n | Aus Sicht der Installation haben diese funktionelle Komponenten keine Auswirkungen da eine vollständige lokale (synchronisierte) Fassung der Datenbank auf jedem Server des Verbundes lagert. Die Aufteilung der Funktionen ergibt sich mehr aus Sicht der "Verbraucher" in denen Konfiguriert werden kann, auf welchem Server gegebenenfalls für welche Aufgaben zugegriffen werden kann. So ist es z.B. im Web-Application-Server möglich, die Datenbankanbindung für die Bereiche Primary, Reporting und Realtime separat anzugeben, so dass es möglich ist, diese Rollen auf verschiedene Server aufzuteilen.
Der einzige Aspekt der Installation der durch die Funktionsaufteilung betroffen ist, ergibt sich aus der Tatsache, dass bei einem Verteilen der Funktionen auf verschiedene Server ein entsprechendes MySQL-Replikations-Setup aufgebaut und konfiguriert werden muss. Dadurch ergibt sich, dass die Funktion "Primary" erzwungenermaßen auf einem Replikations-Master läuft, während alle anderen Funktionen auf Replikations-Slaves laufen können.
Eine sehr besondere Art der Konfiguration ist des weiteren ein spezielles Setup in dem zwei Server in einer Master-Master-Replikation zusammengeschlossen werden (die wiederrum beide als Master für weitere Slaves diesenen können). In einer solchen hoch verfügbaren Konfiguration wird nur einer der Master als "Primary" verwendet. Der andere würde üblicherweise als passive Reserve des HA-Clusters dienen. Es bietet sich allerdings an, diese Ressource sinnvoller zu nutzen, in dem der passive Master entweder die "Reporting" oder die "Statistik" Funktion übernimmt. Die Funktionsbezogenen IP-Adressen werden soweit vom HA-Manager verwaltet. Eine solche Konfiguration hat den Vorteil ein hohes Maß an Verfügbarkeit zu bieten, ohne allzu verschwenderisch mit den Ressourcen umzugehen.
Gemeinsame Installationsschritte
Unabhängig von der Funktion die ein DATA Server übernehmen soll, sind erst mal folgende Installationsschritte zu tätigen auf sowohl Master als auch Slave.
Anbinden des Datenbereiches
Datenbereich anbinden, wie auf der Seite Anbindung STORE (Alle Linux ausser STORE) beschrieben.
Installation der Software
Das Einbinden der offiziellen MySQL Software Repositores und die Installation des MySQL-Servers erfolgt mit folgenden Befehlen:
MySQL 8.x
Translations Ignore |
---|
Code Block |
---|
language | bash |
---|
title | MySQL 8.x |
---|
|
yum -y install libaio
yum -y install https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
yum -y install mysql-community-server |
MySQL 5.6
translations-ignore |
---|
Code Block |
---|
language | bash |
---|
title | MySQL 5.6 |
---|
| yumwget -y installP /etc/my.cnf.d http://devcdn.mysqljtel.comde/downloads/getconfigs/mysqljtel-community-release-el6-5.noarch.rpm
yum -y install mysql-community-server |
|
Beide Varianten
Restart Server
Now, the MySQL must be restarted:Der MySQL Server Dienst wird mit folgendem Befehl in die Liste der automatisch startenden Dienste aufgenommen und gestartet.
Translations Ignore |
---|
Code Block |
---|
language | bash |
---|
title | MySQL service autostart |
---|
| chkconfigsystemctl restart mysqld on
service mysqld start |
|
Als nächstes müssen in der Firewall die Port-Freigaben für den MySQL Server Dienst eingetragen und persistent gespeichert werden:
Translations Ignore |
---|
Code Block |
---|
language | bash |
---|
title | Configure firewall |
---|
|
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --reload |
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.
Status |
---|
colour | Red |
---|
title | Caution Password |
---|
|
Translations Ignore |
---|
Code Block |
---|
| mysqladmin -u root -p password '<password>' |
|
The following commands configure the further users required:
Status |
---|
colour | Red |
---|
title | Caution Password |
---|
|
Translations Ignore |
---|
Code Block |
---|
| 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" |
|
Install UDP Plugin
Next, the UDP plugin is installed. This is required for the communication with further software modules in the system, when certain DB changes are made.
The installation is slightly different for master and slave servers.
Installation
Master Server
Translations Ignore |
---|
Code Block |
---|
| 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 |
|
Slave Server
Translations Ignore |
---|
Code Block |
---|
| 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 |
|
Configuration
To configure the plugin, the following commands are executed:
Status |
---|
colour | Red |
---|
title | Caution Password |
---|
|
Um die Konfiguration des MySQL Servers zu vereinfachen, wird nun ein Verzeichnis angelegt, in dem modulare Konfigurationsdateien abgelegt werden können. Damit diese auch vom MySQL Server geladen werden, muss in der Hauptkonfigurationsdatei noch ein Eintrag erfolgenden. Dies erfolgt durch die Eingabe folgender Befehle:
Translations Ignore |
---|
Code Block |
---|
language | bash |
---|
title | Configure MySQL Server |
---|
|
mkdir /etc/my.cnf.d
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
semanage fcontext -a -t mysqld_etc_t "/etc/my\.cnf\.d(/.*)?"
restorecon -R -v /etc/my.cnf.d
|
Diese Befehle erzeugen das Verzeichnis, fügen der Hauptkonfigurationsdatei die Ladeanweisung für die modularen Konfigurationsdateien hinzu, erstellen eine SELINUX-Sicherheitsfreigabe für das neue Konfigurationsverzeichnis und erzeugen die entsprechenden Security-Labels.
Als nächstes wird eine modulare Konfigurationsdatei mit einigen kommentierten relevanten Optimierungseinstellungen eingespielt.
MySQL 8.x
Translations Ignore |
---|
Code Block |
---|
language | bash |
---|
title | Load the basic settings |
---|
|
wget -P /etc/my.cnf.d http://cdn.jtel.de/downloads/configs/jtel-enhanced-8.cnf |
Die Datei /etc/mycnf.d/jtel-enhanced-8.cnf
enthält eine Reihe gut kommentierter Konfigurationsanweisungen mit denen die Funktion des MySQL Server optimiert werden kann. Die meisten dieser Anweisungen sind auskommentiert. Je nach Bedarf sollten diese Parameter mit Vorsicht angepasst werden. Die Standardwerte sollten aber für die meisten Installationen in Ordnung sein.
MySQL 5.6
Translations Ignore |
---|
Code Block |
---|
language | bash |
---|
title | Load the basic settings |
---|
| wgetmysql -P /etc/my.cnf.d http://cdn.jtel.de/downloads/configs/jtel-enhanced.cnf |
|
Die Datei /etc/mycnf.d/jtel-enhanced.cnf
enthält eine Reihe gut kommentierter Konfigurationsanweisungen mit denen die Funktion des MySQL Server optimiert werden kann. Die meisten dieser Anweisungen sind auskommentiert. Je nach Bedarf sollten diese Parameter mit Vorsicht angepasst werden. Die Standardwerte sollten aber für die meisten Installationen in Ordnung sein.
Beide Varianten
Nun muss der MySQL Server neu gestartet werden:
Translations Ignore |
---|
Code Block |
---|
language | bash |
---|
title | Start MySQL Server |
---|
|
service mysqld restart |
Nach dem ersten Start des MySQL Servers müssen nun die Zugangsdaten für den root-Benutzer festgelegt werden.
Da in MySQL ein Benutzerkonto nicht nur aus einem Benutzernamen sondern auch aus eine Herkunftsadresse der Verbindung besteht, muss noch ein weiterer root-Benutzer erzeugt werden, der sich von beliebigen Herkunftsadressen verbinden darf.
MySQL 8.x
MySQL 8.x speichert ein generiertes Passwort für den root Benutzer in der Datei /var/log/mysqld.log
Dieses Passwort muss als erstes extrahiert werden. Da es oft Sonderzeichen enthält, die nicht ohne Weiteres in die Kommandozeile eingegeben werden können, erfolgt die erste Anpassung durch manuelle Eingabe des Passwortes.
Translations Ignore |
---|
Code Block |
---|
language | bash |
---|
title | MySQL 8.x - Create and configure server users |
---|
|
mysqladmin -u root -p password '<password>' |
Anschließend wird folgende Befehlskette eingegeben um den weiteren User zu erstellen:
ACHTUNG: <password> mit den entsprechenden Passwort ersetzen.
Translations Ignore |
---|
Code Block |
---|
language | bash |
---|
title | MySQL 8.x - Create and configure server users |
---|
|
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" |
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'" |
|
Note |
---|
|
The configuration of the UDP plugin must be performed before the server is included in any replication between servers, otherwise replication will fail. The UDP plugin must be installed on all servers. |
In order that the server makes the best use of the RAM available, the configuration file /etc/my.cnf.d/jtel-enhanced-8.cnf must be adapted.
The setting innodb_buffer_pool_size should be adapted to about 3/4 of the available RAM, but a minimum of 3-4 GB should remain for the use of other processes. For Servers with 4 GB RAM, this should not exceed 2 GB.
Translations Ignore |
---|
Code Block |
---|
| # For 4 GB RAM
innodb_buffer_pool_size = 2048M
# 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 |
|
Restart MySQL
Finally, the MySQL server is restarted for the last time, to load all configuration settings
MySQL 5.6
ACHTUNG: <password> mit den entsprechenden Passwort ersetzen.
Translations Ignore |
---|
Code Block |
---|
language | bash |
---|
title | MySQL 5.6 - Create and configure server users |
---|
| 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:
Translations Ignore |
---|
| systemctl restart mysqld.service |
|