這篇文章主要講解了“centos6.9怎么搭建pxc集群”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“centos6.9怎么搭建pxc集群”吧!

我們提供的服務(wù)有:成都網(wǎng)站制作、做網(wǎng)站、微信公眾號(hào)開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、贛州ssl等。為上1000+企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的贛州網(wǎng)站制作公司
一:環(huán)境介紹:
10.1.32.49
10.1.32.50
10.1.32.36
其中操作系統(tǒng)全部為 :centos 6.9 ,并且49和50是數(shù)據(jù)庫集群的數(shù)據(jù)節(jié)點(diǎn),36為鑒證節(jié)點(diǎn)或者叫選舉節(jié)點(diǎn),安裝的percona 5.6版本,其中鑒證節(jié)點(diǎn)的garb安裝的是garbd-3版本
二:正式安裝:
2.1.首先安裝相關(guān)的yum 源:
1-3版本的yum源:
yum installhttp://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm
1-4版本的yum源:(一般選擇新版本)
yum install http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm
裝一些centos源里面沒有的軟件的源
yum install http://mirrors.ustc.edu.cn/fedora/epel/6/i386/epel-release-6-8.noarch.rpm
查看關(guān)于percona的yum源存在否:
[root@ory-newcaiwu-MySQL-02 ~]# rpm -qa | grep percona
percona-xtrabackup-24-2.4.9-1.el6.x86_64
percona-release-0.1-4.noarch
percona-toolkit-3.0.6-1.el6.x86_64
2.2 關(guān)閉防火墻和 Selinux
service iptables stop
chkconfig iptables off
vi /etc/selinux/config
SELINUX=disabled
2.2.查看已經(jīng)安裝的Percona的版本,如果不是自己需要的,那么卸載掉,防止沖突!
[root@ory-newcaiwu-mysql-01 ~]# yum list Percona*
或者
[root@ory-newcaiwu-mysql-02 ~]# rpm -qa | grep Percona*
卸載系統(tǒng)本身有的Percona
[root@ory-newcaiwu-mysql-01 ~]# yum remove Percona*
安裝pxc具體需要安裝下面幾個(gè)包,真正安裝的時(shí)候只需要Percona-XtraDB-Cluster-server-56即可,其余的都作為依賴包自動(dòng)安裝上了!
yum -y install Percona-XtraDB-Cluster-server Percona-XtraDB-Cluster-client Percona-Server-shared-compat percona-xtrabackup
查看Percona的各個(gè)版本的包的名字,以便于具體選擇特定的版本:
[root@ory-newcaiwu-mysql-02 ~]# rpm -qa | grep Percona*
2.3使用yum安裝,只需要安裝 Percona-XtraDB-Cluster-server即可,別的都是他的依賴包,一并都給自動(dòng)安裝了,如下我們選擇的是5.6版本的mysql:
[root@ory-newcaiwu-mysql-02 ~]# yum install -y Percona-XtraDB-Cluster-server-56
2.4.然后配置參數(shù)/etc/my.cnf,兩個(gè)數(shù)據(jù)節(jié)點(diǎn)配置參數(shù)基本相同,需要改個(gè)別參數(shù);
[mysqld]
# GENERAL
datadir = /data/mysqldata
tmpdir = /tmp
socket = /data/mysqldata/mysql.sock
pid_file = /data/mysqldata/mysql.pid
user = mysql
port = 3306
character-set-server = utf8
bind-address = 0.0.0.0
server-id = 1013250
skip-name-resolve
lower_case_table_names = 1
# INNODB
# This changes how |InnoDB| autoincrement locks are managed and is a requirement for Galera
innodb_autoinc_lock_mode = 2
innodb_buffer_pool_size = 90G
innodb_buffer_pool_instances = 8
innodb_thread_concurrency = 40
innodb_log_buffer_size = 32M
innodb_log_file_size = 1024M
innodb_online_alter_log_max_size = 512M
innodb_open_files = 65535
innodb_purge_threads = 8
innodb_data_home_dir = /data/mysqldata
innodb_data_file_path = ibdata1:256M:autoextend
innodb_read_io_threads = 8
innodb_write_io_threads = 8
innodb_file_per_table = 1
innodb_flush_method = O_DIRECT
innodb_flush_log_at_trx_commit = 2
innodb_max_dirty_pages_pct = 90
innodb_file_format = Barracuda
innodb_file_format_max = Barracuda
innodb_io_capacity = 512
innodb_io_capacity_max = 4096
#event_scheduler = OFF
# MyISAM
key_buffer_size = 32M
# LOGS
#general_log = 1
#general_log_file = /data/logs/mysql/mysql_general.log
log_warnings = 2
log_error = /data/logs/mysql/mysql_error.log
slow_query_log = ON
slow_query_log_file = /data/logs/mysql/mysql_slow.log
log_queries_not_using_indexes = 0
long_query_time = 1
expire_logs_days = 15
log-bin = mysql-bin.log
innodb_print_all_deadlocks = 1
relay-log = relay-log
relay-log-index = relay-log
log_bin_trust_function_creators = 1
# BINLOG
# In order for Galera to work correctly binlog format should be ROW
binlog_format = ROW
binlog_cache_size = 32M
max_binlog_size = 512M
log_bin_trust_function_creators = 1
# OTHER
default_storage_engine = InnoDB
tmp_table_size = 32M
max_heap_table_size = 128M
query_cache_type = 0
query_cache_size = 0M
max_connections = 1024
thread_cache_size = 600
open_files_limit = 65535
innodb_buffer_pool_load_at_startup = ON
innodb_buffer_pool_dump_at_shutdown = ON
auto_increment_offset = 1
optimizer-switch = "mrr=on,mrr_cost_based=off,batched_key_access=on"
join_buffer_size = 16M
expand_fast_index_creation = 1
sort_buffer_size = 16M
max_allowed_packet = 16M
sql_mode = STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION
# WSREP
wsrep_auto_increment_control = OFF
# Path to Galera library
wsrep_provider = /usr/lib64/libgalera_smm.so
# Cluster connection URL
wsrep_cluster_address = gcomm://10.1.32.49:4567,10.1.32.50:4567
# Node #1 address
wsrep_node_address = 10.1.32.50 # local IP
# SST method
wsrep_sst_method = xtrabackup-v2
# Cluster name
wsrep_cluster_name = XFXJ_CAIWU_CLUSTER
# Authentication for SST method
wsrep_sst_auth = "sstuser:LLivTGmIWpVohjMD"
wsrep_max_ws_rows = 500000
wsrep_max_ws_size = 2147483647
wsrep_slave_threads = 40
wsrep_provider_options = "gcache.size=32G; gcache.page_size=512M; gcs.fc_limit = 4096;gcs.fc_master_slave = yes"
#Replication
log_slave_updates = 1
slave_parallel_worker = 4
gtid-mode = on
enforce_gtid_consistency = true
binlog_checksum = CRC32
slave_allow_batching = 1
master_verify_checksum = 1
slave_sql_verify_checksum = 1
master_info_repository = TABLE
relay_log_info_repository = TABLE
[client]
socket = /data/mysqldata/mysql.sock
port = 3306
#default_character_set = utf8
[mysql]
default-character-set = utf8
prompt ="\\u@\\h : \\d \\R:\\m:\\s>"
no-auto-rehash
2.5初始化數(shù)據(jù)庫主節(jié)點(diǎn):其他的不用刻意的初始化,因?yàn)榈饶銌?dòng)第二個(gè)節(jié)點(diǎn)的時(shí)候他會(huì)sst同步給第二個(gè)節(jié)點(diǎn)
mysql_install_db --defaults-file=/etc/my.cnf --user=mysql
2.6.刪除匿名賬號(hào)
mysql -e "delete from mysql.user where user=' ';delete from mysql.user where user='';flush privileges;"
2.7.給管理員賬號(hào)設(shè)密碼
mysqladmin -u root password $password
2.8.每臺(tái)機(jī)器mysql添加SST賬戶
其實(shí)只需要在主節(jié)點(diǎn)添加即可,因?yàn)榈饶銌?dòng)第二個(gè)節(jié)點(diǎn)的時(shí)候他會(huì)sst同步給第二個(gè)節(jié)點(diǎn),那么用戶也會(huì)同步過去。注意用戶名和密碼需要在參數(shù)wsrep_sst_auth中對(duì)應(yīng)!
CREATE USER 'sstuser'@'localhost' IDENTIFIED BY 'liuwenhe';
GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT,PROCESS ON *.* TO 'sstuser'@'localhost';
2.9.啟動(dòng)主節(jié)點(diǎn)(以bootstrap-pxc方式啟動(dòng)):
[root@ory-newcaiwu-mysql-01 ~]# /etc/init.d/mysql #顯示mysql啟動(dòng)全部方式!
Usage: mysql {start|stop|restart|restart-bootstrap|reload|force-reload|status|bootstrap-pxc} [ MySQL (Percona XtraDB Cluster) options ]
以bootstrap-pxc方式啟動(dòng):
[root@ory-newcaiwu-mysql-01 ~]# /etc/init.d/mysql bootstrap-pxc
3.0.啟動(dòng)節(jié)點(diǎn)32.50,會(huì)自動(dòng)觸發(fā)集群主節(jié)點(diǎn)32.49給它全量同步數(shù)據(jù)(也就是sst)
[root@ory-newcaiwu-mysql-02 mysqldata]# /etc/init.d/mysql start
Starting MySQL (Percona XtraDB Cluster)...State transfer in progress, setting sleep higher
.... [ OK ]
三:32.36上 鑒證節(jié)點(diǎn)相關(guān)操作:
3.1.安裝garb服務(wù):
[root@ory-fanxiqian-Oracle-01 ~]# yum install Percona-XtraDB-Cluster-garbd-3
3.2.配置gab參數(shù):
[root@ory-fanxiqian-Oracle-01 ~]# cat /etc/sysconfig/garb
# A comma-separated list of node addresses (address[:port]) in the cluster
GALERA_NODES="10.1.32.36:4567 10.1.32.49:4567 10.1.32.50:4567"
# Galera cluster name, should be the same as on the rest of the nodes.
GALERA_GROUP="XFXJ_CAIWU_CLUSTER"
# Optional Galera internal options string (e.g. SSL settings)
# see http://galeracluster.com/documentation-webpages/galeraparameters.html
# GALERA_OPTIONS=""
# Log file for garbd. Optional, by default logs to syslog
# Deprecated for CentOS7, use journalctl to query the log for garbd
LOG_FILE="/tmp/garbd.log"
3.3.啟動(dòng)gab服務(wù):
root@localhost : (none) 17:57:32>show status like 'wsrep_cluster_size';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| wsrep_cluster_size | 2 |
+--------------------+-------+
1 row in set (0.00 sec)
[root@ory-fanxiqian-Oracle-01 ~]# /etc/init.d/garb start
其中時(shí)候你會(huì)發(fā)現(xiàn)集群節(jié)點(diǎn)數(shù)量增加了1,由2變成了3;
root@localhost : (none) 17:57:32>show status like 'wsrep_cluster_size';
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| wsrep_cluster_size | 3 |
+--------------------+-------+
1 row in set (0.00 sec)
感謝各位的閱讀,以上就是“centos6.9怎么搭建pxc集群”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對(duì)centos6.9怎么搭建pxc集群這一問題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!
文章標(biāo)題:centos6.9怎么搭建pxc集群
文章網(wǎng)址:http://www.chinadenli.net/article44/piiehe.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供服務(wù)器托管、網(wǎng)站排名、ChatGPT、網(wǎng)站建設(shè)、云服務(wù)器、商城網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)