"Linux" "Services" "IaaS" Openstack-pike (2. Build a highly available MySQL database)

Source: Internet
Author: User
Tags documentation percona

1. Introduction

1.1. Official documents:

Database schema: https://docs.openstack.org/ha-guide/shared-database.html

1.2. The Percona XtraDB cluster,5.7 version is used this time

Https://www.percona.com/doc/percona-xtradb-cluster/5.7/index.html

1.3. installation File Download:

https://www.percona.com/downloads/Percona-XtraDB-Cluster-57/LATEST/

or using Yum installation, this article uses Yum to install

Https://www.percona.com/doc/percona-repo-config/yum-repo.html

This also has Docker installation instructions, and so on later in the Docker documentation

Https://www.percona.com/doc/percona-xtradb-cluster/5.7/install/docker.html

2. Installation

Features and Components Machine name Service IP Manage IP Processor cores Ram Storage Note
Mysql PXC HCTJOSMYSQL01 10.30.2.25 172.16.0.25
Mysql PXC HCTJOSMYSQL02 10.30.2.26 172.16.0.26
Mysql PXC HCTJOSMYSQL03 10.30.2.27 172.16.0.27

2.1. Install the Yum source

Yum Install http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm

Although the Epel source has been configured on RHEL7.4, but there are still no errors found for libev.so.4 (), please install it directly using the address below

https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/l/libev-4.15-3.el7.x86_64.rpm

Install the software.

Yum Install percona-xtradb-cluster-57

Don't worry. Start, configure a separate partition to store the database files

Vgcreate vg_mysql/dev/sdblvcreate-n lv_mysql-l +100% freevg_mysqlmkfs.xfs/dev/mapper/vg_mysql-lv_mysql 

Write in/etc/fstab

#Disk for MySQL data/dev/mapper/vg_mysql-lv_mysql    /data_mysql        xfs    defaults    0 0

Re-mount, create two folders within a partition, MySQL and backup

MKDIR-PV/Data_mysqlmount-amkdir-pv/data_mysql/{mysql,backup} 

Modify/ETC/PERCONA-XTRADB-CLUSTER.CONF.D/MYSQLD.CNF

Datadir=/data_mysql/mysql

Get up and try it.

Systemctl start MySQL

Let's see what the code is.

grep ' temporary password '/var/log/mysqld.log

Connect to the database and output the password you just saw

Mysql-u root-p

Added remote access permissions for future management convenience

Mysql> ALTER USER ' root ' @ ' localhost ' identified by ' MySQL '; Query OK, 0 rows affected (0.01 sec) mysql> GRANT all privileges on *. * to [email protected] '% ' identified by ' MySQL "; Query OK, 0 rows affected, 1 warning (0.01 sec) mysql> flush privileges; Query OK, 0 rows affected (0.01 sec)    

SST users also want to add, otherwise the other nodes cannot connect to the master node properly.

mysql> CREATE USER ' sstuser ' @ ' localhost ' identified by ' MySQL '; Query OK, 0 rows affected (0.00 sec) mysql> GRANT RELOAD, LOCK TABLES, PROCESS, REPLICATION CLIENT on *. * to ' Sstuse R ' @ ' localhost '; Query OK, 0 rows affected (0.00 sec) mysql> FLUSH privileges; Query OK, 0 rows affected (0.01 sec)    

Service stopped, ready to configure the cluster

Systemctl stop MySQL

The configuration documentation for the cluster is in this: https://www.percona.com/doc/percona-xtradb-cluster/5.7/configure.html#configure

First modify the/ETC/PERCONA-XTRADB-CLUSTER.CONF.D/WSREP.CNF

[mysqld]# Path to Galera librarywsrep_provider=/usr/lib64/galera3/libgalera_smm.so# Cluster Connection URL contains IPs of nodes#if no IP is found, this implies that a new Cluster needs to be created, #in order to doThat's need to bootstrap this node
#这里可以写域名或者IP地址wsrep_cluster_address =gcomm://hctjosmysql01.hccos.cn,hctjosmysql02.hccos.cn, hctjosmysql03.hccos.cn # in order for Galera to work correctly binlog format should be rowbinlog_format= row# MyISAM Storage eng INE have only experimental supportdefault_storage_engine= innodb# Slave thread to usewsrep_slave_threads= 8 wsrep_log_conflicts# This changes how InnoDB autoincrement locks be managed and is a requirement for galerainnodb_a utoinc_lock_mode=2 # Node IP Address
# This can be written without writing wsrep_node_address=hctjoscontroller01.homecredit.cn # Cluster namewsrep_cluster_name=pxc-cluster- openstack#if wsrep_node_name isn't specified, then system hostname< span> 'll be usedwsrep_node_name=pxc-cluster-openstack-node-1 #pxc_strict_mode allowed Values:disabled, permissive,enforcing,masterpxc_strict_mode= enforcing# SST methodwsrep_sst_method=xtrabackup- v2
# This must be written #authentication for SST methodwsrep_sst_auth= "Sstuser:mysql"

Start the master node

Systemctl start [email protected]

modifying/etc/percona-xtradb-cluster.conf.d/wsrep.cnf on other nodes

Wsrep_node_name=pxc-cluster-openstack-node-2
wsrep_node_address=hctjoscontroller02.homecredit.cn
Wsrep_node_name=pxc-cluster-openstack-node-3
wsrep_node_address=hctjoscontroller03.homecredit.cn

Modify/ETC/PERCONA-XTRADB-CLUSTER.CONF.D/MYSQLD.CNF on other nodes.

[mysqld]server-id=2
[mysqld]server-id=3

Start MySQL on the other

Systemctl start MySQL

Just find a node. Verification

Mysql> Show status like ' Wsrep_cluster_size '; +--------------------+-------+| Variable_name      | Value |+--------------------+-------+| Wsrep_cluster_size | 3     |+--------------------+-------+1 row in Set (0.00 sec)

Note: If the cluster has been started, the primary node down machine wants to rejoin this cluster, the direct start MySQL can

Systemctl start MySQL

If the last node in the cluster is down, the cluster can be started at any one node, and the reboot cluster needs to be executed

Systemctl start [email protected]

"Linux" "Services" "IaaS" Openstack-pike (2. Build a highly available MySQL database)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.