Galera Touch It

Galera Install Doc

Write by zhoulin(perrynzhou)

  1. How Galera Cluster Works
Galera Touch It_第1张图片
11.jpg
  1. Get mysql-wsrep and galera souce
  2. Clone the Galera Cluster for MySQL database server source code.
git clone https://github.com/codership/mysql-wsrep

2.Checkout the branch for the version that you want to use.

# git checkout 5.6

3.Checkout the galera source

# cd ..
# git clone https://github.com/codership/galera.git
  1. Install Galera
    Enter galera source dir:
# cd galera  //galera source dir
# apt-get install  libasio-dev libasio-doc\
            openssl check libboost-all-dev scons\
            zip xclip vim-gnome astyle python-setuptools\
   make cmake gcc g++ bison libncurses5-dev
# scons

Just wait to build,all complete,this info you can see:

This process creates the Galera Replication Plugin, (that is, the libgalera_smm.so file). In your my.cnfconfiguration file, you need to define the path to this file for the wsrep_provider parameter.
Correct path to libgalera_smm.so given to the wsrep_provider option. For example,
wsrep_provider=/usr/lib64/libgalera_smm.so

  1. Install mysql-wsrep
    4.1 make and make install
cmake . -DCMAKE_INSTALL_PREFIX=/data/opt/mysql-wsrep  
-DWITH_WSREP=ON -DWITH_INNODB_DISALLOW_WRITES=ON  
-DMYSQL_DATADIR=/data/opt/mysql-wsrep/data -DSYSCONFDIR=/data/opt/mysql-wsrep/ 
-DWITH_INNOBASE_STORAGE_ENGINE=1 
-DWITH_ARCHIVE_STORAGE_ENGINE=1 
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 
-DWITH_PARTITION_STORAGE_ENGINE=1 
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITHOUT_FEDERATED_STORAGE_ENGINE=1 
-DDEFAULT_CHARSET=utf8 
-DDEFAULT_COLLATION=utf8_general_ci 
-DWITH_EXTRA_CHARSETS=all 
-DENABLED_LOCAL_INFILE=1 
-DWITH_READLINE=1 
-DMYSQL_UNIX_ADDR=/data/opt/mysql-wsrep/mysql.sock -DMYSQL_TCP_PORT=3310 
-DCOMPILATION_COMMENT="lq-edition" -DWITH_DEBUG=1

4.2 init mysql database
My Testing environment just 2 machines,each is is as flow:
192.168.234.128,192.168.243.129,192.168.243.130

All node apply this command:

./mysql_install_db  --user=root --basedir=/data/opt/mysql-wsrep/  --datadir=/data/opt/mysql-wsrep/data/

Each node can create my.cnf
my.cnf of 192.168.243.128:

[mysqld]
wsrep_cluster_name=DBCluster
wsrep_cluster_address="gcomm://192.168.243.128,192.168.243.129,192.168.243.130"
wsrep_node_name=node1
wsrep_node_address="192.168.243.128"
basedir = /data/opt/mysql-wsrep
datadir = /data/opt/mysql-wsrep/data
port = 3310
server_id =1
socket = /tmp/mysql3310.sock
wsrep_provider=/data/opt/galera-3x/libgalera_smm.so
innodb_buffer_pool_size=200m
binlog_format=ROW

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

my.cnf of 192.168.243.129:

[mysqld]
wsrep_cluster_name=DBCluster
wsrep_cluster_address="gcomm://192.168.243.128,192.168.243.129,192.168.243.130"
wsrep_node_name=node2
wsrep_node_address="192.168.243.129"


basedir = /data/opt/mysql-wsrep
datadir = /data/opt/mysql-wsrep/data
port = 3310
server_id =2
socket = /tmp/mysql3310.sock
wsrep_provider=/data/opt/galera-3x/libgalera_smm.so
innodb_buffer_pool_size=200m
binlog_format=ROW
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

my.cnf of 192.168.243.130:

[mysqld]
wsrep_cluster_name=DBCluster
wsrep_cluster_address="gcomm://192.168.243.128,192.168.243.129,192.168.243.130"
wsrep_node_name=node3
wsrep_node_address="192.168.243.130"


basedir = /data/opt/mysql-wsrep
datadir = /data/opt/mysql-wsrep/data
port = 3310
server_id =3
socket = /tmp/mysql3310.sock
wsrep_provider=/data/opt/galera-3x/libgalera_smm.so
innodb_buffer_pool_size=200m
binlog_format=ROW
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
  1. Start mysql-wsrep

Choose one node as master node(192.168.243.128):

#./mysqld \
--defaults-file=/data/opt/mysql-wsrep/my.cnf  --wsrep-new-cluster &

Other node can run by this way:

#./mysqld \
--defaults-file=/data/opt/mysql-wsrep/my.cnf &
Galera Touch It_第2张图片
01.jpg
Galera Touch It_第3张图片
02.jpg
Galera Touch It_第4张图片
03.jpg

你可能感兴趣的:(Galera Touch It)