您的位置:首页 > 数据库 > SQL

percona-xtradb-cluster 部署笔记

2017-09-12 11:01 176 查看
    个人部署PXC集群的相关配置过程及注意事项总结:

1、环境为3台虚拟机centos6.5系统:

192.168.220.160

192.168.220.161

192.168.220.162

2、安装步骤:

下载并安装软件包percona-release-0.1-4.noarch.rpm

通过yum安装Percona-XtraDB-Cluster-server-56(相应一些依赖分支会提示一起安装,输入y即可)

可能会报错提示安装依赖包,按提示安装对应依赖包即可

3、配置:

由于本次部署实在三台虚拟机,配置相对较低,所以配置文件相关参数相应调低或去掉,生产环境可根据情况调高。

用mkdir  -p +路径 命令创建下面配置文件出现的目录(原来可能不存在)

并用chown -R mysql:mysql  +路径 对其授权

下面两个值根据实际情况设置,3个节点需要设置成不同的值:

server_id=

wsrep_node_address

配置文件如下:

/etc/my.cnf

[client]
port                           = 3307
default-character-set       = utf8
socket                         = /var/lib/mysql/mysql.sock
[mysqld]
# GENERAL #
user                           = mysql
default-storage-engine         = InnoDB
skip_name_resolve
character-set-server           = utf8
datadir                        = /var/lib/mysql
socket                         = /var/lib/mysql/mysql.sock
pid_file                       = /var/lib/mysql/mysql.pid
port				= 3307
lower_case_table_names		= 1
explicit_defaults_for_timestamp = true
symbolic-links = 0
large_pages                     = ON
# MyISAM #
# SAFETY #
max_connect_errors             = 1000000
skip_name_resolve

# BINARY LOGGING #
log-bin                        =/data/mysql/binlog/mysql-bin
expire-logs-days               = 30
sync-binlog                    = 0
binlog_cache_size              = 32M
max_binlog_cache_size          = 512M
max_binlog_size                = 512M
slave_skip_errors              = 1032,1062,126,1114,1146,1048,1396
log-slave-updates               = 1

# REPLICATION #
relay-log                      =/opt/mysql/binlog/relay-bin
slave-net-timeout              = 60

# CACHES AND LIMITS #
tmp_table_size                 = 250M
max_heap_table_size            = 250M
query_cache_type               = 0
query_cache_size               = 0
max_connections                = 3000
back_log       = 10240
thread_cache_size              = 5000
open_files_limit               = 20480
table_definition_cache         = 4096
table_open_cache               = 6000
table_open_cache_instances     = 16
sort_buffer_size       = 32M
max_length_for_sort_data = 10240
join_buffer_size       = 32M
read_rnd_buffer_size	       = 32M

# INNODB #
#transaction_isolation          = REPEATABLE-READ
transaction_isolation          = READ-COMMITTED

#init_connect='SET autocommit=0'
init_connect='insert into db_monitor.accesslog(thread_id,log_time,localname,matchname) values(connection_id(),now(),user(),current_user());'
#wait_timeout=100
#interactive_timeout=100

# LOGGING #
log_error                      =/var/lib/mysql/mysql-error.log
log_queries_not_using_indexes  = 0
slow_query_log                 = 1
slow_query_log_file            = /var/lib/mysql/mysql-slow.log
long_query_time			= 0.5

# thread pool
thread_handling = pool-of-threads
thread_pool_oversubscribe = 10

#config for wsrep
server_id=4
wsrep_provider=/usr/lib64/libgalera_smm.so
wsrep_cluster_address=gcomm://192.168.220.160,192.168.220.161,192.168.220.162

binlog_format=ROW
default_storage_engine=InnoDB
innodb_locks_unsafe_for_binlog=1
innodb_autoinc_lock_mode=2
wsrep_node_address=192.168.220.160
wsrep_sst_method=xtrabackup-v2
wsrep_cluster_name=my_mysql_cluster
wsrep_sst_auth="sstuser:s3cret"
wsrep_slave_threads=2
wsrep_provider_options='gcs.max_packet_size=10485760;gcache.size=2147483648'
wsrep_max_ws_rows=1048576
wsrep_max_ws_size=2147483648
#config for others
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES


