Installing MySQL InnoDBCluster on CentOS 7

From rdkwiki
Jump to: navigation, search


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

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 (not preferred, but focus is on InnoDB cluster in this article)

  • 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 nodes for cluster (repeat on each node)

  • mysqlsh --uri myroot@localhost:3306 --> Connect MySQL Shell to the LOCAL MySQL instance on 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 on first node.
  • dba.checkInstanceConfiguration('myroot@node1.test.local:3306') --> Check if the configuration of the node is cluster ready.
  • var cluster = dba.createCluster('mycluster'); --> create the cluster on the first node.
  • 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.