前言:pxc全名Percona XtraDB Cluster,是Percona公司免费开源的一款优秀的高可用解决方案,并且已经在很多企业中部署到生产环境。pxc具有多主复制、数据强一致性等优秀特性,具体原理特性等放到下一篇介绍,本篇主要介绍快速安装部署PXC集群。

说明 ip
node1 192.168.50.3
node2 192.168.50.4
node3 192.168.50.5

一、安装依赖

  1. yum install perl-IO-Socket-SSL perl-DBD-MySQL perl-Time-HiRes socat nc -y

二、安装xtrabackup

去wwww.percona.com下载最新版本xtrabackup的rpm包,具体参考前面的xtrabackup安装文档xtrabackup安装使用

  1. rpm -ivh percona-xtrabackup-24-2.4.9-1.el6.x86_64.rpm

三、安装pxc

1.下载安装包
去wwww.percona.com下载最新版本Percona-XtraDB-Cluster二进制包,先不急着初始化
特别注意二进制包:
ssl100: for all supported Debian and Ubuntu versions
ssl101: for supported Red Hat Enterprise Linux derivatives
我们一般下载ssl101的二进制包即可
解压到/usr/local/mysql或者做软连接也可以。
2.配置文件
node1配置文件:

  1. #my.cnf
  2. [client]
  3. port = 3306
  4. socket = /tmp/mysql.sock
  5. [mysql]
  6. prompt="\\u@\\h:\\p [\\d]>
  7. #pager="less -i -n -S"
  8. #tee=/home/mysql/query.log
  9. no-auto-rehash
  10. [mysqld]
  11. #misc
  12. user = mysql
  13. basedir = /usr/local/mysql
  14. datadir = /data/pxc/mysql3306/data
  15. port = 3306
  16. socket = /tmp/mysql.sock
  17. event_scheduler = 0
  18. #timeout
  19. interactive_timeout = 300
  20. wait_timeout = 300
  21. #character set
  22. character-set-server = utf8
  23. open_files_limit = 65535
  24. max_connections = 100
  25. max_connect_errors = 100000
  26. #logs
  27. log-output=file
  28. slow_query_log = 1
  29. slow_query_log_file = slow.log
  30. log-error = error.log
  31. log_warnings = 2
  32. pid-file = mysql.pid
  33. long_query_time = 1
  34. #log-slow-admin-statements = 1
  35. #log-queries-not-using-indexes = 1
  36. log-slow-slave-statements = 1
  37. #binlog
  38. binlog_format = row
  39. server-id = 1023306
  40. log-bin = /data/pxc/mysql3306/logs/mysql-bin
  41. binlog_cache_size = 1M
  42. max_binlog_size = 200M
  43. max_binlog_cache_size = 2G
  44. sync_binlog = 0
  45. expire_logs_days = 10
  46. #relay log
  47. skip_slave_start = 1
  48. max_relay_log_size = 500M
  49. relay_log_purge = 1
  50. relay_log_recovery = 1
  51. log_slave_updates
  52. #slave-skip-errors=1032,1053,1062
  53. #buffers & cache
  54. table_open_cache = 2048
  55. table_definition_cache = 2048
  56. table_open_cache = 2048
  57. max_heap_table_size = 96M
  58. sort_buffer_size = 2M
  59. join_buffer_size = 2M
  60. thread_cache_size = 256
  61. query_cache_size = 0
  62. query_cache_type = 0
  63. query_cache_limit = 256K
  64. query_cache_min_res_unit = 512
  65. thread_stack = 192K
  66. tmp_table_size = 96M
  67. key_buffer_size = 8M
  68. read_buffer_size = 2M
  69. read_rnd_buffer_size = 16M
  70. bulk_insert_buffer_size = 32M
  71. #myisam
  72. myisam_sort_buffer_size = 128M
  73. myisam_max_sort_file_size = 10G
  74. myisam_repair_threads = 1
  75. #innodb
  76. innodb_buffer_pool_size = 100M
  77. innodb_buffer_pool_instances = 1
  78. innodb_data_file_path = ibdata1:100M:autoextend
  79. innodb_flush_log_at_trx_commit = 2
  80. innodb_log_buffer_size = 64M
  81. innodb_log_file_size = 256M
  82. innodb_log_files_in_group = 3
  83. innodb_max_dirty_pages_pct = 90
  84. innodb_file_per_table = 1
  85. innodb_rollback_on_timeout
  86. innodb_status_file = 1
  87. innodb_io_capacity = 2000
  88. transaction_isolation = READ-COMMITTED
  89. innodb_flush_method = O_DIRECT
  90. #pxc
  91. default_storage_engine=Innodb
  92. innodb_locks_unsafe_for_binlog=1
  93. innodb_autoinc_lock_mode=2
  94. wsrep_cluster_name=pxc_xucl
  95. wsrep_cluster_address=gcomm://192.168.50.3,192.168.50.4,192.168.50.5
  96. wsrep_node_address=192.168.50.3
  97. wsrep_provider=/usr/local/mysql/lib/libgalera_smm.so
  98. wsrep_sst_method=xtrabackup-v2
  99. wsrep_sst_auth=sst:xuclxucl

node2配置文件:

  1. #my.cnf
  2. [client]
  3. port = 3306
  4. socket = /tmp/mysql.sock
  5. [mysql]
  6. prompt="\\u@\\h:\\p [\\d]>
  7. #pager="less -i -n -S"
  8. #tee=/home/mysql/query.log
  9. no-auto-rehash
  10. [mysqld]
  11. #misc
  12. user = mysql
  13. basedir = /usr/local/mysql
  14. datadir = /data/pxc/mysql3306/data
  15. port = 3306
  16. socket = /tmp/mysql.sock
  17. event_scheduler = 0
  18. #timeout
  19. interactive_timeout = 300
  20. wait_timeout = 300
  21. #character set
  22. character-set-server = utf8
  23. open_files_limit = 65535
  24. max_connections = 100
  25. max_connect_errors = 100000
  26. #logs
  27. log-output=file
  28. slow_query_log = 1
  29. slow_query_log_file = slow.log
  30. log-error = error.log
  31. log_warnings = 2
  32. pid-file = mysql.pid
  33. long_query_time = 1
  34. #log-slow-admin-statements = 1
  35. #log-queries-not-using-indexes = 1
  36. log-slow-slave-statements = 1
  37. #binlog
  38. binlog_format = row
  39. server-id = 1023306
  40. log-bin = /data/pxc/mysql3306/logs/mysql-bin
  41. binlog_cache_size = 1M
  42. max_binlog_size = 200M
  43. max_binlog_cache_size = 2G
  44. sync_binlog = 0
  45. expire_logs_days = 10
  46. #relay log
  47. skip_slave_start = 1
  48. max_relay_log_size = 500M
  49. relay_log_purge = 1
  50. relay_log_recovery = 1
  51. log_slave_updates
  52. #slave-skip-errors=1032,1053,1062
  53. #buffers & cache
  54. table_open_cache = 2048
  55. table_definition_cache = 2048
  56. table_open_cache = 2048
  57. max_heap_table_size = 96M
  58. sort_buffer_size = 2M
  59. join_buffer_size = 2M
  60. thread_cache_size = 256
  61. query_cache_size = 0
  62. query_cache_type = 0
  63. query_cache_limit = 256K
  64. query_cache_min_res_unit = 512
  65. thread_stack = 192K
  66. tmp_table_size = 96M
  67. key_buffer_size = 8M
  68. read_buffer_size = 2M
  69. read_rnd_buffer_size = 16M
  70. bulk_insert_buffer_size = 32M
  71. #myisam
  72. myisam_sort_buffer_size = 128M
  73. myisam_max_sort_file_size = 10G
  74. myisam_repair_threads = 1
  75. #innodb
  76. innodb_buffer_pool_size = 100M
  77. innodb_buffer_pool_instances = 1
  78. innodb_data_file_path = ibdata1:100M:autoextend
  79. innodb_flush_log_at_trx_commit = 2
  80. innodb_log_buffer_size = 64M
  81. innodb_log_file_size = 256M
  82. innodb_log_files_in_group = 3
  83. innodb_max_dirty_pages_pct = 90
  84. innodb_file_per_table = 1
  85. innodb_rollback_on_timeout
  86. innodb_status_file = 1
  87. innodb_io_capacity = 2000
  88. transaction_isolation = READ-COMMITTED
  89. innodb_flush_method = O_DIRECT
  90. #pxc
  91. default_storage_engine=Innodb
  92. innodb_locks_unsafe_for_binlog=1
  93. innodb_autoinc_lock_mode=2
  94. wsrep_cluster_name=pxc_xucl
  95. wsrep_cluster_address=gcomm://192.168.50.3,192.168.50.4,192.168.50.5
  96. wsrep_node_address=192.168.50.4
  97. wsrep_provider=/usr/local/mysql/lib/libgalera_smm.so
  98. wsrep_sst_method=xtrabackup-v2
  99. wsrep_sst_auth=sst:xuclxucl

