mysql database 高可用架构:MariaDB Galera Cluster

[[email protected] ~]# rpm -ivh epel-release-6-8.noarch.rpm 
[[email protected] ~]# yum install -y bison bison-devel check check-devel boost boost-devel \ 
cmake readline readline-devel scons socat perl-DBD-MySQL

[[email protected] ~]# rpm -ivh libev-4.15-1.el6.rf.x86_64.rpm
[[email protected] ~]# rpm -ivh percona-xtrabackup-24-2.4.9-1.el6.x86_64.rpm

[[email protected] ~]# [[email protected] ~]# tar zxvf mariadb-10.3.10.tar.gz
[[email protected] ~]# cd mariadb-10.3.10
[[email protected] mariadb-10.3.10]# cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DWITHOUT_TOKUDB_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EMBEDDED_SERVER=0 \
-DWITH_WSREP=1 \
-DWITH_INNODB_DISALLOW_WRITES=1

[[email protected] mariadb-10.3.10]# make && make install

[[email protected] mariadb-10.3.10]# cd support-files/ 
[[email protected] support-files]# cp mysql.server /etc/init.d/mysqld
[[email protected] ~]# chmod a+x /etc/init.d/mysqld

[[email protected] ~]#  vi /etc/my.cnf
[mysqld]
bind-address = 0.0.0.0
default_storage_engine = innodb
innodb_autoinc_lock_mode = 2
innodb_flush_log_at_trx_commit = 0
wsrep_on = 1
wsrep_provider = /usr/local/mysql/lib/libgalera_smm.so
wsrep_provider_options="gcache.size=1024M; gcache.page_size=512M"
wsrep_cluster_name = "MariaDB Galera Cluster"
wsrep_cluster_address = "gcomm://192.168.1.201,192.168.1.202,192.168.1.203"
wsrep_sst_method=xtrabackup-v2
wsrep_sst_auth=sst:sst
wsrep_node_name = wallet01
wsrep_node_address="192.168.1.201"

[[email protected] ~]# tar zxvf galera-3-25.3.23.tar.gz
[[email protected] ~]# cd galera-3-25.3.23
[[email protected] galera-3-25.3.23]# scons
[[email protected] galera-3-25.3.23]# cp libgalera_smm.so /usr/local/mysql/lib/
[[email protected] galera-3-25.3.23]# cp garb/garbd /usr/local/mysql/bin/

[[email protected] ~]# cd /usr/local/mysql/
[[email protected] mysql]# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

[[email protected] ~]# /etc/init.d/mysqld bootstrap
[[email protected] ~]# service mysqld status
 SUCCESS! MariaDB running (27944)
 
[[email protected] ~]# mysql_secure_installation

[[email protected] ~]# mysql -uroot -pabcd.1234
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 728
Server version: 10.3.10-MariaDB-log Source distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create user [email protected]'localhost' identified by 'sst';
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> grant reload,lock tables,replication client,process on *.* to [email protected]'localhost';
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.000 sec)

[[email protected] ~]# netstat -tunlp | grep mysqld
tcp        0      0 0.0.0.0:4567                0.0.0.0:*                   LISTEN      27944/mysqld        
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      27944/mysqld


猜你喜欢

转载自blog.51cto.com/13598811/2326943
0条评论
添加一条新回复