Documentation update

This commit is contained in:
Pinga 2023-12-13 19:43:55 +02:00
parent 363b5bf7b0
commit 0e135befc2
2 changed files with 324 additions and 135 deletions

View file

@ -99,140 +99,6 @@ apt install -y mariadb-client mariadb-server php8.2-mysql
mysql_secure_installation mysql_secure_installation
``` ```
#### Replication Setup
1. Configuration of MariaDB Galera Cluster
To begin, you need to configure each node (database server) in your MariaDB Galera cluster. This involves editing the configuration file located at ```/etc/mysql/mariadb.conf.d/60-galera.cnf``` on each server. Below are the steps for each node:
**Master Database Server:**
Access the configuration file: Open ```/etc/mysql/mariadb.conf.d/60-galera.cnf``` for editing.
Apply Configuration: Replace the existing content with the provided settings:
```bash
[mysqld]
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
# Galera Provider Configuration
wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so
# Galera Cluster Configuration
wsrep_cluster_name="galera_cluster"
wsrep_cluster_address="gcomm://node1-ip-address,node2-ip-address,node3-ip-address"
# Galera Synchronization Configuration
wsrep_sst_method=rsync
# Galera Node Configuration
wsrep_node_address="node1-ip-address"
wsrep_node_name="node1"
```
**Second Database Server:**
Configuration File Editing: Similar to the master server, edit ```/etc/mysql/mariadb.conf.d/60-galera.cnf```.
Update Settings: Replace the existing content with:
```bash
[mysqld]
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
# Galera Provider Configuration
wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so
# Galera Cluster Configuration
wsrep_cluster_name="galera_cluster"
wsrep_cluster_address="gcomm://node1-ip-address,node2-ip-address,node3-ip-address"
# Galera Synchronization Configuration
wsrep_sst_method=rsync
# Galera Node Configuration
wsrep_node_address="node2-ip-address"
wsrep_node_name="node2"
```
**Third Database Server:**
Edit Configuration: Again, modify ```/etc/mysql/mariadb.conf.d/60-galera.cnf``` as done for the other servers.
Implement Changes: Replace the configuration settings with:
```bash
[mysqld]
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
# Galera Provider Configuration
wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so
# Galera Cluster Configuration
wsrep_cluster_name="galera_cluster"
wsrep_cluster_address="gcomm://node1-ip-address,node2-ip-address,node3-ip-address"
# Galera Synchronization Configuration
wsrep_sst_method=rsync
# Galera Node Configuration
wsrep_node_address="node3-ip-address"
wsrep_node_name="node3"
```
2. Stopping MariaDB Services
For all three database servers, you need to halt the MariaDB service. This can be done using the following command:
```bash
systemctl stop mariadb
```
3. Initializing the Galera Cluster
Only on the master database server, you will initiate the cluster:
Start the Cluster: Execute ```galera_new_cluster``` to initialize.
Verify Cluster Status: Check the cluster's status with the command:
```bash
mysql -u root -p -e "SHOW STATUS LIKE 'wsrep_cluster_size'"
```
This should return a cluster size of 1.
4. Starting and Verifying Other Nodes
For the remaining nodes, perform the following:
**Second Node:**
Start MariaDB: Use ```systemctl start mariadb```.
Confirm Cluster Status: Execute the same status command as on the master. The cluster size should now be 2.
**Third Node:**
Service Initiation: Again, start MariaDB with ```systemctl start mariadb```.
Status Check: Verify the cluster status. The expected cluster size should be 3.
By following these steps, you will have successfully updated the replication settings for your MariaDB Galera Cluster in Namingo.
#### Tune your MariaDB
[Tune your MariaDB](https://github.com/major/MySQLTuner-perl) [Tune your MariaDB](https://github.com/major/MySQLTuner-perl)
### 2b. Install and configure PostgreSQL: ### 2b. Install and configure PostgreSQL:
@ -257,6 +123,14 @@ postgres=# \q
[Tune your PostgreSQL](https://pgtune.leopard.in.ua/) [Tune your PostgreSQL](https://pgtune.leopard.in.ua/)
### 2c. Database Replication Setup:
For those considering implementing replication in their Namingo installation, it is highly recommended for enhancing data availability and reliability. We have prepared a detailed guide to walk you through the replication setup process. Please refer to our comprehensive guide for setting up and managing replication by following the link: [Replication Setup Guide](replication.md).
### 2d. Database Encryption Setup:
To ensure the security and confidentiality of your data within the Namingo system, implementing database encryption is a crucial step. Database encryption helps protect sensitive information from unauthorized access and breaches. We have compiled an in-depth guide that covers the essentials of database encryption, including key management, best practices, and step-by-step instructions for secure implementation. For a thorough understanding and to begin securing your data, please refer to our detailed guide: [Database Encryption Guide](encryption.md). This resource is designed to equip you with the knowledge and tools necessary for effectively encrypting your database in the Namingo environment.
## 3. Install Adminer: ## 3. Install Adminer:
```bash ```bash
@ -522,7 +396,9 @@ This will initialize and configure the audit trail functionality. This process e
### Setup Backup ### Setup Backup
***TODO*** To ensure the safety and availability of your data in Namingo, it's crucial to set up and verify automated backups. Begin by editing the ```backup.json``` file in the automation directory, where you'll input your database details and specify the SFTP server information for offsite backup storage. Ensure that the details for the database and the SFTP server, including server address, credentials, and port, are accurately entered in two specified locations within the ```backup.json``` file.
Additionally, check that the cronjob for PHPBU is correctly scheduled on your server, as this automates the backup process. You can verify this by reviewing your server's cronjob list. These steps are vital to maintain regular, secure backups of your system, safeguarding against data loss and ensuring business continuity.
### RDE (Registry data escrow) configuration: ### RDE (Registry data escrow) configuration:

313
docs/replication.md Normal file
View file

@ -0,0 +1,313 @@
# Namingo Registry Database Replication
## MariaDB
1. Configuration of MariaDB Galera Cluster
To begin, you need to configure each node (database server) in your MariaDB Galera cluster. This involves editing the configuration file located at ```/etc/mysql/mariadb.conf.d/60-galera.cnf``` on each server. Below are the steps for each node:
**Master Database Server:**
Access the configuration file: Open ```/etc/mysql/mariadb.conf.d/60-galera.cnf``` for editing.
Apply Configuration: Replace the existing content with the provided settings:
```bash
[mysqld]
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
# Galera Provider Configuration
wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so
# Galera Cluster Configuration
wsrep_cluster_name="galera_cluster"
wsrep_cluster_address="gcomm://node1-ip-address,node2-ip-address,node3-ip-address"
# Galera Synchronization Configuration
wsrep_sst_method=rsync
# Galera Node Configuration
wsrep_node_address="node1-ip-address"
wsrep_node_name="node1"
```
**Second Database Server:**
Configuration File Editing: Similar to the master server, edit ```/etc/mysql/mariadb.conf.d/60-galera.cnf```.
Update Settings: Replace the existing content with:
```bash
[mysqld]
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
# Galera Provider Configuration
wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so
# Galera Cluster Configuration
wsrep_cluster_name="galera_cluster"
wsrep_cluster_address="gcomm://node1-ip-address,node2-ip-address,node3-ip-address"
# Galera Synchronization Configuration
wsrep_sst_method=rsync
# Galera Node Configuration
wsrep_node_address="node2-ip-address"
wsrep_node_name="node2"
```
**Third Database Server:**
Edit Configuration: Again, modify ```/etc/mysql/mariadb.conf.d/60-galera.cnf``` as done for the other servers.
Implement Changes: Replace the configuration settings with:
```bash
[mysqld]
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
# Galera Provider Configuration
wsrep_on=ON
wsrep_provider=/usr/lib/galera/libgalera_smm.so
# Galera Cluster Configuration
wsrep_cluster_name="galera_cluster"
wsrep_cluster_address="gcomm://node1-ip-address,node2-ip-address,node3-ip-address"
# Galera Synchronization Configuration
wsrep_sst_method=rsync
# Galera Node Configuration
wsrep_node_address="node3-ip-address"
wsrep_node_name="node3"
```
2. Stopping MariaDB Services
For all three database servers, you need to halt the MariaDB service. This can be done using the following command:
```bash
systemctl stop mariadb
```
3. Initializing the Galera Cluster
Only on the master database server, you will initiate the cluster:
Start the Cluster: Execute ```galera_new_cluster``` to initialize.
Verify Cluster Status: Check the cluster's status with the command:
```bash
mysql -u root -p -e "SHOW STATUS LIKE 'wsrep_cluster_size'"
```
This should return a cluster size of 1.
4. Starting and Verifying Other Nodes
For the remaining nodes, perform the following:
**Second Node:**
Start MariaDB: Use ```systemctl start mariadb```.
Confirm Cluster Status: Execute the same status command as on the master. The cluster size should now be 2.
**Third Node:**
Service Initiation: Again, start MariaDB with ```systemctl start mariadb```.
Status Check: Verify the cluster status. The expected cluster size should be 3.
By following these steps, you will have successfully updated the replication settings for your MariaDB Galera Cluster in Namingo.
## MySQL
Overview
This document outlines the process for setting up a basic master-slave replication in MySQL. Replication enables data from one MySQL database server (the master) to be replicated to one or more MySQL database servers (the slaves).
Prerequisites
- Two or more MySQL servers (version 5.7 or later recommended).
- Network connectivity between the master and slave servers.
- Identical MySQL version on all servers.
- Unique server IDs for each server in the my.cnf or my.ini file.
1. Configure the Master Server
On the master server, edit the MySQL configuration file (typically ```my.cnf``` or ```my.ini```):
```bash
[mysqld]
server-id=1
log_bin=mysql-bin
binlog_do_db=registry
binlog_do_db=registryTransactions
binlog_do_db=registryAudit
```
- ```server-id```: Unique identifier for the master server.
Restart MySQL to apply these changes.
2. Create a Replication User on the Master
Log in to the MySQL master server and create a dedicated user for replication:
```bash
CREATE USER 'replicator'@'%' IDENTIFIED BY 'password';
GRANT REPLICATION SLAVE ON *.* TO 'replicator'@'%';
```
Replace ```'password'``` with a secure password.
3. Obtain Master Status Information
Execute the following command on the master:
```bash
SHOW MASTER STATUS;
```
Note down the File and Position values, as these will be needed when configuring the slave server.
4. Configure the Slave Server
On the slave server, edit the MySQL configuration:
```bash
[mysqld]
server-id=2
relay_log=relay-log
```
- ```server-id```: Unique identifier for the slave server.
Restart MySQL on the slave server.
5. Set up the Slave to Replicate the Master
On the slave server, run the following command:
```bash
CHANGE MASTER TO
MASTER_HOST='master_ip_address',
MASTER_USER='replicator',
MASTER_PASSWORD='password',
MASTER_LOG_FILE='recorded_log_file_name',
MASTER_LOG_POS=recorded_log_position;
```
Replace ```'master_ip_address'```, ```'recorded_log_file_name'```, and ```'recorded_log_position'``` with the actual master server IP address, and the file and position values noted earlier.
6. Start the Slave
Finally, start the replication on the slave:
```bash
START SLAVE;
```
7. Verify Replication
Check the slave status:
```bash
SHOW SLAVE STATUS\G
```
Look for ```Slave_IO_Running``` and ```Slave_SQL_Running``` both being set to Yes.
## PostgreSQL
1. Configure the Primary Server
On the primary server, edit the PostgreSQL configuration file (```postgresql.conf```):
```bash
# Enable WAL (Write-Ahead Logging) archiving
wal_level = replica
archive_mode = on
archive_command = 'cp %p /path_to_wal_archive/%f'
# Set the maximum number of WAL senders
max_wal_senders = 3
# Set the connection timeout for replication connections
wal_sender_timeout = 60s
```
- ```wal_level```: Set to replica to enable enough information for the standby server.
- ```archive_mode``` and ```archive_command```: Configures archiving of WAL files.
- ```max_wal_senders```: The maximum number of concurrent replication connections.
- ```wal_sender_timeout```: The timeout for replication connections.
2. Allow Replication Connections
In ```pg_hba.conf```, add a line to allow connections from the standby server:
```bash
host replication replicator standby_ip_address/32 md5
```
Replace ```standby_ip_address``` with the actual IP address of the standby server.
replicator is the replication user.
3. Create a Replication User
On the primary server, create a user for replication:
```bash
CREATE ROLE replicator REPLICATION LOGIN PASSWORD 'password';
```
4. Initialize the Standby Server
Stop the PostgreSQL service on the standby server.
Use ```pg_basebackup``` to make a base backup of the primary server:
```bash
pg_basebackup -h primary_ip_address -D /var/lib/postgresql/10/main -U replicator -P --wal-method=fetch
```
5. Configure the Standby Server
On the standby server, create a recovery configuration file (```recovery.conf```):
```bash
standby_mode = 'on'
primary_conninfo = 'host=primary_ip_address port=5432 user=replicator password=password'
```
6. Start the Standby Server
Start PostgreSQL on the standby server. It will now start replicating from the primary server.
7. Verify Replication
Check the replication status on the primary server:
```bash
SELECT * FROM pg_stat_replication;
```