node3配置文件:

  1. #my.cnf
  2. [client]
  3. port = 3306
  4. socket = /tmp/mysql.sock
  5. [mysql]
  6. prompt="\\u@\\h:\\p [\\d]>
  7. #pager="less -i -n -S"
  8. #tee=/home/mysql/query.log
  9. no-auto-rehash
  10. [mysqld]
  11. #misc
  12. user = mysql
  13. basedir = /usr/local/mysql
  14. datadir = /data/pxc/mysql3306/data
  15. port = 3306
  16. socket = /tmp/mysql.sock
  17. event_scheduler = 0
  18. #timeout
  19. interactive_timeout = 300
  20. wait_timeout = 300
  21. #character set
  22. character-set-server = utf8
  23. open_files_limit = 65535
  24. max_connections = 100
  25. max_connect_errors = 100000
  26. #logs
  27. log-output=file
  28. slow_query_log = 1
  29. slow_query_log_file = slow.log
  30. log-error = error.log
  31. log_warnings = 2
  32. pid-file = mysql.pid
  33. long_query_time = 1
  34. #log-slow-admin-statements = 1
  35. #log-queries-not-using-indexes = 1
  36. log-slow-slave-statements = 1
  37. #binlog
  38. binlog_format = row
  39. server-id = 1023306
  40. log-bin = /data/pxc/mysql3306/logs/mysql-bin
  41. binlog_cache_size = 1M
  42. max_binlog_size = 200M
  43. max_binlog_cache_size = 2G
  44. sync_binlog = 0
  45. expire_logs_days = 10
  46. #relay log
  47. skip_slave_start = 1
  48. max_relay_log_size = 500M
  49. relay_log_purge = 1
  50. relay_log_recovery = 1
  51. log_slave_updates
  52. #slave-skip-errors=1032,1053,1062
  53. #buffers & cache
  54. table_open_cache = 2048
  55. table_definition_cache = 2048
  56. table_open_cache = 2048
  57. max_heap_table_size = 96M
  58. sort_buffer_size = 2M
  59. join_buffer_size = 2M
  60. thread_cache_size = 256
  61. query_cache_size = 0
  62. query_cache_type = 0
  63. query_cache_limit = 256K
  64. query_cache_min_res_unit = 512
  65. thread_stack = 192K
  66. tmp_table_size = 96M
  67. key_buffer_size = 8M
  68. read_buffer_size = 2M
  69. read_rnd_buffer_size = 16M
  70. bulk_insert_buffer_size = 32M
  71. #myisam
  72. myisam_sort_buffer_size = 128M
  73. myisam_max_sort_file_size = 10G
  74. myisam_repair_threads = 1
  75. #innodb
  76. innodb_buffer_pool_size = 100M
  77. innodb_buffer_pool_instances = 1
  78. innodb_data_file_path = ibdata1:100M:autoextend
  79. innodb_flush_log_at_trx_commit = 2
  80. innodb_log_buffer_size = 64M
  81. innodb_log_file_size = 256M
  82. innodb_log_files_in_group = 3
  83. innodb_max_dirty_pages_pct = 90
  84. innodb_file_per_table = 1
  85. innodb_rollback_on_timeout
  86. innodb_status_file = 1
  87. innodb_io_capacity = 2000
  88. transaction_isolation = READ-COMMITTED
  89. innodb_flush_method = O_DIRECT
  90. #pxc
  91. default_storage_engine=Innodb
  92. innodb_locks_unsafe_for_binlog=1
  93. innodb_autoinc_lock_mode=2
  94. wsrep_cluster_name=pxc_xucl
  95. wsrep_cluster_address=gcomm://192.168.50.3,192.168.50.4,192.168.50.5
  96. wsrep_node_address=192.168.50.5
  97. wsrep_provider=/usr/local/mysql/lib/libgalera_smm.so
  98. wsrep_sst_method=xtrabackup-v2
  99. wsrep_sst_auth=sst:xuclxucl

3.初始化节点1

  1. /usr/local/mysql/bin/mysqld --defaults-file=/data/pxc/my.cnf --initialize

