MariaDB Galera Cluster 5.5.39 on Centos 5.8_64
来源:互联网 发布:电脑照相机软件下载 编辑:程序博客网 时间:2024/05/01 06:23
1.在三个节点上安装MariaDBGalera Cluster
Node1:172.16.2.106
Node2:172.16.2.109
Node3:172.16.2.207
三个节点的服务器都已经安装了64位的 Centos 5.8
Node1做为已经数据库数据的服务器,集群启动时node2和node3要从node1同步数据
节点启动时的同步有三种方式,要my.cnf文件中的wsrep_sst_method参数进行配置
wsrep_sst_method的参数说明:
Method
Speed
Blocks Donor?
Available on Live Node
Type
Requires root access to database server?
mysqldump
slow
yes
yes
logical
donor and joiner
rsync
fastest
yes
no
physical
none
xtrabackup
fast
briefly
no
physical
donor only
rsync在数据同步(SST和IST)的时候,速度最快,但是会锁住提供数据的节点,xtrabackup只会短暂的锁住节点。
我们这次的安装是用rsync的方式进行同步,galera 官网建议用xtrabackup方式,对数据库的影响最小,在以后的文档中再对xtrabackup启动同步的方式做测试
安装 mariadb
在 mariadb官网上下载已经包含 wsrep模块的源代码包
https://downloads.mariadb.org/interstitial/mariadb-galera-5.5.39/source/mariadb-galera-5.5.39.tar.gz
必须要注册用户才能下载
(人家都已经给我们提供这么好的东西了,让注册就注册一下呗)
我们没有使用最新版本的,而是使用了稳定版,在线上平台的软件的使用中我们也要遵守这个原则
先安装一些在编译码代码过程中必须的软件,
yum install pcre-devel
yum install bison-devel
yum install cmake
添加mariadb 的管理用户
groupadd mysql
useradd -g mysql mysql
tar zxf mariadb-5.5.32.tar.gz
cd mariadb-5.5.32
cmake .-DCMAKE_INSTALL_PREFIX=/usr/local/mariadb \
-DMYSQL_UNIX_ADDR=/usr/local/mariadb/data/mysql.sock\
-DMYSQL_DATADIR=/usr/local/mariadb/data \
-DSYSCONFDIR=/usr/local/mariadb/etc \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DWITH_XTRADB_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DWITH_BIG_TABLES=1 \
-DWITH_DEBUG=0 \
-DWITH_WSREP=1 \
-DWITH_INNODB_DISALLOW_WRITES=1
make && make install
编译的时候要支持 galera 必须要加上
-DWITH_WSREP=1 \
-DWITH_INNODB_DISALLOW_WRITES=1
下面完成maria 的一些初始化
/bin/cp support-files/my-small.cnf/etc/my.conf
/bin/cp support-files/mysql.server/etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
/usr/local/mariadb/scripts/mysql_install_db--user=mysql --basedir=/usr/local/mariadb --datadir=/usr/local/mariadb/data
chown -R mysql:mysql /usr/local/mariadb/data
service mysqld start
export PATH=$PATH:/usr/local/mariadb/bin
echo 'exportPATH=$PATH:/usr/local/mariadb/bin' >> /etc/profile
source /etc/profile
完成上面的工作之后,服务器已经可以当成一个单独的数据库服务器来使用了
配置数据库启动时同步所需要的数据库用户名,密码
首先用 service mysqld start 启动数据库
Mysql –u root –p
登录到系统后添加用户
grant usageon *.* to wsrep@’%’ identified by password '123456';
grant allprivileges on *.* to wsrep@’%’;
安装galera
在该网站上下载相应版本的 galera,要结合你的系统来下载
https://launchpad.net/galera/3.x/25.3.5/+download/galera-25.3.5-1.rhel5.x86_64.rpm
该软件我们使们rpm包进行安装
先安装galera所依赖的软件
yum install boost-devel
yum install check-devel
wget http://prdownloads.sourceforge.net/scons/scons-2.2.0.tar.gz
tar zxvf scons-2.2.0.tar.gz
cd scons-2.2.0
python setup.py install
完成 scons的安装
用rpm包进行安装galera
rpm –ivhgalera-25.3.5-1.rhel5.x86_64.rpm
软件已经安装完成,这一步我们只要记着会在 /usr/lib64/galera 目录生成一个 libgalera_smm.so 文件就可以,在以后的过程中我们会用到/usr/lib64/galera/libgalera_smm.so
上面的步骤三个服务器都要操作,做上面操作后就已经完成了mariadb galera安装的基本操作
下面对mariadb进行集群的配置
Node1:
在/etc/my.cnf 的[mysqld] 下面增加如下内容
binlog_cache_size = 1M
binlog_format = ROW
default-storage-engine = InnoDB
expire_logs_days = 10
innodb_autoinc_lock_mode = 2
innodb_buffer_pool_size = 300M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 99
innodb_doublewrite = 1
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit = 2
innodb_lock_wait_timeout = 60
innodb_locks_unsafe_for_binlog = 1
innodb_stats_on_metadata = 0
key_buffer = 256M
wsrep_cluster_address = 'gcomm:// ' #特殊地址,做为启动时被同步数据的服务器使用此配置,如果服务器第二次启动,就要改成集群中其它服务器的地址
wsrep_provider =/usr/lib64/galera/libgalera_smm.so
wsrep_retry_autocommit = 0
wsrep_sst_method = rsync
wsrep_sst_auth = wsrep:123456 #前面的步骤中设置的数据库用户名,密码,在数据库启动过程中同步数据使用
wsrep_provider_options="gcache.size=10G;gcache.page_size=1G"
wsrep_slave_threads=16
wsrep_node_address=172.16.2.106
Node2:
在/etc/my.cnf 的[mysqld] 下面增加如下内容
binlog_cache_size = 1M
binlog_format = ROW
default-storage-engine = InnoDB
expire_logs_days = 10
innodb_autoinc_lock_mode = 2
innodb_buffer_pool_size = 300M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 99
innodb_doublewrite = 1
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit = 2
innodb_lock_wait_timeout = 60
innodb_locks_unsafe_for_binlog = 1
innodb_stats_on_metadata = 0
key_buffer = 256M
wsrep_cluster_address = 'gcomm://172.16.2.106,172.16.2.207'
wsrep_provider =/usr/lib64/galera/libgalera_smm.so
wsrep_retry_autocommit = 0
wsrep_sst_method = rsync
wsrep_sst_auth = wsrep:123456 #前面的步骤中设置的数据库用户名,密码,在数据库启动过程中同步数据使用
wsrep_provider_options="gcache.size=10G;gcache.page_size=1G"
wsrep_slave_threads=16
wsrep_node_address=172.16.2.109
Node3:
在/etc/my.cnf 的[mysqld] 下面增加如下内容
binlog_cache_size = 1M
binlog_format = ROW
default-storage-engine = InnoDB
expire_logs_days = 10
innodb_autoinc_lock_mode = 2
innodb_buffer_pool_size = 300M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 99
innodb_doublewrite = 1
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit = 2
innodb_lock_wait_timeout = 60
innodb_locks_unsafe_for_binlog = 1
innodb_stats_on_metadata = 0
key_buffer = 256M
wsrep_cluster_address = 'gcomm://172.16.2.106,172.16.2.109'
wsrep_provider =/usr/lib64/galera/libgalera_smm.so
wsrep_retry_autocommit = 0
wsrep_sst_method = rsync
wsrep_sst_auth = wsrep:123456 #前面的步骤中设置的数据库用户名,密码,在数据库启动过程中同步数据使用
wsrep_provider_options="gcache.size=10G;gcache.page_size=1G"
wsrep_slave_threads=16
wsrep_node_address=172.16.2.207
完成配置,首先启动节点node1,然后再启动node2和node3,后两个节点的启动没有先后顺序
连到任一节点新建一数据库-》建表-》插入数据,
Create database mariadb DEFAULT CHARACTERSET utf8 COLLATE utf8_general_ci
create table t(name varchar(20));
insert into t values('cheshi');
正常的的话在其它服务器是可以看到数据的
查看数据库的运行状态
Show status like ‘wsrep%’;
集群服务运行正常,收工!!!
源自:http://www.dba365.net/forum.php?mod=viewthread&tid=191&extra=page%3D1
0 0
- MariaDB Galera Cluster 5.5.39 on Centos 5.8_64
- MariaDB-10.1 Galera Cluster on CentOS 7
- mariadb-galera-10.0.19 on centos 6.5
- MariaDB Galera Cluster 部署
- MariaDB Galera Cluster 部署
- MariaDB Galera Cluster 安装
- 安装MariaDB Galera Cluster
- What is MariaDB Galera Cluster?
- MariaDB Galera Cluster集群优缺点
- [MariaDB] Setup MariaDB Galera Cluster with HAProxy
- CentOS 7.2部署MariaDB Galera Cluster(10.1.21-MariaDB) 3主集群环境
- What is MariaDB Galera Cluster?( 什么是 MariaDB Galera 集群)
- 处理MariaDB Galera Cluster安装报错三例
- MariaDB Galera Cluster 部署(mysql 集群部署)
- MariaDB Galera Cluster 部署(如何快速部署MariaDB集群)
- MariaDB Galera Cluster 部署(如何快速部署MariaDB集群)
- MariaDB集群Galera Cluster的研究与测试
- CentOS6.5安装 MariaDB Galera Cluster 10.0
- 数字信号处理的学习资源
- 神奇的sh:管道操作|原理 ,实现一个支持管道操作的grep
- StringBuilder 与 StringBuffer 区别
- 【LeetCode with Python】 Combinations
- Directx10 龙书笔记- 雾效的实现
- MariaDB Galera Cluster 5.5.39 on Centos 5.8_64
- 【LeetCode with Python】 Convert Sorted Array to Binary Search Tree
- 【LeetCode with Python】 Copy List with Random Pointer
- 位域之我见
- 【LeetCode with Python】 Count and Say
- 《炉石传说》架构设计赏析(3):Gameplay初探
- 【LeetCode with Python】 Divide Two Integers
- Android SDK目录详解
- 使用Firebug对js进行断点调试的图文方法