Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Installing Percona XtraDB Cluster
- This is a guide about installing Percona XtraDB Cluster on 3 Debian jessie servers.
- ## Preparations
- We need 3 Debian jessie machines, preferably on the same network:
- * db01.example.com
- * db02.example.com
- * db03.example.com
- ### Prepare /etc/hosts
- On db01:
- ```
- 127.0.1.1 db01.example.com db01
- 127.0.0.1 localhost
- 10.10.10.2 db02.example.com db02
- 10.10.10.3 db03.example.com db03
- ```
- On db02:
- ```
- 127.0.1.1 db02.example.com db02
- 127.0.0.1 localhost
- 10.10.10.1 db01.example.com db01
- 10.10.10.3 db03.example.com db03
- ```
- On db03:
- ```
- 127.0.1.1 db03.example.com db03
- 127.0.0.1 localhost
- 10.10.10.1 db01.example.com db01
- 10.10.10.2 db02.example.com db02
- ```
- ### Setup the FW
- On db01:
- ```
- ufw allow from 10.10.10.2
- ufw allow from 10.10.10.3
- ```
- On db02:
- ```
- ufw allow from 10.10.10.1
- ufw allow from 10.10.10.3
- ```
- On db03:
- ```
- ufw allow from 10.10.10.1
- ufw allow from 10.10.10.2
- ```
- ## Install Percona XtraDB Cluster
- ### Setup debian repositories
- Run these commands on all nodes.
- * Download the percona relese .deb:
- ```
- wget https://repo.percona.com/apt/percona-release_0.1-4.$(lsb_release -sc)_all.deb
- ```
- * Install the package:
- ```
- dpkg -i percona-release_0.1-4.$(lsb_release -sc)_all.deb
- ```
- * Update APT:
- ```
- apt update
- ```
- ### Install the package
- * Install *percona-xtradb-cluster-57*:
- ```
- apt -y install percona-xtradb-cluster-57
- ```
- Enter and verify the *root* user password when prompted.
- **Error: We get this in the logs:**
- > 2017-08-13T07:54:38.438122Z 12 [Note] Access denied for user 'root'@'localhost' (using password: NO)
- ## Setup the cluster
- ### Configure the nodes
- * Stop the *mysql* service on all nodes:
- ```
- service mysql stop
- ```
- * Add these in *etc/mysql/percona-xtradb-cluster.conf.d/mysqld.cnf* on *db01*:
- ```
- # XtraDB Cluster
- wsrep_provider=/usr/lib/galera3/libgalera_smm.so
- wsrep_cluster_name=pxc-cluster
- wsrep_cluster_address=gcomm://10.10.10.1,10.10.10.2,10.10.10.3
- wsrep_node_name=db01
- wsrep_node_address=10.10.10.1
- wsrep_sst_method=xtrabackup-v2
- wsrep_sst_auth=sstuser:P4$$W0rd
- pxc_strict_mode=ENFORCING
- binlog_format=ROW
- default_storage_engine=InnoDB
- innodb_autoinc_lock_mode=2
- ```
- * Use the same sonfiguration for *db02* and *db03* except these lines:
- ```
- wsrep_node_name=db02
- wsrep_node_address=10.10.10.2
- ```
- ```
- wsrep_node_name=db03
- wsrep_node_address=10.10.10.3
- ```
- ### Bootstarp the first node
- * Start the *mysql* service in bootstrap mode:
- ```
- /etc/init.d/mysql bootstrap-pxc
- ```
- * Verify that the service has been initialised:
- ```
- echo "show status like 'wsrep%'" | mysql | grep -E '(wsrep_local_state_uuid|wsrep_local_state|wsrep_local_state_comment|wsrep_cluster_size|wsrep_cluster_status|wsrep_connected|wsrep_ready)'
- wsrep_local_state_uuid a7150f16-7ffc-11e7-a81b-2200ad46db9d
- wsrep_local_state 4
- wsrep_local_state_comment Synced
- wsrep_cluster_size 1
- wsrep_cluster_status Primary
- wsrep_connected ON
- wsrep_ready ON
- ```
- Looks OK!
- * Create a user for State Snapshot Tranfer (SST):
- ```
- mysql -p
- CREATE USER 'sstuser'@'localhost' IDENTIFIED BY 'passw0rd';
- GRANT RELOAD, LOCK TABLES, PROCESS, REPLICATION CLIENT ON *.* TO 'sstuser'@'localhost';
- FLUSH PRIVILEGES;
- ```
- ### Add more nodes
- Now we need to add more nodes in the cluster.
- * Start *mysql* on *db02*:
- ```
- /etc/init.d/mysql start
- ```
- * Verify that *db02* has been added:
- ```
- echo "show status like 'wsrep%'" | mysql | grep -E '(wsrep_local_state_uuid|wsrep_local_state|wsrep_local_state_comment|wsrep_cluster_size|wsrep_cluster_status|wsrep_connected|wsrep_ready)'
- wsrep_local_state_uuid cc726457-7ffb-11e7-9879-7bb11ba2758a
- wsrep_local_state 4
- wsrep_local_state_comment Synced
- wsrep_cluster_size 1
- wsrep_cluster_status Primary
- wsrep_connected ON
- wsrep_ready ON
- ```
- The *wsrep_cluster_size* is still '1'. Something is wrong. Running `tcpdump` for ports 3306 and 4567, on *db01*, reveals that no traffic reaches the first node.
- Running `nmap` on *db02* we get:
- ```
- nmap -sV -p 3306,4567 db01
- Starting Nmap 6.47 ( http://nmap.org ) at 2017-08-13 11:55 PDT
- Nmap scan report for db01 (10.10.10.1)
- Host is up (0.0010s latency).
- rDNS record for 10.10.10.1: db01.example.com
- PORT STATE SERVICE VERSION
- 3306/tcp open mysql MySQL (unauthorized)
- 4567/tcp open tram
- ```
- Ports are open so no connectivity issues.
- References
- ----------
- * https://www.percona.com/doc/percona-repo-config/apt-repo.html
- * https://www.percona.com/doc/percona-xtradb-cluster/LATEST/install/apt.html
- * https://www.percona.com/doc/percona-xtradb-cluster/LATEST/configure.html
- * https://www.percona.com/doc/percona-xtradb-cluster/LATEST/bootstrap.html
- * https://www.percona.com/doc/percona-xtradb-cluster/LATEST/add-node.html
Advertisement
RAW Paste Data
Copied
Advertisement