mysql PXC 安装

导言
实验环境说明:
OS版本	CentOS7
PXC版本	Percona-XtraDB-Cluster-5.7.18-rel15-29.20.1.Linux.x86_64.ssl101.tar.gz
Xtrabackup版本	percona-xtrabackup-24-2.4.7-2.el6.x86_64.rpm

服务器说明:
主机名称	IP	配置	用途
c1	10.194.41.231	1核1G	主节点之一,需安装PXC、
Xtrabackup
c2	10.194.41.227	1核1G	主节点之一,需安装PXC、
Xtrabackup
c3	10.194.41.228	1核1G	主节点之一,需安装PXC、
Xtrabackup

配置环境
•	安装epel源(所有节点)
centos6
 rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
centos7
 rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

•	安装依赖包
yum install perl-IO-Socket-SSL perl-DBD-MySQL perl-Time-HiRes socat nc -y

•	安装xtrabackup
wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.7/binary/redhat/6/x86_64/percona-xtrabackup-24-2.4.7-2.el6.x86_64.rpm
rpm -ivh percona-xtrabackup-24-2.4.7-2.el6.x86_64.rpm


安装配置PXC
•	数据库初始化
shell#>tar-zxvf  /mnt/Percona-XtraDB-Cluster-5.7.18-rel15-29.20.1.Linux.x86_64.ssl101.tar.gz
shell#>ln -s /mnt/Percona-XtraDB-Cluster-5.7.18-rel15-29.20.1.Linux.x86_64.ssl101 /usr/local/mysql
shell#>mkdir -p /data/mysql/mysql3306/{data,logs,tmp}
shell#>groupadd mysql && useradd -M -g mysql -s /sbin/nologin -d /usr/local/mysql mysql
shell#>chown -R mysql:mysql /data/mysql/ /usr/local/mysql/
shell#>echo 'export PATH=/usr/local/mysql/bin:$PATH' >> /etc/profile && source /etc/profile
shell#>/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql/mysql3306/data  --user=mysql --initialize
•	my.cnf
[client]
port    = 3306
socket    = /tmp/mysql.sock

[mysql]
prompt="\u@c1 \R:\m:\s [\d]> "
no-auto-rehash

[mysqld]
user    = mysql
port    = 3306
basedir    = /usr/local/mysql
datadir    = /data/mysql/mysql3306/data
socket    = /tmp/mysql.sock
pid-file = c1.pid
character-set-server = utf8mb4
skip_name_resolve = 1
open_files_limit    = 65535
back_log = 1024
max_connections = 20
max_connect_errors = 1000000
table_open_cache = 40
table_definition_cache = 40
table_open_cache_instances = 64
thread_stack = 512K
external-locking = FALSE
max_allowed_packet = 32M
sort_buffer_size = 4M
join_buffer_size = 4M
thread_cache_size = 30
query_cache_size = 0
query_cache_type = 0
interactive_timeout = 600
wait_timeout = 600
tmp_table_size = 32M
max_heap_table_size = 32M
slow_query_log = 1
slow_query_log_file = /data/mysql/mysql3306/data/slow.log
log-error = /data/mysql/mysql3306/data/error.log
long_query_time = 1
log_queries_not_using_indexes =1
log_throttle_queries_not_using_indexes = 60
min_examined_row_limit = 100
log_slow_admin_statements = 1
log_slow_slave_statements = 1
server-id = 3306
log-bin = /data/mysql/mysql3306/logs/mysql-bin
sync_binlog = 1
binlog_cache_size = 4M
max_binlog_cache_size = 2G
max_binlog_size = 1G
expire_logs_days = 7
master_info_repository = TABLE
relay_log_info_repository = TABLE
gtid_mode = on
enforce_gtid_consistency = 1
log_slave_updates
binlog_format = row
relay_log_recovery = 1
relay-log-purge = 1
key_buffer_size = 32M
read_buffer_size = 8M
read_rnd_buffer_size = 4M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
lock_wait_timeout = 3600
explicit_defaults_for_timestamp = 1
innodb_thread_concurrency = 0
innodb_sync_spin_loops = 100
innodb_spin_wait_delay = 30

transaction_isolation = REPEATABLE-READ
#innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 717M
innodb_buffer_pool_instances = 8
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_data_file_path = ibdata1:1G:autoextend
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 32M
innodb_log_file_size = 2G
innodb_log_files_in_group = 2
innodb_max_undo_log_size = 4G

