Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build pxc Cluster with centos6.9

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to build a pxc cluster in centos6.9". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to build a pxc cluster in centos6.9.

One: environmental introduction:

10.1.32.49

10.1.32.50

10.1.32.36

The operating systems are all centos 6.9, and 49 and 50 are the data nodes of the database cluster, 36 are authentication nodes or election nodes, and the percona version 5.6 is installed, in which the garb of the authentication node is installed with the garbd-3 version

Second: formal installation:

2.1. First install the relevant yum source:

1-3 versions of yum source:

Yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm

1-4 version of yum source: (generally choose new version)

Yum install http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm

Install some sources of software that are not available in centos feeds

Yum install http://mirrors.ustc.edu.cn/fedora/epel/6/i386/epel-release-6-8.noarch.rpm

Check to see if the yum source for percona exists:

[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 turn off the firewall and Selinux

Service iptables stop

Chkconfig iptables off

Vi / etc/selinux/config

SELINUX=disabled

2.2. Check the installed version of Percona, and if you don't need it, uninstall it to prevent conflicts!

[root@ory-newcaiwu-mysql-01 ~] # yum list Percona*

Or

[root@ory-newcaiwu-mysql-02 ~] # rpm-qa | grep Percona*

Uninstall the Percona of the system itself

[root@ory-newcaiwu-mysql-01 ~] # yum remove Percona*

To install pxc, you need to install the following packages, only Percona-XtraDB-Cluster-server-56 is needed for real installation, and the rest are automatically installed as dependent packages!

Yum-y install Percona-XtraDB-Cluster-server Percona-XtraDB-Cluster-client Percona-Server-shared-compat percona-xtrabackup

Check the names of the packages for each version of Percona to make it easier to select a specific version:

[root@ory-newcaiwu-mysql-02 ~] # rpm-qa | grep Percona*

2.3.Using yum to install, you only need to install Percona-XtraDB-Cluster-server. All other dependent packages are installed automatically. We choose version 5.6 of mysql as follows:

[root@ory-newcaiwu-mysql-02 ~] # yum install-y Percona-XtraDB-Cluster-server-56

2.4. Then configure the parameter / etc/my.cnf. The configuration parameters of the two data nodes are basically the same, and individual parameters need to be changed.

[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 per gcs.fcmaster masterminds = 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

Initialize the database master node: the rest need not be initialized deliberately, because when you start the second node, it will sst synchronize to the second node.

Mysql_install_db-defaults-file=/etc/my.cnf-user=mysql

2.6. Delete anonymous account

Mysql-e "delete from mysql.user where user=''; delete from mysql.user where user='';flush privileges;"

2.7. Set a password for the administrator account

Mysqladmin-u root password $password

2.8. Add SST account to mysql of each machine

In fact, you only need to add it to the primary node, because when you start the second node, it will sst synchronize to the second node, and the user will also synchronize it. Note that the username and password need to be corresponding in the parameter wsrep_sst_auth!

CREATE USER 'sstuser'@'localhost' IDENTIFIED BY' liuwenhe'

GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT,PROCESS ON *. * TO 'sstuser'@'localhost'

2.9. Start the primary node (start as bootstrap-pxc):

[root@ory-newcaiwu-mysql-01 ~] # / etc/init.d/mysql # shows all the ways mysql starts!

Usage: mysql {start | stop | restart | restart-bootstrap | reload | force-reload | status | bootstrap-pxc} [MySQL (Percona XtraDB Cluster) options]

Start as bootstrap-pxc:

[root@ory-newcaiwu-mysql-01 ~] # / etc/init.d/mysql bootstrap-pxc

3.0. Startup node 32.50will automatically trigger cluster master node 32.49to give it full synchronization data (that is, 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]

3: 32.36 authentication node related operations:

3.1. Install the garb service:

[root@ory-fanxiqian-Oracle-01 ~] # yum install Percona-XtraDB-Cluster-garbd-3

3.2. Configure gab parameters:

[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.36RV 4567 10.1.32.49Rd 4567 10.1.32.50PUR 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. Start the gab service:

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

Among them, you will find that the number of cluster nodes has increased by 1, from 2 to 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)

Thank you for reading, the above is the content of "how to build pxc clusters in centos6.9". After the study of this article, I believe you have a deeper understanding of how to build pxc clusters in centos6.9, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report