4、启动及验证:
由于第一次启动, 首先启动第一节点/etc/init.d/mysql bootstrap-px 接着另外两个节点/etc/init.d/mysql start

mysql> show status like '%wsrep%';
+------------------------------+----------------------------------------------------------------+
| Variable_name                | Value                                                          |
+------------------------------+----------------------------------------------------------------+
| wsrep_local_state_uuid       | 7afea44d-979b-11e7-a99a-8ed9d6280c37                           |
| wsrep_protocol_version       | 7                                                              |
| wsrep_last_committed         | 3                                                              |
| wsrep_replicated             | 0                                                              |
| wsrep_replicated_bytes       | 0                                                              |
| wsrep_repl_keys              | 0                                                              |
| wsrep_repl_keys_bytes        | 0                                                              |
| wsrep_repl_data_bytes        | 0                                                              |
| wsrep_repl_other_bytes       | 0                                                              |
| wsrep_received               | 4                                                              |
| wsrep_received_bytes         | 728                                                            |
| wsrep_local_commits          | 0                                                              |
| wsrep_local_cert_failures    | 0                                                              |
| wsrep_local_replays          | 0                                                              |
| wsrep_local_send_queue       | 0                                                              |
| wsrep_local_send_queue_max   | 1                                                              |
| wsrep_local_send_queue_min   | 0                                                              |
| wsrep_local_send_queue_avg   | 0.000000                                                       |
| wsrep_local_recv_queue       | 0                                                              |
| wsrep_local_recv_queue_max   | 2                                                              |
| wsrep_local_recv_queue_min   | 0                                                              |
| wsrep_local_recv_queue_avg   | 0.250000                                                       |
| wsrep_local_cached_downto    | 0                                                              |
| wsrep_flow_control_paused_ns | 0                                                              |
| wsrep_flow_control_paused    | 0.000000                                                       |
| wsrep_flow_control_sent      | 0                                                              |
| wsrep_flow_control_recv      | 0                                                              |
| wsrep_cert_deps_distance     | 0.000000                                                       |
| wsrep_apply_oooe             | 0.000000                                                       |
| wsrep_apply_oool             | 0.000000                                                       |
| wsrep_apply_window           | 0.000000                                                       |
| wsrep_commit_oooe            | 0.000000                                                       |
| wsrep_commit_oool            | 0.000000                                                       |
| wsrep_commit_window          | 0.000000                                                       |
| wsrep_local_state            | 4                                                              |
| wsrep_local_state_comment    | Synced                                                         |
| wsrep_cert_index_size        | 0                                                              |
| wsrep_cert_bucket_count      | 22                                                             |
| wsrep_gcache_pool_size       | 1320                                                           |
| wsrep_causal_read
b2a2
s           | 0                                                              |
| wsrep_cert_interval          | 0.000000                                                       |
| wsrep_incoming_addresses     | 192.168.220.160:3307,192.168.220.161:3307,192.168.220.162:3307 |
| wsrep_desync_count           | 0                                                              |
| wsrep_evs_delayed            |                                                                |
| wsrep_evs_evict_list         |                                                                |
| wsrep_evs_repl_latency       | 0.00166187/0.00451718/0.0104513/0.00354648/4                   |
| wsrep_evs_state              | OPERATIONAL                                                    |
| wsrep_gcomm_uuid             | 5398f7f7-97a2-11e7-80ad-5a153937fe9d                           |
| wsrep_cluster_conf_id        | 3                                                              |
| wsrep_cluster_size           | 3                                                              |
| wsrep_cluster_state_uuid     | 7afea44d-979b-11e7-a99a-8ed9d6280c37                           |
| wsrep_cluster_status         | Primary                                                        |
| wsrep_connected              | ON                                                             |
| wsrep_local_bf_aborts        | 0                                                              |
| wsrep_local_index            | 0                                                              |
| wsrep_provider_name          | Galera                                                         |
| wsrep_provider_vendor        | Codership Oy                               |
| wsrep_provider_version       | 3.20(r7e383f7)                                                 |
| wsrep_ready                  | ON                                                             |
+------------------------------+----------------------------------------------------------------+
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息