innodb_io_capacity = 4000
innodb_io_capacity_max = 8000
innodb_flush_neighbors = 0
innodb_write_io_threads = 8
innodb_read_io_threads = 8
innodb_purge_threads = 4
innodb_page_cleaners = 4
innodb_open_files = 65535
innodb_max_dirty_pages_pct = 50
innodb_flush_method = O_DIRECT
innodb_lru_scan_depth = 4000
innodb_checksum_algorithm = crc32
#innodb_file_format = Barracuda
#innodb_file_format_max = Barracuda
innodb_lock_wait_timeout = 10
innodb_rollback_on_timeout = 1
innodb_print_all_deadlocks = 1
innodb_file_per_table = 1
innodb_online_alter_log_max_size = 4G
internal_tmp_disk_storage_engine = InnoDB
innodb_stats_on_metadata = 0

innodb_status_file = 1
innodb_status_output = 0
innodb_status_output_locks = 0

#performance_schema
performance_schema = 1
performance_schema_instrument = '%=on'

#innodb monitor
innodb_monitor_enable="module_innodb"
innodb_monitor_enable="module_server"
innodb_monitor_enable="module_dml"
innodb_monitor_enable="module_ddl"
innodb_monitor_enable="module_trx"
innodb_monitor_enable="module_os"
innodb_monitor_enable="module_purge"
innodb_monitor_enable="module_log"
innodb_monitor_enable="module_lock"
innodb_monitor_enable="module_buffer"
innodb_monitor_enable="module_index"
innodb_monitor_enable="module_ibuf_system"
innodb_monitor_enable="module_buffer_page"
innodb_monitor_enable="module_adaptive_hash"

[mysqldump]
quick
max_allowed_packet = 32M

•	修改mysqld_safe启动文件
#####具体需要替换的路径根据安装的包名称去mysqld_safe文件中查询#############
sed -i 's#/mnt/workspace/percona-xtradb-cluster-5.7-binary-tarball/label_exp/centos6-64/Percona-XtraDB-Cluster-5.7.18-29.20/346/usr/local/Percona-XtraDB-Cluster-5.7.18-rel15-29.20.1.Linux.x86_64.ssl101#/usr/local/mysql#g' /usr/local/mysql/bin/mysqld_safe

vi /usr/local/mysql/support-files/mysql.server
basedir=/usr/local/mysql
datadir=/data/mysql/mysql3306/data

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

chmod 755 /etc/init.d/mysql

•	添加PXC相关的参数
vi /etc/my.cnf
[mysqld]
...
#PXC
wsrep_provider=/usr/local/mysql/lib/libgalera_smm.so
wsrep_cluster_address=gcomm://10.194.41.231,10.194.41.227,10.194.41.228
wsrep_node_address=10.194.41.231
wsrep_slave_threads=2
innodb_autoinc_lock_mode=2
binlog_format = ROW
default_storage_engine=InnoDB
wsrep_cluster_name=pxc-jiangzq
wsrep_sst_auth=sst:jiangzq
wsrep_sst_method=xtrabackup-v2
•	检查环境
[root@c1 xtrabackup]# /etc/init.d/mysql --help
Usage: mysql {start|stop|restart|restart-bootstrap|reload|force-reload|status|bootstrap-pxc}  [ MySQL (Percona XtraDB Cluster) options ]

•	启动第一个节点
shell>/etc/init.d/mysql bootstrap-pxc

###其他启动方式###
/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf  bootstrap-pxc &
/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf bootstrap-pxc

•	修改root密码和添加sst账户
alter user user() identified by 'evis123';
create user 'sst'@'%' identified by 'evis123';
grant all  on *.* to 'sst'@'%';

•	将整个虚拟机再克隆两个
#####修改主机名
shell>hostname c2
shell>vi /etc/sysconfig/network
hostname=c2
#####修改ip地址
shell>vi /etc/sysconfig/network-script/ifcfg-eth0
shell>service network restart
#####修改mysql配置文件
shell>vi /etc/my.cnf
server-id=203306
pid-file = c2.pid
wsrep_node_address=10.194.41.227
####重新生成UUID######
shell>rm–fr /data/mysql/mysql3306/data/auto.cnf
•	第2、3个节点启动
shell>/etc/init.d/mysql start



  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值