查看error.log输出如下:

  1. 2018-03-22T08:31:02.663756Z 0 [Warning] The syntax '--log_warnings/-W' is deprecated and will be removed in a future release. Please use '--log_error_verbosity' instead.
  2. 2018-03-22T08:31:02.663919Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  3. 2018-03-22T08:31:02.663957Z 0 [Note] Ignoring --secure-file-priv value as server is running with --initialize(-insecure) or --bootstrap.
  4. 2018-03-22T08:31:02.663970Z 0 [Warning] WSREP: Node is running in bootstrap/initialize mode. Disabling pxc_strict_mode checks
  5. 2018-03-22T08:31:02.663985Z 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.7.21-20-29.26-log) starting as process 7358 ...
  6. 2018-03-22T08:31:02.665381Z 0 [Note] --initialize specifed on an existing data directory.
  7. 2018-03-22T08:31:02.665956Z 0 [Note] WSREP: Setting wsrep_ready to false
  8. 2018-03-22T08:31:02.665969Z 0 [Note] WSREP: Found pre-stored initial position: 3330362f-6461-7461-2f00-f50000000000:41556992
  9. 2018-03-22T08:31:02.665972Z 0 [Note] WSREP: wsrep_load(): loading provider library 'none'
  10. 2018-03-22T08:31:02.665975Z 0 [Note] WSREP: Setting wsrep_ready to true
  11. 2018-03-22T08:31:02.678611Z 0 [Warning] InnoDB: Using innodb_locks_unsafe_for_binlog is DEPRECATED. This option may be removed in future releases. Please use READ COMMITTED transaction isolation level instead; Please refer to http://dev.mysql.com/doc/refman/5.7/en/set-transaction.html
  12. 2018-03-22T08:31:02.678640Z 0 [Note] InnoDB: PUNCH HOLE support available
  13. 2018-03-22T08:31:02.678648Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
  14. 2018-03-22T08:31:02.678651Z 0 [Note] InnoDB: Uses event mutexes
  15. 2018-03-22T08:31:02.678655Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
  16. 2018-03-22T08:31:02.678658Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
  17. 2018-03-22T08:31:02.678661Z 0 [Note] InnoDB: Using Linux native AIO
  18. 2018-03-22T08:31:02.678831Z 0 [Note] InnoDB: Number of pools: 1
  19. 2018-03-22T08:31:02.678910Z 0 [Note] InnoDB: Using CPU crc32 instructions
  20. 2018-03-22T08:31:02.680144Z 0 [Note] InnoDB: Initializing buffer pool, total size = 100M, instances = 1, chunk size = 100M
  21. 2018-03-22T08:31:02.682565Z 0 [Note] InnoDB: Completed initialization of buffer pool
  22. 2018-03-22T08:31:02.683764Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
  23. 2018-03-22T08:31:02.693950Z 0 [Note] InnoDB: The first innodb_system data file 'ibdata1' did not exist. A new tablespace will be created!
  24. 2018-03-22T08:31:02.694166Z 0 [Note] InnoDB: Setting file './ibdata1' size to 100 MB. Physically writing the file full; Please wait ...
  25. 2018-03-22T08:31:02.694496Z 0 [Note] InnoDB: Progress in MB:
  26. 100
  27. 2018-03-22T08:31:03.069672Z 0 [Note] InnoDB: File './ibdata1' size is now 100 MB.
  28. 2018-03-22T08:31:03.069892Z 0 [Note] InnoDB: Setting log file ./ib_logfile101 size to 256 MB
  29. 2018-03-22T08:31:03.070000Z 0 [Note] InnoDB: Progress in MB:
  30. 100 200
  31. 2018-03-22T08:31:03.598100Z 0 [Note] InnoDB: Setting log file ./ib_logfile1 size to 256 MB
  32. 2018-03-22T08:31:03.598220Z 0 [Note] InnoDB: Progress in MB:
  33. 100 200
  34. 2018-03-22T08:31:03.882825Z 0 [Note] InnoDB: Setting log file ./ib_logfile2 size to 256 MB
  35. 2018-03-22T08:31:03.882945Z 0 [Note] InnoDB: Progress in MB:
  36. 100 200
  37. 2018-03-22T08:31:04.246505Z 0 [Note] InnoDB: Created parallel doublewrite buffer at /data/pxc/mysql3306/data/xb_doublewrite, size 3932160 bytes
  38. 2018-03-22T08:31:04.318847Z 0 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
  39. 2018-03-22T08:31:04.318914Z 0 [Warning] InnoDB: New log files created, LSN=45790
  40. 2018-03-22T08:31:04.318923Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
  41. 2018-03-22T08:31:04.318967Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
  42. 2018-03-22T08:31:04.471597Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
  43. 2018-03-22T08:31:04.471735Z 0 [Note] InnoDB: Doublewrite buffer not found: creating new
  44. 2018-03-22T08:31:04.543336Z 0 [Note] InnoDB: Doublewrite buffer created
  45. 2018-03-22T08:31:04.553103Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
  46. 2018-03-22T08:31:04.553131Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
  47. 2018-03-22T08:31:04.553757Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
  48. 2018-03-22T08:31:04.558344Z 0 [Note] InnoDB: Foreign key constraint system tables created
  49. 2018-03-22T08:31:04.560332Z 0 [Note] InnoDB: Creating tablespace and datafile system tables.
  50. 2018-03-22T08:31:04.560727Z 0 [Note] InnoDB: Tablespace and datafile system tables created.
  51. 2018-03-22T08:31:04.560747Z 0 [Note] InnoDB: Creating sys_virtual system tables.
  52. 2018-03-22T08:31:04.560863Z 0 [Note] InnoDB: sys_virtual table created
  53. 2018-03-22T08:31:04.560874Z 0 [Note] InnoDB: Creating zip_dict and zip_dict_cols system tables.
  54. 2018-03-22T08:31:04.561233Z 0 [Note] InnoDB: zip_dict and zip_dict_cols system tables created.
  55. 2018-03-22T08:31:04.561319Z 0 [Note] InnoDB: Waiting for purge to start
  56. 2018-03-22T08:31:04.612605Z 0 [Note] InnoDB: Percona XtraDB (http://www.percona.com) 5.7.21-rel20 started; log sequence number 0
  57. 2018-03-22T08:31:04.613279Z 0 [Note] Plugin 'FEDERATED' is disabled.
  58. 2018-03-22T08:31:04.622215Z 0 [Note] Salting uuid generator variables, current_pid: 7358, server_start_time: 1521707462, bytes_sent: 0,
  59. 2018-03-22T08:31:04.622269Z 0 [Note] Generated uuid: '5c50473c-2dab-11e8-9481-080027de0e0e', server_start_time: 2071092880158721668, bytes_sent: 50293392
  60. 2018-03-22T08:31:04.622282Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 5c50473c-2dab-11e8-9481-080027de0e0e.
  61. 2018-03-22T08:31:04.623391Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
  62. 2018-03-22T08:31:05.090710Z 0 [Note] Auto generated SSL certificates are placed in data directory.
  63. 2018-03-22T08:31:05.101030Z 0 [Warning] CA certificate ca.pem is self signed.
  64. 2018-03-22T08:31:05.320481Z 0 [Note] Auto generated RSA key files are placed in data directory.
  65. 2018-03-22T08:31:05.320880Z 1 [Note] Creating the system database
  66. 2018-03-22T08:31:05.320926Z 1 [Note] A temporary password is generated for root@localhost: 5b6RO=Z<g*S9
  67. 2018-03-22T08:31:05.333922Z 1 [Note] Creating the system tables
  68. 2018-03-22T08:31:05.625787Z 1 [Note] Filling in the system tables, part 1
  69. 2018-03-22T08:31:05.626706Z 1 [Note] Filling in the system tables, part 2
  70. 2018-03-22T08:31:05.626714Z 1 [Note] Filling in the mysql.help table
  71. 2018-03-22T08:31:05.885746Z 1 [Note] Creating user for internal session service
  72. 2018-03-22T08:31:05.886040Z 1 [Note] Creating the sys schema
  73. 2018-03-22T08:31:06.166453Z 1 [Note] Bootstrapping complete
  74. 2018-03-22T08:31:06.166856Z 0 [Note] Giving 0 client threads a chance to die gracefully
  75. 2018-03-22T08:31:06.166872Z 0 [Note] WSREP: Waiting for active wsrep applier to exit
  76. 2018-03-22T08:31:06.166875Z 0 [Note] WSREP: Service disconnected.
  77. 2018-03-22T08:31:06.166877Z 0 [Note] WSREP: Waiting to close threads......
  78. 2018-03-22T08:31:11.167025Z 0 [Note] WSREP: Some threads may fail to exit.
  79. 2018-03-22T08:31:11.167118Z 0 [Note] Giving 0 client threads a chance to die gracefully
  80. 2018-03-22T08:31:11.167124Z 0 [Note] Shutting down slave threads
  81. 2018-03-22T08:31:11.167130Z 0 [Note] Forcefully disconnecting 0 remaining clients
  82. 2018-03-22T08:31:11.178224Z 0 [Note] Binlog end
  83. 2018-03-22T08:31:11.179733Z 0 [Note] InnoDB: FTS optimize thread exiting.
  84. 2018-03-22T08:31:11.179813Z 0 [Note] InnoDB: Starting shutdown...
  85. 2018-03-22T08:31:11.282666Z 0 [Note] InnoDB: Dumping buffer pool(s) to /data/pxc/mysql3306/data/ib_buffer_pool
  86. 2018-03-22T08:31:11.282837Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 180322 9:31:11
  87. 2018-03-22T08:31:11.886137Z 0 [Note] InnoDB: Waiting for page_cleaner to finish flushing of buffer pool
  88. 2018-03-22T08:31:13.408971Z 0 [Note] InnoDB: Shutdown completed; log sequence number 2556457
  89. 2018-03-22T08:31:13.409032Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"

node1初始化完成,接着我们启动node1

  1. /usr/local/mysql/bin/mysqld --defaults-file=/data/pxc/my.cnf --wsrep-new-cluster &

说明:使用—wsrep-new-cluster 启动, 让他忽略参数: wsrep_cluster_address 让
他知道他是集群中的第一个节点, 在启动中不用去找其它节点。

查看error.log看到ready for connections表示启动成功

  1. 2018-03-22T08:33:06.775084Z 0 [Warning] The syntax '--log_warnings/-W' is deprecated and will be removed in a future release. Please use '--log_error_verbosity' instead.
  2. 2018-03-22T08:33:06.775285Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  3. 2018-03-22T08:33:06.775353Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
  4. 2018-03-22T08:33:06.775409Z 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.7.21-20-29.26-log) starting as process 7393 ...
  5. 2018-03-22T08:33:06.784742Z 0 [Note] WSREP: Setting wsrep_ready to false
  6. 2018-03-22T08:33:06.784754Z 0 [Note] WSREP: No pre-stored wsrep-start position found. Skipping position initialization.
  7. 2018-03-22T08:33:06.784757Z 0 [Note] WSREP: wsrep_load(): loading provider library '/usr/local/mysql/lib/libgalera_smm.so'
  8. 2018-03-22T08:33:06.791639Z 0 [Note] WSREP: wsrep_load(): Galera 3.26(r) by Codership Oy <info@codership.com> loaded successfully.
  9. 2018-03-22T08:33:06.791701Z 0 [Note] WSREP: CRC-32C: using hardware acceleration.
  10. 2018-03-22T08:33:06.791929Z 0 [Warning] WSREP: Could not open state file for reading: '/data/pxc/mysql3306/data//grastate.dat'
  11. 2018-03-22T08:33:06.791936Z 0 [Warning] WSREP: No persistent state found. Bootstraping with default state
  12. 2018-03-22T08:33:06.791977Z 0 [Note] WSREP: Found saved state: 00000000-0000-0000-0000-000000000000:-1, safe_to_bootstrap: 1
  13. 2018-03-22T08:33:06.800384Z 0 [Note] WSREP: Passing config to GCS: base_dir = /data/pxc/mysql3306/data/; base_host = 192.168.50.3; base_port = 4567; cert.log_conflicts = no; debug = no; evs.auto_evict = 0; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT15S; evs.join_retrans_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 10; evs.stats_report_period = PT1M; evs.suspect_timeout = PT5S; evs.user_send_window = 4; evs.view_forget_timeout = PT24H; gcache.dir = /data/pxc/mysql3306/data/; gcache.freeze_purge_at_seqno = -1; gcache.keep_pages_count = 0; gcache.keep_pages_size = 0; gcache.mem_size = 0; gcache.name = /data/pxc/mysql3306/data//galera.cache; gcache.page_size = 128M; gcache.recover = no; gcache.size = 128M; gcomm.thread_prio = ; gcs.fc_debug = 0; gcs.fc_factor = 1; gcs.fc_limit = 100; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; gcs.recv_q_hard_limit = 9223372036854775807; gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; gmcast.segment = 0; gmcast.version = 0; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; pc.ignore_sb = false; pc.npvo = false; pc.recovery = 1; pc.version = 0; pc.wait_prim = true; pc.wait_prim_timeout = PT30S; pc.weight = 1; protonet.backend = asio; protonet.version = 0; repl.causal_read_timeout = PT30S; repl.commit_order = 3; repl.key_format = FLAT8; repl.max_ws_size = 2147483647; repl.proto_max = 8; socket.checksum = 2; socket.recv_buf_size = 212992;
  14. 2018-03-22T08:33:06.823061Z 0 [Note] WSREP: GCache history reset: 00000000-0000-0000-0000-000000000000:0 -> 00000000-0000-0000-0000-000000000000:-1
  15. 2018-03-22T08:33:06.825847Z 0 [Note] WSREP: Assign initial position for certification: -1, protocol version: -1
  16. 2018-03-22T08:33:06.825883Z 0 [Note] WSREP: Preparing to initiate SST/IST
  17. 2018-03-22T08:33:06.825888Z 0 [Note] WSREP: Starting replication
  18. 2018-03-22T08:33:06.825900Z 0 [Note] WSREP: Setting initial position to 00000000-0000-0000-0000-000000000000:-1
  19. 2018-03-22T08:33:06.826070Z 0 [Note] WSREP: Using CRC-32C for message checksums.
  20. 2018-03-22T08:33:06.826178Z 0 [Note] WSREP: gcomm thread scheduling priority set to other:0
  21. 2018-03-22T08:33:06.826269Z 0 [Warning] WSREP: Fail to access the file (/data/pxc/mysql3306/data//gvwstate.dat) error (No such file or directory). It is possible if node is booting for first time or re-booting after a graceful shutdown
  22. 2018-03-22T08:33:06.826275Z 0 [Note] WSREP: Restoring primary-component from disk failed. Either node is booting for first time or re-booting after a graceful shutdown
  23. 2018-03-22T08:33:06.829440Z 0 [Note] WSREP: GMCast version 0
  24. 2018-03-22T08:33:06.829622Z 0 [Note] WSREP: (a5272275, 'tcp://0.0.0.0:4567') listening at tcp://0.0.0.0:4567
  25. 2018-03-22T08:33:06.829635Z 0 [Note] WSREP: (a5272275, 'tcp://0.0.0.0:4567') multicast: , ttl: 1
  26. 2018-03-22T08:33:06.829943Z 0 [Note] WSREP: EVS version 0
  27. 2018-03-22T08:33:06.830042Z 0 [Note] WSREP: gcomm: bootstrapping new group 'pxc_wubx'
  28. 2018-03-22T08:33:06.830067Z 0 [Note] WSREP: start_prim is enabled, turn off pc_recovery
  29. 2018-03-22T08:33:06.830613Z 0 [Note] WSREP: Node a5272275 state primary
  30. 2018-03-22T08:33:06.830647Z 0 [Note] WSREP: Current view of cluster as seen by this node
  31. view (view_id(PRIM,a5272275,1)
  32. memb {
  33. a5272275,0
  34. }
  35. joined {
  36. }
  37. left {
  38. }
  39. partitioned {
  40. }
  41. )
  42. 2018-03-22T08:33:06.830666Z 0 [Note] WSREP: Save the discovered primary-component to disk
  43. 2018-03-22T08:33:06.830784Z 0 [Note] WSREP: discarding pending addr without UUID: tcp://192.168.50.3:4567
  44. 2018-03-22T08:33:06.830792Z 0 [Note] WSREP: discarding pending addr proto entry 0x2fb9540
  45. 2018-03-22T08:33:06.830819Z 0 [Note] WSREP: discarding pending addr without UUID: tcp://192.168.50.4:4567
  46. 2018-03-22T08:33:06.830824Z 0 [Note] WSREP: discarding pending addr proto entry 0x2fc1cf0
  47. 2018-03-22T08:33:06.830832Z 0 [Note] WSREP: discarding pending addr without UUID: tcp://192.168.50.5:4567
  48. 2018-03-22T08:33:06.830835Z 0 [Note] WSREP: discarding pending addr proto entry 0x2fca470
  49. 2018-03-22T08:33:06.830861Z 0 [Note] WSREP: gcomm: connected
  50. 2018-03-22T08:33:06.831117Z 0 [Note] WSREP: Shifting CLOSED -> OPEN (TO: 0)
  51. 2018-03-22T08:33:06.831185Z 0 [Note] WSREP: Waiting for SST/IST to complete.
  52. 2018-03-22T08:33:06.833031Z 0 [Note] WSREP: New COMPONENT: primary = yes, bootstrap = no, my_idx = 0, memb_num = 1
  53. 2018-03-22T08:33:06.833869Z 0 [Note] WSREP: Starting new group from scratch: a5283990-2dab-11e8-abe5-f600706598d2
  54. 2018-03-22T08:33:06.834299Z 0 [Note] WSREP: STATE_EXCHANGE: sent state UUID: a5284acc-2dab-11e8-b04d-a26cf382854e
  55. 2018-03-22T08:33:06.834388Z 0 [Note] WSREP: STATE EXCHANGE: sent state msg: a5284acc-2dab-11e8-b04d-a26cf382854e
  56. 2018-03-22T08:33:06.834402Z 0 [Note] WSREP: STATE EXCHANGE: got state msg: a5284acc-2dab-11e8-b04d-a26cf382854e from 0 (localhost.localdomain)
  57. 2018-03-22T08:33:06.834410Z 0 [Note] WSREP: Quorum results:
  58. version = 4,
  59. component = PRIMARY,
  60. conf_id = 0,
  61. members = 1/1 (primary/total),
  62. act_id = 0,
  63. last_appl. = -1,
  64. protocols = 0/8/3 (gcs/repl/appl),
  65. group UUID = a5283990-2dab-11e8-abe5-f600706598d2
  66. 2018-03-22T08:33:06.834416Z 0 [Note] WSREP: Flow-control interval: [100, 100]
  67. 2018-03-22T08:33:06.834418Z 0 [Note] WSREP: Trying to continue unpaused monitor
  68. 2018-03-22T08:33:06.834421Z 0 [Note] WSREP: Restored state OPEN -> JOINED (0)
  69. 2018-03-22T08:33:06.834437Z 0 [Note] WSREP: Member 0.0 (localhost.localdomain) synced with group.
  70. 2018-03-22T08:33:06.834441Z 0 [Note] WSREP: Shifting JOINED -> SYNCED (TO: 0)
  71. 2018-03-22T08:33:06.834665Z 2 [Note] WSREP: New cluster view: global state: a5283990-2dab-11e8-abe5-f600706598d2:0, view# 1: Primary, number of nodes: 1, my index: 0, protocol version 3
  72. 2018-03-22T08:33:06.834678Z 2 [Note] WSREP: Setting wsrep_ready to true
  73. 2018-03-22T08:33:06.834701Z 0 [Note] WSREP: SST complete, seqno: 0
  74. 2018-03-22T08:33:06.837697Z 0 [Warning] InnoDB: Using innodb_locks_unsafe_for_binlog is DEPRECATED. This option may be removed in future releases. Please use READ COMMITTED transaction isolation level instead; Please refer to http://dev.mysql.com/doc/refman/5.7/en/set-transaction.html
  75. 2018-03-22T08:33:06.837781Z 0 [Note] InnoDB: PUNCH HOLE support available
  76. 2018-03-22T08:33:06.837787Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
  77. 2018-03-22T08:33:06.837790Z 0 [Note] InnoDB: Uses event mutexes
  78. 2018-03-22T08:33:06.837793Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier
  79. 2018-03-22T08:33:06.837796Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
  80. 2018-03-22T08:33:06.837798Z 0 [Note] InnoDB: Using Linux native AIO
  81. 2018-03-22T08:33:06.837952Z 0 [Note] InnoDB: Number of pools: 1
  82. 2018-03-22T08:33:06.838033Z 0 [Note] InnoDB: Using CPU crc32 instructions
  83. 2018-03-22T08:33:06.839425Z 0 [Note] InnoDB: Initializing buffer pool, total size = 100M, instances = 1, chunk size = 100M
  84. 2018-03-22T08:33:06.842260Z 0 [Note] InnoDB: Completed initialization of buffer pool
  85. 2018-03-22T08:33:06.844122Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
  86. 2018-03-22T08:33:06.861920Z 0 [Note] InnoDB: Crash recovery did not find the parallel doublewrite buffer at /data/pxc/mysql3306/data/xb_doublewrite
  87. 2018-03-22T08:33:06.867175Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
  88. 2018-03-22T08:33:06.896116Z 0 [Note] InnoDB: Created parallel doublewrite buffer at /data/pxc/mysql3306/data/xb_doublewrite, size 3932160 bytes
  89. 2018-03-22T08:33:06.946633Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
  90. 2018-03-22T08:33:06.946702Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
  91. 2018-03-22T08:33:06.991171Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
  92. 2018-03-22T08:33:06.991944Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
  93. 2018-03-22T08:33:06.991958Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
  94. 2018-03-22T08:33:06.992189Z 0 [Note] InnoDB: Waiting for purge to start
  95. 2018-03-22T08:33:07.043774Z 0 [Note] InnoDB: Percona XtraDB (http://www.percona.com) 5.7.21-rel20 started; log sequence number 2556457
  96. 2018-03-22T08:33:07.043946Z 0 [Note] Plugin 'FEDERATED' is disabled.
  97. 2018-03-22T08:33:07.046331Z 0 [Note] InnoDB: Loading buffer pool(s) from /data/pxc/mysql3306/data/ib_buffer_pool
  98. 2018-03-22T08:33:07.070494Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
  99. 2018-03-22T08:33:07.070517Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
  100. 2018-03-22T08:33:07.076544Z 0 [Warning] CA certificate ca.pem is self signed.
  101. 2018-03-22T08:33:07.076618Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
  102. 2018-03-22T08:33:07.076731Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
  103. 2018-03-22T08:33:07.076757Z 0 [Note] IPv6 is available.
  104. 2018-03-22T08:33:07.076765Z 0 [Note] - '::' resolves to '::';
  105. 2018-03-22T08:33:07.076778Z 0 [Note] Server socket created on IP: '::'.
  106. 2018-03-22T08:33:07.106190Z 0 [Note] InnoDB: Buffer pool(s) load completed at 180322 9:33:07
  107. 2018-03-22T08:33:07.148383Z 0 [Note] Event Scheduler: Loaded 0 events
  108. 2018-03-22T08:33:07.150249Z 0 [Note] /usr/local/mysql/bin/mysqld: ready for connections.
  109. Version: '5.7.21-20-29.26-log' socket: '/tmp/mysql.sock' port: 3306 Percona XtraDB Cluster binary (GPL) 5.7.21-29.26, Revision 1702aea, wsrep_29.26
  110. 2018-03-22T08:33:07.151857Z 2 [Note] WSREP: Initialized wsrep sidno 2
  111. 2018-03-22T08:33:07.151890Z 2 [Note] WSREP: wsrep_notify_cmd is not defined, skipping notification.
  112. 2018-03-22T08:33:07.151912Z 2 [Note] WSREP: REPL Protocols: 8 (3, 2)
  113. 2018-03-22T08:33:07.151920Z 2 [Note] WSREP: Assign initial position for certification: 0, protocol version: 3
  114. 2018-03-22T08:33:07.151957Z 0 [Note] WSREP: Service thread queue flushed.
  115. 2018-03-22T08:33:07.152114Z 2 [Note] WSREP: GCache history reset: 00000000-0000-0000-0000-000000000000:0 -> a5283990-2dab-11e8-abe5-f600706598d2:0
  116. 2018-03-22T08:33:07.154210Z 2 [Note] WSREP: Synchronized with group, ready for connections
  117. 2018-03-22T08:33:07.154222Z 2 [Note] WSREP: Setting wsrep_ready to true
  118. 2018-03-22T08:33:07.154232Z 2 [Note] WSREP: wsrep_notify_cmd is not defined, skipping notification.

Node1启动完成后,我们登录数据库更改密码新建SST账号

  1. alter user user() identified by '123456';
  2. grant reload, lock tables, replication client, process on *.* to 'sst'@'localhost' identified by 'xuclxucl';

4.其他节点启动
node2、node3不需要初始化,可以直接启动

  1. /usr/local/mysql/bin/mysqld --defaults-file=/data/pxc/my.cnf &

查看error.log

  1. [root@localhost data]# cat error.log
  2. 2018-03-22T08:50:31.025706Z 0 [Warning] The syntax '--log_warnings/-W' is deprecated and will be removed in a future release. Please use '--log_error_verbosity' instead.
  3. 2018-03-22T08:50:31.025879Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  4. 2018-03-22T08:50:31.025949Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
  5. 2018-03-22T08:50:31.025976Z 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.7.21-20-29.26-log) starting as process 7391 ...
  6. 2018-03-22T08:50:31.028667Z 0 [Note] WSREP: Setting wsrep_ready to false
  7. 2018-03-22T08:50:31.028679Z 0 [Note] WSREP: No pre-stored wsrep-start position found. Skipping position initialization.
  8. 2018-03-22T08:50:31.028682Z 0 [Note] WSREP: wsrep_load(): loading provider library '/usr/local/mysql/lib/libgalera_smm.so'
  9. 2018-03-22T08:50:31.031904Z 0 [Note] WSREP: wsrep_load(): Galera 3.26(r) by Codership Oy <info@codership.com> loaded successfully.
  10. 2018-03-22T08:50:31.032279Z 0 [Note] WSREP: CRC-32C: using hardware acceleration.
  11. 2018-03-22T08:50:31.032549Z 0 [Warning] WSREP: Could not open state file for reading: '/data/pxc/mysql3306/data//grastate.dat'
  12. 2018-03-22T08:50:31.032586Z 0 [Warning] WSREP: No persistent state found. Bootstraping with default state
  13. 2018-03-22T08:50:31.032649Z 0 [Note] WSREP: Found saved state: 00000000-0000-0000-0000-000000000000:-1, safe_to_bootstrap: 1
  14. 2018-03-22T08:50:31.043831Z 0 [Note] WSREP: Passing config to GCS: base_dir = /data/pxc/mysql3306/data/; base_host = 192.168.50.4; base_port = 4567; cert.log_conflicts = no; debug = no; evs.auto_evict = 0; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT15S; evs.join_retrans_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 10; evs.stats_report_period = PT1M; evs.suspect_timeout = PT5S; evs.user_send_window = 4; evs.view_forget_timeout = PT24H; gcache.dir = /data/pxc/mysql3306/data/; gcache.freeze_purge_at_seqno = -1; gcache.keep_pages_count = 0; gcache.keep_pages_size = 0; gcache.mem_size = 0; gcache.name = /data/pxc/mysql3306/data//galera.cache; gcache.page_size = 128M; gcache.recover = no; gcache.size = 128M; gcomm.thread_prio = ; gcs.fc_debug = 0; gcs.fc_factor = 1; gcs.fc_limit = 100; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; gcs.recv_q_hard_limit = 9223372036854775807; gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; gmcast.segment = 0; gmcast.version = 0; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; pc.ignore_sb = false; pc.npvo = false; pc.recovery = 1; pc.version = 0; pc.wait_prim = true; pc.wait_prim_timeout = PT30S; pc.weight = 1; protonet.backend = asio; protonet.version = 0; repl.causal_read_timeout = PT30S; repl.commit_order = 3; repl.key_format = FLAT8; repl.max_ws_size = 2147483647; repl.proto_max = 8; socket.checksum = 2; socket.recv_buf_size = 212992;
  15. 2018-03-22T08:50:31.056944Z 0 [Note] WSREP: GCache history reset: 00000000-0000-0000-0000-000000000000:0 -> 00000000-0000-0000-0000-000000000000:-1
  16. 2018-03-22T08:50:31.058840Z 0 [Note] WSREP: Assign initial position for certification: -1, protocol version: -1
  17. 2018-03-22T08:50:31.058868Z 0 [Note] WSREP: Preparing to initiate SST/IST
  18. 2018-03-22T08:50:31.058871Z 0 [Note] WSREP: Starting replication
  19. 2018-03-22T08:50:31.058882Z 0 [Note] WSREP: Setting initial position to 00000000-0000-0000-0000-000000000000:-1
  20. 2018-03-22T08:50:31.059050Z 0 [Note] WSREP: Using CRC-32C for message checksums.
  21. 2018-03-22T08:50:31.059114Z 0 [Note] WSREP: gcomm thread scheduling priority set to other:0
  22. 2018-03-22T08:50:31.059200Z 0 [Warning] WSREP: Fail to access the file (/data/pxc/mysql3306/data//gvwstate.dat) error (No such file or directory). It is possible if node is booting for first time or re-booting after a graceful shutdown
  23. 2018-03-22T08:50:31.059205Z 0 [Note] WSREP: Restoring primary-component from disk failed. Either node is booting for first time or re-booting after a graceful shutdown
  24. 2018-03-22T08:50:31.059519Z 0 [Note] WSREP: GMCast version 0
  25. 2018-03-22T08:50:31.059519Z 0 [Note] WSREP: (13906f3a, 'tcp://0.0.0.0:4567') listening at tcp://0.0.0.0:4567
  26. 2018-03-22T08:50:31.059519Z 0 [Note] WSREP: (13906f3a, 'tcp://0.0.0.0:4567') multicast: , ttl: 1
  27. 2018-03-22T08:50:31.059558Z 0 [Note] WSREP: EVS version 0
  28. 2018-03-22T08:50:31.059640Z 0 [Note] WSREP: gcomm: connecting to group 'pxc_wubx', peer '192.168.50.3:,192.168.50.4:,192.168.50.5:'
  29. 2018-03-22T08:50:31.061708Z 0 [Note] WSREP: (13906f3a, 'tcp://0.0.0.0:4567') connection established to 13906f3a tcp://192.168.50.4:4567
  30. 2018-03-22T08:50:31.061734Z 0 [Warning] WSREP: (13906f3a, 'tcp://0.0.0.0:4567') address 'tcp://192.168.50.4:4567' points to own listening address, blacklisting
  31. 2018-03-22T08:50:31.062344Z 0 [Note] WSREP: (13906f3a, 'tcp://0.0.0.0:4567') connection established to a5272275 tcp://192.168.50.3:4567
  32. 2018-03-22T08:50:31.062536Z 0 [Note] WSREP: (13906f3a, 'tcp://0.0.0.0:4567') turning message relay requesting on, nonlive peers:
  33. 2018-03-22T08:50:31.324478Z 0 [Note] WSREP: declaring a5272275 at tcp://192.168.50.3:4567 stable
  34. 2018-03-22T08:50:31.325151Z 0 [Note] WSREP: Node a5272275 state primary
  35. 2018-03-22T08:50:31.325520Z 0 [Note] WSREP: Current view of cluster as seen by this node
  36. view (view_id(PRIM,13906f3a,4)
  37. memb {
  38. 13906f3a,0
  39. a5272275,0
  40. }
  41. joined {
  42. }
  43. left {
  44. }
  45. partitioned {
  46. }
  47. )
  48. 2018-03-22T08:50:31.325537Z 0 [Note] WSREP: Save the discovered primary-component to disk
  49. 2018-03-22T08:50:31.325775Z 0 [Note] WSREP: discarding pending addr without UUID: tcp://192.168.50.5:4567
  50. 2018-03-22T08:50:31.562109Z 0 [Note] WSREP: gcomm: connected
  51. 2018-03-22T08:50:31.562177Z 0 [Note] WSREP: Shifting CLOSED -> OPEN (TO: 0)
  52. 2018-03-22T08:50:31.562231Z 0 [Note] WSREP: Waiting for SST/IST to complete.
  53. 2018-03-22T08:50:31.562398Z 0 [Note] WSREP: New COMPONENT: primary = yes, bootstrap = no, my_idx = 0, memb_num = 2
  54. 2018-03-22T08:50:31.562767Z 0 [Note] WSREP: STATE_EXCHANGE: sent state UUID: 13dd3684-2dae-11e8-b51f-320ac4fc3dca
  55. 2018-03-22T08:50:31.563236Z 0 [Note] WSREP: STATE EXCHANGE: sent state msg: 13dd3684-2dae-11e8-b51f-320ac4fc3dca
  56. 2018-03-22T08:50:31.563752Z 0 [Note] WSREP: STATE EXCHANGE: got state msg: 13dd3684-2dae-11e8-b51f-320ac4fc3dca from 0 (localhost.localdomain)
  57. 2018-03-22T08:50:31.564081Z 0 [Note] WSREP: STATE EXCHANGE: got state msg: 13dd3684-2dae-11e8-b51f-320ac4fc3dca from 1 (localhost.localdomain)
  58. 2018-03-22T08:50:31.564099Z 0 [Note] WSREP: Quorum results:
  59. version = 4,
  60. component = PRIMARY,
  61. conf_id = 3,
  62. members = 1/2 (primary/total),
  63. act_id = 4,
  64. last_appl. = -1,
  65. protocols = 0/8/3 (gcs/repl/appl),
  66. group UUID = a5283990-2dab-11e8-abe5-f600706598d2
  67. 2018-03-22T08:50:31.564104Z 0 [Note] WSREP: Flow-control interval: [141, 141]
  68. 2018-03-22T08:50:31.564107Z 0 [Note] WSREP: Trying to continue unpaused monitor
  69. 2018-03-22T08:50:31.564109Z 0 [Note] WSREP: Shifting OPEN -> PRIMARY (TO: 4)
  70. 2018-03-22T08:50:31.564163Z 2 [Note] WSREP: State transfer required:
  71. Group state: a5283990-2dab-11e8-abe5-f600706598d2:4
  72. Local state: 00000000-0000-0000-0000-000000000000:-1
  73. 2018-03-22T08:50:31.564174Z 2 [Note] WSREP: New cluster view: global state: a5283990-2dab-11e8-abe5-f600706598d2:4, view# 4: Primary, number of nodes: 2, my index: 0, protocol version 3
  74. 2018-03-22T08:50:31.564176Z 2 [Note] WSREP: Setting wsrep_ready to true
  75. 2018-03-22T08:50:31.564180Z 2 [Warning] WSREP: Gap in state sequence. Need state transfer.
  76. 2018-03-22T08:50:31.564182Z 2 [Note] WSREP: Setting wsrep_ready to false
  77. 2018-03-22T08:50:31.564248Z 0 [Note] WSREP: Initiating SST/IST transfer on JOINER side (wsrep_sst_xtrabackup-v2 --role 'joiner' --address '192.168.50.4' --datadir '/data/pxc/mysql3306/data/' --defaults-file '/data/pxc/my.cnf' --defaults-group-suffix '' --parent '7391' '' )
  78. 2018-03-22T08:50:32.141960Z 2 [Note] WSREP: Prepared SST/IST request: xtrabackup-v2|192.168.50.4:4444/xtrabackup_sst//1
  79. 2018-03-22T08:50:32.141982Z 2 [Note] WSREP: wsrep_notify_cmd is not defined, skipping notification.
  80. 2018-03-22T08:50:32.142000Z 2 [Note] WSREP: REPL Protocols: 8 (3, 2)
  81. 2018-03-22T08:50:32.142014Z 2 [Note] WSREP: Assign initial position for certification: 4, protocol version: 3
  82. 2018-03-22T08:50:32.142036Z 0 [Note] WSREP: Service thread queue flushed.
  83. 2018-03-22T08:50:32.142051Z 2 [Note] WSREP: Check if state gap can be serviced using IST
  84. 2018-03-22T08:50:32.142061Z 2 [Note] WSREP: Local UUID: 00000000-0000-0000-0000-000000000000 != Group UUID: a5283990-2dab-11e8-abe5-f600706598d2
  85. 2018-03-22T08:50:32.142096Z 2 [Note] WSREP: State gap can't be serviced using IST. Switching to SST
  86. 2018-03-22T08:50:32.142146Z 2 [Note] WSREP: Failed to prepare for incremental state transfer: Local state UUID (00000000-0000-0000-0000-000000000000) does not match group state UUID (a5283990-2dab-11e8-abe5-f600706598d2): 1 (Operation not permitted)
  87. at galera/src/replicator_str.cpp:prepare_for_IST():538. IST will be unavailable.
  88. 2018-03-22T08:50:32.146597Z 0 [Note] WSREP: Member 0.0 (localhost.localdomain) requested state transfer from '*any*'. Selected 1.0 (localhost.localdomain)(SYNCED) as donor.
  89. 2018-03-22T08:50:32.146641Z 0 [Note] WSREP: Shifting PRIMARY -> JOINER (TO: 4)
  90. 2018-03-22T08:50:32.146756Z 2 [Note] WSREP: Requesting state transfer: success, donor: 1
  91. 2018-03-22T08:50:32.146778Z 2 [Note] WSREP: GCache history reset: 00000000-0000-0000-0000-000000000000:0 -> a5283990-2dab-11e8-abe5-f600706598d2:4
  92. 2018-03-22T08:50:32.858690Z WSREP_SST: [INFO] WARNING: Stale temporary SST directory: /data/pxc/mysql3306/data//.sst from previous state transfer. Removing
  93. 2018-03-22T08:50:32.861937Z WSREP_SST: [INFO] Proceeding with SST.........
  94. 2018-03-22T08:50:32.886694Z WSREP_SST: [INFO] ............Waiting for SST streaming to complete!
  95. 2018-03-22T08:50:34.068994Z 0 [Note] WSREP: (13906f3a, 'tcp://0.0.0.0:4567') turning message relay requesting off
  96. 2018-03-22T08:50:45.608868Z 0 [Note] WSREP: 1.0 (localhost.localdomain): State transfer to 0.0 (localhost.localdomain) complete.
  97. 2018-03-22T08:50:45.612112Z 0 [Note] WSREP: Member 1.0 (localhost.localdomain) synced with group.
  98. 2018-03-22T08:50:45.613446Z WSREP_SST: [INFO] Preparing the backup at /data/pxc/mysql3306/data//.sst

节点3同节点2

5.查看各节点状态

  1. mysql> show global status like '%wsrep%';
  2. +----------------------------------+--------------------------------------+
  3. | Variable_name | Value |
  4. +----------------------------------+--------------------------------------+
  5. | wsrep_local_state_uuid | a5283990-2dab-11e8-abe5-f600706598d2 |
  6. | wsrep_protocol_version | 8 |
  7. | wsrep_last_applied | 4 |
  8. | wsrep_last_committed | 4 |
  9. | wsrep_replicated | 4 |
  10. | wsrep_replicated_bytes | 952 |
  11. | wsrep_repl_keys | 4 |
  12. | wsrep_repl_keys_bytes | 128 |
  13. | wsrep_repl_data_bytes | 553 |
  14. | wsrep_repl_other_bytes | 0 |
  15. | wsrep_received | 11 |
  16. | wsrep_received_bytes | 934 |
  17. | wsrep_local_commits | 0 |
  18. | wsrep_local_cert_failures | 0 |
  19. | wsrep_local_replays | 0 |
  20. | wsrep_local_send_queue | 0 |
  21. | wsrep_local_send_queue_max | 1 |
  22. | wsrep_local_send_queue_min | 0 |
  23. | wsrep_local_send_queue_avg | 0.000000 |
  24. | wsrep_local_recv_queue | 0 |
  25. | wsrep_local_recv_queue_max | 3 |
  26. | wsrep_local_recv_queue_min | 0 |
  27. | wsrep_local_recv_queue_avg | 0.363636 |
  28. | wsrep_local_cached_downto | 1 |
  29. | wsrep_flow_control_paused_ns | 0 |
  30. | wsrep_flow_control_paused | 0.000000 |
  31. | wsrep_flow_control_sent | 0 |
  32. | wsrep_flow_control_recv | 0 |
  33. | wsrep_flow_control_interval | [ 141, 141 ] |
  34. | wsrep_flow_control_interval_low | 141 |
  35. | wsrep_flow_control_interval_high | 141 |
  36. | wsrep_flow_control_status | OFF |
  37. | wsrep_cert_deps_distance | 1.000000 |
  38. | wsrep_apply_oooe | 0.000000 |
  39. | wsrep_apply_oool | 0.000000 |
  40. | wsrep_apply_window | 1.000000 |
  41. | wsrep_commit_oooe | 0.000000 |
  42. | wsrep_commit_oool | 0.000000 |
  43. | wsrep_commit_window | 1.000000 |
  44. | wsrep_local_state | 4 |
  45. | wsrep_local_state_comment | Synced |
  46. | wsrep_cert_index_size | 1 |
  47. | wsrep_cert_bucket_count | 22 |
  48. | wsrep_gcache_pool_size | 2704 |
  49. | wsrep_causal_reads | 0 |
  50. | wsrep_cert_interval | 0.000000 |
  51. | wsrep_ist_receive_status | |
  52. | wsrep_ist_receive_seqno_start | 0 |
  53. | wsrep_ist_receive_seqno_current | 0 |
  54. | wsrep_ist_receive_seqno_end | 0 |
  55. | wsrep_incoming_addresses | 192.168.50.4:3306,192.168.50.3:3306 |
  56. | wsrep_desync_count | 0 |
  57. | wsrep_evs_delayed | |
  58. | wsrep_evs_evict_list | |
  59. | wsrep_evs_repl_latency | 0/0/0/0/0 |
  60. | wsrep_evs_state | OPERATIONAL |
  61. | wsrep_gcomm_uuid | a5272275-2dab-11e8-9ba0-4b7e19a09c41 |
  62. | wsrep_cluster_conf_id | 4 |
  63. | wsrep_cluster_size | 2 |
  64. | wsrep_cluster_state_uuid | a5283990-2dab-11e8-abe5-f600706598d2 |
  65. | wsrep_cluster_status | Primary |
  66. | wsrep_connected | ON |
  67. | wsrep_local_bf_aborts | 0 |
  68. | wsrep_local_index | 1 |
  69. | wsrep_provider_name | Galera |
  70. | wsrep_provider_vendor | Codership Oy <info@codership.com> |
  71. | wsrep_provider_version | 3.26(r) |
  72. | wsrep_ready | ON |
  73. +----------------------------------+--------------------------------------+
  74. 68 rows in set (0.00 sec)

看到

  1. wsrep_local_state=4
  2. wsrep_local_state_comment = Synced
  3. wsrep_cluster_status = Primary
  4. wsrep_connected = ON

至此,PXC集群搭建完成,下篇会给大家带来PXC原理及日常运维相关操作。