strutture:lnf:dr:calcolo:sistemi:galera_custer_installation
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
strutture:lnf:dr:calcolo:sistemi:galera_custer_installation [2015/11/26 18:17] – tota@infn.it | strutture:lnf:dr:calcolo:sistemi:galera_custer_installation [2023/07/19 09:23] (current) – rorru@infn.it | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ===== Galera Cluster MariaDB Installation ===== | ||
+ | {{: | ||
+ | |||
+ | === Cluster details === | ||
+ | We using 3 freshly deployed VMs running a minimal install of **CentOS 7** x86_64 | ||
+ | |||
+ | * Cluster node 1 has hostname **HOST_G** and IP address **IP_HOST_G** | ||
+ | * Cluster node 2 has hostname **HOST_L** and IP address **IP_HOST_L** | ||
+ | * Cluster node 3 has hostname **HOST_F** and IP address **IP_HOST_F** | ||
+ | |||
+ | The cluster is reachable throught the load balancer miracle.lnf.infn.it with ip address 193.206.84.215. | ||
+ | |||
+ | === Add MariaDB Repositories === | ||
+ | Create a mariadb repository / | ||
+ | |||
+ | < | ||
+ | # cat > / | ||
+ | </ | ||
+ | |||
+ | Insert the following directives: | ||
+ | |||
+ | < | ||
+ | # MariaDB 10.1 CentOS repository list - created 2015-10-14 13:45 UTC | ||
+ | # http:// | ||
+ | [mariadb] | ||
+ | name = MariaDB | ||
+ | baseurl = http:// | ||
+ | gpgkey=https:// | ||
+ | gpgcheck=1 | ||
+ | </ | ||
+ | |||
+ | terminate by the [Enter] key. To save and exit press [CTRL]+[d] keys. | ||
+ | |||
+ | === Install MariaDB Galera Cluster === | ||
+ | |||
+ | Install the MariaDB Galera Cluster by executing the following command on all nodes: | ||
+ | |||
+ | < | ||
+ | # yum install MariaDB-server MariaDB-client rsync galera | ||
+ | </ | ||
+ | |||
+ | Start the mariadb service and enables the service to be started on boot: | ||
+ | |||
+ | < | ||
+ | # systemctl start mariadb | ||
+ | # systemctl enable mariadb | ||
+ | </ | ||
+ | |||
+ | Run the mysql_secure_installation script so we can improve the security. Run the following command on all nodes: | ||
+ | |||
+ | < | ||
+ | # / | ||
+ | </ | ||
+ | |||
+ | we don’t set the root password and we accept all defaults. | ||
+ | |||
+ | === Create MariaDB Galera Cluster users === | ||
+ | |||
+ | Now, we create the database user. The '' | ||
+ | |||
+ | On the **HOST_G** node run the following command: | ||
+ | < | ||
+ | # mysql | ||
+ | mysql> GRANT USAGE ON *.* to sst_user@'< | ||
+ | mysql> GRANT USAGE ON *.* to sst_user@'< | ||
+ | mysql> GRANT ALL PRIVILEGES on *.* to sst_user; | ||
+ | mysql> FLUSH PRIVILEGES; | ||
+ | mysql> quit | ||
+ | </ | ||
+ | |||
+ | On the **HOST_L** node run the following command: | ||
+ | < | ||
+ | # mysql | ||
+ | mysql> GRANT USAGE ON *.* to sst_user@'< | ||
+ | mysql> GRANT USAGE ON *.* to sst_user@'< | ||
+ | mysql> GRANT ALL PRIVILEGES on *.* to sst_user; | ||
+ | mysql> FLUSH PRIVILEGES; | ||
+ | mysql> quit | ||
+ | </ | ||
+ | |||
+ | Finally, on the **HOST_F** node run the following command: | ||
+ | < | ||
+ | # mysql | ||
+ | mysql> GRANT USAGE ON *.* to sst_user@'< | ||
+ | mysql> GRANT USAGE ON *.* to sst_user@'< | ||
+ | mysql> GRANT ALL PRIVILEGES on *.* to sst_user; | ||
+ | mysql> FLUSH PRIVILEGES; | ||
+ | mysql> quit | ||
+ | </ | ||
+ | |||
+ | === Create the MariaDB Galera Cluster config === | ||
+ | First stop the mariadb services on all nodes: | ||
+ | |||
+ | < | ||
+ | # systemctl stop mariadb | ||
+ | </ | ||
+ | |||
+ | Next, We are going to create the MariaDB Galera Cluster configuration by the following command on all nodes: | ||
+ | |||
+ | < | ||
+ | # vi / | ||
+ | </ | ||
+ | |||
+ | Insert in the [mariadb-10.1] section the following directives: | ||
+ | |||
+ | < | ||
+ | binlog_format=ROW | ||
+ | default-storage-engine=innodb | ||
+ | innodb_autoinc_lock_mode=2 | ||
+ | innodb_locks_unsafe_for_binlog=1 | ||
+ | query_cache_size=1M | ||
+ | query_cache_type=OFF | ||
+ | bind-address=0.0.0.0 | ||
+ | datadir=/ | ||
+ | innodb_log_file_size=100M | ||
+ | innodb_file_per_table | ||
+ | innodb_flush_log_at_trx_commit=2 | ||
+ | wsrep_provider=/ | ||
+ | wsrep_cluster_address=" | ||
+ | wsrep_cluster_name=' | ||
+ | wsrep_node_address='< | ||
+ | wsrep_node_name='< | ||
+ | wsrep_sst_method=rsync | ||
+ | wsrep_sst_auth=sst_user: | ||
+ | enforce_storage_engine=' | ||
+ | wsrep_on=ON | ||
+ | sql_mode='' | ||
+ | </ | ||
+ | |||
+ | Adjust the '' | ||
+ | |||
+ | On **HOST_L** node: | ||
+ | < | ||
+ | wsrep_node_address='< | ||
+ | wsrep_node_name='< | ||
+ | </ | ||
+ | |||
+ | On **HOST_F** node: | ||
+ | < | ||
+ | wsrep_node_address='< | ||
+ | wsrep_node_name='< | ||
+ | </ | ||
+ | |||
+ | === Initialize the first cluster node HOST_G === | ||
+ | |||
+ | Start MariaDB with the special '' | ||
+ | |||
+ | < | ||
+ | # systemctl set-environment MYSQLD_OPTS=" | ||
+ | # systemctl start mariadb | ||
+ | # systemctl unset-environment MYSQLD_OPTS | ||
+ | </ | ||
+ | |||
+ | Check cluster status by run the following command on the node: | ||
+ | |||
+ | < | ||
+ | # mysql | ||
+ | mysql > show status like ' | ||
+ | </ | ||
+ | |||
+ | === Add the other cluster nodes === | ||
+ | Start MariaDB on the other cluster node executing the follow command: | ||
+ | |||
+ | < | ||
+ | # systemctl start mariadb | ||
+ | </ | ||
+ | |||
+ | === Add disk and create logical partitions === | ||
+ | Using oVirt, add disk on each node of the cluster with the following size: | ||
+ | * HOST_G: 150GB (100GB to databases and 50GB to backup) | ||
+ | * HOST_L: 150GB (100GB to databases and 50GB to backup) | ||
+ | * HOST_F: 220GB (100GB to databases and 120GB to snapshot and backup) | ||
+ | |||
+ | You can find target partition name typing: | ||
+ | |||
+ | < | ||
+ | # cat / | ||
+ | </ | ||
+ | |||
+ | (in this case ''/ | ||
+ | |||
+ | First create a physical volumes that will be used to create the LVM: | ||
+ | |||
+ | < | ||
+ | # pvcreate /dev/vdb | ||
+ | </ | ||
+ | |||
+ | Then create a volume group with name '' | ||
+ | < | ||
+ | # vgcreate data /dev/vdb | ||
+ | </ | ||
+ | |||
+ | On all nodes create a logical volume named '' | ||
+ | |||
+ | < | ||
+ | # lvcreate -L 100GB -n db data | ||
+ | </ | ||
+ | |||
+ | Build XFS filesystem on ''/ | ||
+ | |||
+ | < | ||
+ | # mkfs.xfs / | ||
+ | </ | ||
+ | |||
+ | Stop mariadb service: | ||
+ | |||
+ | < | ||
+ | # systemctl stop mariadb | ||
+ | </ | ||
+ | |||
+ | Mount ''/ | ||
+ | |||
+ | < | ||
+ | # mount / | ||
+ | </ | ||
+ | |||
+ | Move all files and folders in ''/ | ||
+ | |||
+ | < | ||
+ | # mv / | ||
+ | </ | ||
+ | |||
+ | Make the user '' | ||
+ | |||
+ | < | ||
+ | # chown mysql:mysql /mnt/ | ||
+ | </ | ||
+ | |||
+ | Umount ''/ | ||
+ | |||
+ | < | ||
+ | # umount /mnt/ | ||
+ | </ | ||
+ | |||
+ | Change ''/ | ||
+ | |||
+ | < | ||
+ | # vi /etc/fstab | ||
+ | </ | ||
+ | |||
+ | append the following content: | ||
+ | |||
+ | < | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | NOTE: The importance of the noatime setting is that it eliminates the need by the system to make writes to the file system for files which are simply being read. | ||
+ | |||
+ | Mount all filesystems mentioned in fstab: | ||
+ | |||
+ | < | ||
+ | # mount -a | ||
+ | </ | ||
+ | |||
+ | Start mariadb service: | ||
+ | |||
+ | < | ||
+ | # systemctl start mariadb | ||
+ | </ | ||
+ | |||
+ | == Logical partition to backup and snapshot == | ||
+ | |||
+ | HOST_F is the node designed to backup. The 220GB are assigned as follows: | ||
+ | * 100GB to database | ||
+ | * 100GB to databases backup | ||
+ | * 10GB to snapshot | ||
+ | * 10GB can be used to extend previous logical volumes | ||
+ | |||
+ | The firsts 100GB are assigned to the databases as shown in the previous section. | ||
+ | |||
+ | |||
+ | |||
+ | If HOST_F is down, HOST_L (or HOST_G) is allowed to become a responsable node to backup. So we prepare 50GB to database backup on HOST_G and HOST_L and 100GB on HOST_F. | ||
+ | |||
+ | Create a logical volume named **backup** on **data** volume group with 100GB size on HOST_F: | ||
+ | |||
+ | < | ||
+ | # lvcreate -L 100GB -n backup data | ||
+ | </ | ||
+ | |||
+ | and with max available free size to HOST_G anf HOST_L: | ||
+ | |||
+ | < | ||
+ | # lvcreate -l 100%FREE -n backup data | ||
+ | </ | ||
+ | |||
+ | Build XFS filesystem on ''/ | ||
+ | |||
+ | < | ||
+ | # mkfs.xfs / | ||
+ | </ | ||
+ | |||
+ | Create ''/ | ||
+ | |||
+ | < | ||
+ | # mkdir -p / | ||
+ | </ | ||
+ | |||
+ | Only on HOST_F create a snapshot logical volume that is 10GB in size named ''/ | ||
+ | |||
+ | < | ||
+ | # lvcreate -L 10G -n db-snap -s / | ||
+ | </ | ||
+ | |||
+ | Create ''/ | ||
+ | |||
+ | < | ||
+ | # mkdir / | ||
+ | </ | ||
+ | |||
+ | Append the following content to ''/ | ||
+ | |||
+ | < | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | On HOST_F append also: | ||
+ | |||
+ | < | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | Mount all filesystems mentioned in fstab: | ||
+ | |||
+ | < | ||
+ | # mount -a | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | === Backup === |