PXC的集群安装是怎样的

发布时间:2021-11-16 16:04:57 作者:柒染
来源:亿速云 阅读:177

这期内容当中小编将会给大家带来有关PXC的集群安装是怎样的,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

Percona XtraDB Cluster简介

Percona XtraDB Cluster是MySQL高可用性和可扩展性的解决方案,Percona XtraDB Cluster完全兼容MySQL和Percona Server。
Percona XtraDB Cluster提供的特性有:

pxc优点:

pxc缺点:

Percona XtraDB Cluster局限性

安装Percona XtraDB 集群

shell> tar zxvf Percona-XtraDB-Cluster-5.6.22-72.0.tar.gzshell> cd Percona-XtraDB-Cluster-5.6.22-72.0安装依赖包shell> yum install cmake gcc gcc-c++ libaio libaio-devel automake autoconf bzr bison libtool ncurses5-develshell> BUILD/compile-pentium64默认安装路径/usr/local/mysql/shell> make && make installshell> rpm -ivh Percona-XtraDB-Cluster-galera-3-3.14-1.rhel6.x86_64.rpm创建数据文件目录shell> mkdir -p /data/pxcshell> mv /usr/local/mysql/ /opt/pxcshell> chown -R mysql.mysql /opt/pxcshell> chown -R mysql.mysql /data/pxc

配置节点node1:

shell> more /opt/pxc/my.cnf[mysqld]socket=/tmp/mysql-node1.sockport=3307datadir=/data/pxcuser=mysqlbinlog_format=ROWdefault-storage-engine=innodbinnodb_autoinc_lock_mode=2innodb_locks_unsafe_for_binlog=1query_cache_size=0query_cache_type=0bind-address=0.0.0.0wsrep_provider=/usr/lib64/libgalera_smm.sowsrep_cluster_address=gcomm://10.106.58.211,10.106.58.212,10.106.58.213wsrep_cluster_name=my_wsrep_clusterwsrep_slave_threads=1wsrep_certify_nonPK=1wsrep_max_ws_rows=131072wsrep_max_ws_size=1073741824wsrep_debug=1wsrep_convert_LOCK_to_trx=0wsrep_retry_autocommit=1wsrep_auto_increment_control=1wsrep_causal_reads=0#wsrep_notify_cmd=# SST method#wsrep_sst_method=xtrabackup-v2wsrep_sst_method=rsync# Authentication for SST method#wsrep_sst_auth="sstuser:s3cret"# Node #1 addresswsrep_node_address=10.106.58.211server-id  = 1

启动node1:

shell> /opt/pxc/scripts/mysql_install_db --basedir=/opt/pxc/ --datadir=/data/pxc/ \--user=mysql --defaults-file=/opt/pxc/my.cnfshell> /opt/pxc/bin/mysqld_safe --defaults-file=/opt/pxc/my.cnf --wsrep-new-cluster &shell> /opt/pxc/bin/mysql -u root -S /tmp/mysql-node1.sockmysql> delete from mysql.user where user = '';mysql> GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO sstuser@'localhost' identified by 's3cret';mysql> flush privileges;

配置启动节点node2、node3:

node2、node3配置启动同理。

[mysqld]socket=/tmp/mysql-node1.sockwsrep_node_address=10.106.58.212server-id  = 2shell> /opt/pxc/bin/mysqld_safe --defaults-file=/opt/pxc/my.cnf &

检查pxc状态

mysql> show status like 'wsrep%';+------------------------------+----------------------------------------------------------+| Variable_name                | Value                                                    |+------------------------------+----------------------------------------------------------+| wsrep_local_state_uuid       | 17b9d472-5ace-11e5-b22f-ab14cb9dcc7b                     || wsrep_protocol_version       | 7                                                        || wsrep_last_committed         | 7                                                        || 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               | 3                                                        || wsrep_received_bytes         | 311                                                      || wsrep_local_commits          | 0                                                        || wsrep_local_cert_failures    | 0                                                        |.| wsrep_incoming_addresses     | 10.106.58.213:3307,10.106.58.212:3307,10.106.58.211:3307 || wsrep_evs_delayed            |                                                          || wsrep_evs_evict_list         |                                                          || wsrep_evs_repl_latency       | 0/0/0/0/0                                                || wsrep_evs_state              | OPERATIONAL                                              || wsrep_gcomm_uuid             | c21183b0-5acf-11e5-930d-9bfcbb0bb24c                     || wsrep_cluster_conf_id        | 5                                                        || wsrep_cluster_size           | 3                                                        || wsrep_cluster_state_uuid     | 17b9d472-5ace-11e5-b22f-ab14cb9dcc7b                     || wsrep_cluster_status         | Primary                                                  || wsrep_connected              | ON                                                       || wsrep_local_bf_aborts        | 0                                                        || wsrep_local_index            | 2                                                        || wsrep_provider_name          | Galera                                                   || wsrep_provider_vendor        | Codership Oy <info@codership.com>                        || wsrep_provider_version       | 3.11(r93aca2d)                                           || wsrep_ready                  | ON                                                       |+------------------------------+----------------------------------------------------------+58 rows in set (0.01 sec)

简单测试pxc

mysql@node1> create database svoid;Query OK, 1 row affected (0.00 sec)mysql@node2> use svoidDatabase changedmysql@node2> create table test(id int);Query OK, 0 rows affected (0.01 sec)mysql@node3> use svoidDatabase changedmysql@node3> show tables;+-----------------+| Tables_in_svoid |+-----------------+| test            |+-----------------+1 row in set (0.00 sec)mysql@node3> insert into test select 1;Query OK, 1 row affected (0.01 sec)Records: 1  Duplicates: 0  Warnings: 0mysqlnode2> update test set id = 2 where id = 1;Query OK, 1 row affected (0.01 sec)Rows matched: 1  Changed: 1  Warnings: 0mysqlnode1> alter table test add primary key(id);Query OK, 1 row affected (0.02 sec)Records: 1  Duplicates: 0  Warnings: 0mysqlnode1> select * from test;+----+| id |+----+|  2 |+----+1 row in set (0.00 sec)模拟故障node1宕机shell> /opt/pxc/bin/mysqladmin -S /tmp/mysql-node1.sock -u root shutdownmysqlnode2> insert into test select 1;Query OK, 1 row affected (0.00 sec)Records: 1  Duplicates: 0  Warnings: 0mysqlnode2> insert into test select 3;Query OK, 1 row affected (0.00 sec)Records: 1  Duplicates: 0  Warnings: 0启动node1shell> /opt/pxc/bin/mysqld_safe --defaults-file=/opt/pxc/my.cnf &mysqlnode1> select * from test;+----+| id |+----+|  1 ||  2 ||  3 |+----+3 rows in set (0.00 sec)可以看出其中一个节点故障不影响其他节点正常使用,启动节点后会自动同步数据

上述就是小编为大家分享的PXC的集群安装是怎样的了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注亿速云行业资讯频道。

推荐阅读:
  1. 为PXC集群引入Mycat并构建完整的高可用集群架构
  2. ProxySQL辅助的PXC集群维护模式

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

pxc

上一篇:如何理解MySQL的存储过程与光标

下一篇:数据库分布式事务常见实现方法是什么

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》