Advertisement
Guest User

Untitled

a guest
Aug 13th, 2017
530
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Installing Percona XtraDB Cluster
  2.  
  3. This is a guide about installing Percona XtraDB Cluster on 3 Debian jessie servers.
  4.  
  5. ## Preparations
  6.  
  7. We need 3 Debian jessie machines, preferably on the same network:
  8.  
  9. * db01.example.com
  10. * db02.example.com
  11. * db03.example.com
  12.  
  13. ### Prepare /etc/hosts
  14.  
  15. On db01:
  16.  
  17. ```
  18. 127.0.1.1 db01.example.com db01
  19. 127.0.0.1 localhost
  20. 10.10.10.2 db02.example.com db02
  21. 10.10.10.3 db03.example.com db03
  22. ```
  23.  
  24. On db02:
  25.  
  26. ```
  27. 127.0.1.1 db02.example.com db02
  28. 127.0.0.1 localhost
  29. 10.10.10.1 db01.example.com db01
  30. 10.10.10.3 db03.example.com db03
  31. ```
  32.  
  33. On db03:
  34.  
  35. ```
  36. 127.0.1.1 db03.example.com db03
  37. 127.0.0.1 localhost
  38. 10.10.10.1 db01.example.com db01
  39. 10.10.10.2 db02.example.com db02
  40. ```
  41.  
  42. ### Setup the FW
  43.  
  44. On db01:
  45.  
  46. ```
  47. ufw allow from 10.10.10.2
  48. ufw allow from 10.10.10.3
  49. ```
  50.  
  51. On db02:
  52.  
  53. ```
  54. ufw allow from 10.10.10.1
  55. ufw allow from 10.10.10.3
  56. ```
  57.  
  58. On db03:
  59.  
  60. ```
  61. ufw allow from 10.10.10.1
  62. ufw allow from 10.10.10.2
  63. ```
  64.  
  65. ## Install Percona XtraDB Cluster
  66.  
  67.  
  68. ### Setup debian repositories
  69.  
  70. Run these commands on all nodes.
  71.  
  72. * Download the percona relese .deb:
  73.  
  74. ```
  75. wget https://repo.percona.com/apt/percona-release_0.1-4.$(lsb_release -sc)_all.deb
  76. ```
  77.  
  78. * Install the package:
  79.  
  80. ```
  81. dpkg -i percona-release_0.1-4.$(lsb_release -sc)_all.deb
  82. ```
  83.  
  84. * Update APT:
  85.  
  86. ```
  87. apt update
  88. ```
  89.  
  90. ### Install the package
  91.  
  92. * Install *percona-xtradb-cluster-57*:
  93.  
  94. ```
  95. apt -y install percona-xtradb-cluster-57
  96. ```
  97.  
  98. Enter and verify the *root* user password when prompted.
  99.  
  100.  
  101. **Error: We get this in the logs:**
  102.  
  103. > 2017-08-13T07:54:38.438122Z 12 [Note] Access denied for user 'root'@'localhost' (using password: NO)
  104.  
  105. ## Setup the cluster
  106.  
  107. ### Configure the nodes
  108.  
  109. * Stop the *mysql* service on all nodes:
  110.  
  111. ```
  112. service mysql stop
  113. ```
  114.  
  115. * Add these in *etc/mysql/percona-xtradb-cluster.conf.d/mysqld.cnf* on *db01*:
  116.  
  117. ```
  118. # XtraDB Cluster
  119. wsrep_provider=/usr/lib/galera3/libgalera_smm.so
  120.  
  121. wsrep_cluster_name=pxc-cluster
  122. wsrep_cluster_address=gcomm://10.10.10.1,10.10.10.2,10.10.10.3
  123.  
  124. wsrep_node_name=db01
  125. wsrep_node_address=10.10.10.1
  126.  
  127. wsrep_sst_method=xtrabackup-v2
  128. wsrep_sst_auth=sstuser:P4$$W0rd
  129.  
  130. pxc_strict_mode=ENFORCING
  131.  
  132. binlog_format=ROW
  133. default_storage_engine=InnoDB
  134. innodb_autoinc_lock_mode=2
  135. ```
  136.  
  137. * Use the same sonfiguration for *db02* and *db03* except these lines:
  138.  
  139. ```
  140. wsrep_node_name=db02
  141. wsrep_node_address=10.10.10.2
  142. ```
  143.  
  144. ```
  145. wsrep_node_name=db03
  146. wsrep_node_address=10.10.10.3
  147. ```
  148.  
  149. ### Bootstarp the first node
  150.  
  151. * Start the *mysql* service in bootstrap mode:
  152.  
  153. ```
  154. /etc/init.d/mysql bootstrap-pxc
  155. ```
  156.  
  157. * Verify that the service has been initialised:
  158.  
  159. ```
  160. 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)'
  161.  
  162. wsrep_local_state_uuid a7150f16-7ffc-11e7-a81b-2200ad46db9d
  163. wsrep_local_state 4
  164. wsrep_local_state_comment Synced
  165. wsrep_cluster_size 1
  166. wsrep_cluster_status Primary
  167. wsrep_connected ON
  168. wsrep_ready ON
  169. ```
  170.  
  171. Looks OK!
  172.  
  173. * Create a user for State Snapshot Tranfer (SST):
  174.  
  175. ```
  176. mysql -p
  177. CREATE USER 'sstuser'@'localhost' IDENTIFIED BY 'passw0rd';
  178. GRANT RELOAD, LOCK TABLES, PROCESS, REPLICATION CLIENT ON *.* TO 'sstuser'@'localhost';
  179. FLUSH PRIVILEGES;
  180. ```
  181.  
  182. ### Add more nodes
  183.  
  184. Now we need to add more nodes in the cluster.
  185.  
  186. * Start *mysql* on *db02*:
  187.  
  188. ```
  189. /etc/init.d/mysql start
  190. ```
  191.  
  192. * Verify that *db02* has been added:
  193.  
  194. ```
  195. 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)'
  196.  
  197. wsrep_local_state_uuid cc726457-7ffb-11e7-9879-7bb11ba2758a
  198. wsrep_local_state 4
  199. wsrep_local_state_comment Synced
  200. wsrep_cluster_size 1
  201. wsrep_cluster_status Primary
  202. wsrep_connected ON
  203. wsrep_ready ON
  204. ```
  205.  
  206. 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.
  207.  
  208. Running `nmap` on *db02* we get:
  209.  
  210. ```
  211. nmap -sV -p 3306,4567 db01
  212.  
  213. Starting Nmap 6.47 ( http://nmap.org ) at 2017-08-13 11:55 PDT
  214. Nmap scan report for db01 (10.10.10.1)
  215. Host is up (0.0010s latency).
  216. rDNS record for 10.10.10.1: db01.example.com
  217. PORT STATE SERVICE VERSION
  218. 3306/tcp open mysql MySQL (unauthorized)
  219. 4567/tcp open tram
  220. ```
  221.  
  222. Ports are open so no connectivity issues.
  223.  
  224. References
  225. ----------
  226. * https://www.percona.com/doc/percona-repo-config/apt-repo.html
  227. * https://www.percona.com/doc/percona-xtradb-cluster/LATEST/install/apt.html
  228. * https://www.percona.com/doc/percona-xtradb-cluster/LATEST/configure.html
  229. * https://www.percona.com/doc/percona-xtradb-cluster/LATEST/bootstrap.html
  230. * https://www.percona.com/doc/percona-xtradb-cluster/LATEST/add-node.html
Advertisement
RAW Paste Data Copied
Advertisement