centos 6.9搭建pxc叢集
一:環境介紹:
10.1.32.49
10.1.32.50
10.1.32.36
其中作業系統全部為 :centos 6.9 ,並且49和50是資料庫叢集的資料節點,36為鑑證節點或者叫選舉節點,安裝的percona 5.6版本,其中鑑證節點的garb安裝的是garbd-3版本
二:正式安裝:
2.1.首先安裝相關的yum 源:
1-3版本的yum源:
yum install
1-4版本的yum源:(一般選擇新版本)
yum install
裝一些centos源裡面沒有的軟體的源
yum install
檢視關於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 關閉防火牆和 Selinux
service iptables stop
chkconfig iptables off
vi /etc/selinux/config
SELINUX=disabled
2.2.檢視已經安裝的Percona的版本,如果不是自己需要的,那麼解除安裝掉,防止衝突!
[root@ory-newcaiwu-mysql-01 ~]# yum list Percona*
或者
[root@ory-newcaiwu-mysql-02 ~]# rpm -qa | grep Percona*
解除安裝系統本身有的 Percona
[root@ory-newcaiwu-mysql-01 ~]# yum remove Percona*
安裝pxc具體需要安裝下面幾個包,真正安裝的時候只需要 Percona-XtraDB-Cluster-server-56即可,其餘的都作為依賴包自動安裝上了!
yum -y install Percona-XtraDB-Cluster-server Percona-XtraDB-Cluster-client Percona-Server-shared-compat percona-xtrabackup
檢視Percona的各個版本的包的名字,以便於具體選擇特定的版本:
[root@ory-newcaiwu-mysql-02 ~]# rpm -qa | grep Percona*
2.3使用yum安裝,只需要安裝 Percona-XtraDB-Cluster-server即可,別的都是他的依賴包,一併都給自動安裝了,如下我們選擇的是5.6版本的mysql:
[root@ory-newcaiwu-mysql-02 ~]# yum install -y Percona-XtraDB-Cluster-server-56
2.4.然後配置引數/etc/my.cnf,兩個資料節點配置引數基本相同,需要改個別引數;
[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初始化資料庫主節點:其他的不用刻意的初始化,因為 等你啟動第二個節點的時候他會sst同步給第二個節點
mysql_install_db --defaults-file=/etc/my.cnf --user=mysql
2.6.刪除匿名賬號
mysql -e "delete from mysql.user where user=' ';delete from mysql.user where user='';flush privileges;"
2.7.給管理員賬號設密碼
mysqladmin -u root password $password
2.8.每臺機器mysql新增SST賬戶
其實只需要在主節點新增即可,因為等你啟動第二個節點的時候他會sst同步給第二個節點,那麼使用者也會同步過去。注意使用者名稱和密碼需要在引數wsrep_sst_auth中對應!
CREATE USER 'sstuser' @ 'localhost' IDENTIFIED BY 'liuwenhe' ;
GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT,PROCESS ON *.* TO 'sstuser' @ 'localhost' ;
2.9.啟動主節點(以bootstrap-pxc方式啟動):
[root@ory-newcaiwu-mysql-01 ~]# /etc/init.d/mysql #顯示mysql啟動全部方式!
Usage: mysql {start|stop|restart|restart-bootstrap|reload|force-reload|status|bootstrap-pxc} [ MySQL (Percona XtraDB Cluster) options ]
以bootstrap-pxc方式啟動:
[root@ory-newcaiwu-mysql-01 ~]# /etc/init.d/mysql bootstrap-pxc
3.0.啟動節點32.50,會自動觸發叢集主節點32.49給它全量同步資料(也就是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上 鑑證節點相關操作:
3.1.安裝garb服務:
[root@ory-fanxiqian-Oracle-01 ~]# yum install Percona-XtraDB-Cluster-garbd-3
3.2.配置gab引數:
[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.啟動gab服務:
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
其中時候你會發現叢集節點數量增加了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)
至此兩個資料節點+一個仲裁節點的pxc架構搭建完畢,至於相關的引數最佳化接下來繼續更新。。。。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29654823/viewspace-2215775/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- greenplum 6.9 for centos7叢集搭建步驟CentOS
- MySQL叢集搭建方案(PXC)MySql
- 丐版pxc叢集
- centos7搭建redis叢集CentOSRedis
- CentOS7 搭建 Redis 叢集CentOSRedis
- centos7搭建dolphinscheduler叢集CentOS
- mysql學習筆記之快速搭建PXC叢集(Mycat分片)MySql筆記
- Linux Centos 搭建叢集圖文教程LinuxCentOS
- Linux(Centos7)Redis叢集的搭建LinuxCentOSRedis
- Centos7 ELK7.6.2叢集搭建CentOS
- hadoop叢集搭建,CentOS7克隆HadoopCentOS
- Centos mini系統下的Hadoop叢集搭建CentOSHadoop
- CentOS7 上搭建多節點 Elasticsearch叢集CentOSElasticsearch
- CentOS7搭建Hadoop-3.3.0叢集手記CentOSHadoop
- 搭建zookeeper叢集(偽叢集)
- 從庫轉換成PXC叢集的節點
- zookeeper叢集及kafka叢集搭建Kafka
- linux下搭建ZooKeeper叢集(偽叢集)Linux
- Redis系列:搭建Redis叢集(叢集模式)Redis模式
- 搭建ELK叢集
- Ambari叢集搭建
- kafka叢集搭建Kafka
- Hadoop搭建叢集Hadoop
- zookeeper 叢集搭建
- 搭建 Redis 叢集Redis
- nacos 叢集搭建
- mysql叢集搭建MySql
- redis叢集搭建Redis
- Hadoop叢集搭建Hadoop
- Zookeeper叢集搭建
- RabbitMQ叢集搭建MQ
- HBASE叢集搭建
- Centos7搭建hadoop3.3.4分散式叢集CentOSHadoop分散式
- 2019最新k8s叢集搭建教程 (centos k8s 搭建)K8SCentOS
- 在 centos6.9 上 cdh-5.13.3的搭建報錯CentOS
- 雲主機centos7搭建基於docker的hadoop叢集CentOSDockerHadoop
- CentOS7系統規劃搭建 kubernetes 叢集詳細教程。CentOS
- CentOS 7上搭建Spark 3.0.1 + Hadoop 3.2.1分散式叢集CentOSSparkHadoop分散式