Installing MySQL InnoDBCluster on CentOS 7
From rdkwiki
Contents
Intro
The steps below will configure a working MySQL 5.7 InnoDB cluster with 3 nodes. The steps assume that you have 4 (fresh) CentOS 7 servers running.
Make MySQL available for installation
!! This step will replace CentOS's default MariaDB
- rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm --> Make MySQL 5.7 available for installation
Installing MySQL
- yum install mysql-server --> install the MySQL server
- yum install mysql-shell --> install the MySQL Shell
- systemctl start mysqld --> start the MySQL server
- systemctl status mysqld --> check if the MySQL server is running
- systemctl enable mysqld --> make the MySQL server start at boot
disable SELINUX
- sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config --> disabled SELINUX at startup
- setenforce 0 --> disable SELINUX without reboot
Securing MySQL
- grep "temporary password" /var/log/mysqld.log --> get the random password that is generated during the MySQL 5.7 installation
- mysql_secure_installation --> default script with a few questions to harden the MySQL security
- mysql -h localhost -u root -p --> connect with the new password from the previous step
- create user '<user>'@'<ip/subnet>' identified by '<password>'; --> here you can use wildcards for the ip/subnet (for example: '192.168.0.%' or '%' for all hosts)
- grant all privileges on *.* to '<user>'@'<ip/subnet>' with grant option; --> give the new user all rights
- flush privileges; --> reload all privileges
Firewall configuration
- firewall-cmd --permanent --add-service=mysql --> add MySQL service to firewall
- firewall-cmd --permanent --add-port=13306/tcp --> add MySQL InnoDB Cluster port to firewall
- firewall-cmd --reload --> reload firewall with changed configuration
Configure all nodes for cluster
- mysqlsh --uri myroot@localhost:3306 --> Connect MySQL Shell to the LOCAL MySQL instance on each node.
- dba.configureLocalInstance('myroot@localhost:3306') --> configure the node for the cluster.
Cluster creation
- mysqlsh --uri myroot@node1.test.local:3306 --> Connect MySQL Shell to MySQL instance on first node.
- dba.checkInstanceConfiguration('myroot@node1.test.local:3306') -->
- var cluster = dba.createCluster('mycluster'); -->
- cluster.addInstance('myroot@node1.test.local:3306') --> Add node to cluster. Repeat for each node (node2.test.local, node3.test.local... etc.)
- cluster.checkInstanceState('myroot@node1.test.local:3306') --> Check the state of a node.