CentOS6.5,MySQL Galera安装

安装依赖环境
yum install gcc gcc-c++ boost-devel scons check-devel openssl-devel libaio -y
下载含wsrep Patch的MySQL 5.5.29
wget https://launchpad.net/codership-mysql/5.5/5.5.29-23.7.3/+download/mysql-5.5.29_wsrep_23.7.3-linux-x86_64.tar.gz
解压
tar zxvf mysql-5.5.29_wsrep_23.7.3-linux-x86_64.tar.gz
将解压目录移动至/usr/local/并重命名为MYSQL
mv mysql-5.5.29_wsrep_23.7.3-linux-x86_64 /usr/local/mysql
进入
cd /usr/local/mysql/
增加mysql用户和mysql组
groupadd mysql
useradd -r -g mysql mysql
 更改目录属主为mysql
chown -R mysql:mysql .
安装
./scripts/mysql_install_db --no-defaults --datadir=/usr/local/mysql/data --user=mysql
安装 Galera复制插件
wget https://launchpad.net/galera/2.x/23.2.4/+download/galera-23.2.4-src.tar.gz
解压并进入该目录
tar zxvf galera-23.2.4-src.tar.gz && cd galera-23.2.4-src
安装
scons
拷贝文件
cp garb/garbd /usr/local/mysql/bin/
cp libgalera_smm.so /usr/local/mysql/lib/plugin/
建立软连接
ln -s /usr/local/mysql/bin/mysql /usr/bin
拷贝启动文件
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
创建目录并赋权
mkdir -p /var/lib/mysql && chown mysql:mysql /var/lib/mysql
修改mysql配置文件
vim /etc/my.cnf
写入内容(wsrep_node_name = node1这里根据机器数量对node编号进行相应的更改 )
[client]
port = 3306
socket = /var/lib/mysql/mysql.sock

[mysqld_safe]
log-error = /var/lib/mysql/mysql.log
pid-file = /var/lib/mysql/mysql.pid

[mysqld]
wsrep_node_name = node1
wsrep_provider = /usr/local/mysql/lib/plugin/libgalera_smm.so
#wsrep_provider_options ='gcache.size=1G;socket.ssl_key=my_key;socket.ssl_cert=my_cert'
#wsrep_slave_threads=16
wsrep_sst_method = rsync
#wsrep_sst_auth=root:

port = 3306
socket = /var/lib/mysql/mysql.sock
user = mysql
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data

default_storage_engine=InnoDB
#innodb_buffer_pool_size=1G
#innodb_log_file_size=256M
innodb_autoinc_lock_mode=2
innodb_locks_unsafe_for_binlog=1
innodb_flush_log_at_trx_commit=0
innodb_doublewrite=0
innodb_file_per_table=1

binlog_format=ROW
log-bin=mysql-bin
server-id=101
relay-log=mysql-relay-bin
#read_only=1
log-slave-updates=1

启动主库
service mysql start --wsrep_cluster_address=gcomm://
查看mysqld占用端口
netstat -plantu | grep mysqld
[root@jkslw software]# netstat -plantu | grep mysqld
tcp        0      0 0.0.0.0:4567                0.0.0.0:*                   LISTEN      8359/mysqld         
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      8359/mysqld  
防火墙开放3306,4567和4444端口(4444端口好像是从库连接主库通讯用的,不开从库无法启动)

启动从库,并连接至主库
service mysql start --wsrep_cluster_address=gcomm://192.168.1.11:4567










    

你可能感兴趣的:(MYSQL)