※mysql_secure_installation 要記得允許root從Remote Login
2 .安裝其他套件(可能會用到的)
yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm
yum install -y percona-xtrabackup-24 yum rsync nmap lsof perl-DBI nc galera socat jemalloc
如果要使用RSYNC,可以設定SSH KEY
ssh-keygen -t rsa
cat /var/lib/jenkins/.ssh/id_rsa.pub >> “other db server” /root/.ssh/authorized_keys
如果只是要測安裝,可以先關閉firewall與selinux ,正式環境還是乖乖啟動吧。
systemctl disable firewalld
systemctl stop firewalld
vim /etc/sysconfig/selinux set disable
service mysql start
GRANT ALL PRIVILEGES ON *.* TO 'sync'@localhost IDENTIFIED BY 'Password' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'sync'@'10.1.0.%' IDENTIFIED BY 'Password' WITH GRANT OPTION;
flush privileges;
4. 關閉DB,設定環境Node 1環境
service mysql stop
Node 1.
vim /etc/my.con.f/server.cnf
[mysqld]innodb_use_sys_malloc = 1
event_scheduler = ON
max_connections = 1024
log-bin-trust-function-creators = 1
default-time-zone = '+8:00'
character-set-server=utf8
wsrep_sst_auth=sync:Password
wsrep_sst_method=rsync
#wsrep_sst_method=xtrabackupwsrep_sst_method=rsync
[galera]
wsrep_on=ON
binlog_format=ROW
default_storage_engine = innodb
innodb_autoinc_lock_mode = 2
innodb_buffer_pool_size = 122M
query_cache_type = 0
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_name='mycluster'
wsrep_cluster_address='gcomm://'
wsrep_node_name='DB-1'
wsrep_node_address='192.168.1.1'
bind-address=0.0.0.0
啟動First DB
galera_new_cluster
或
service mysql start --wsrep-new-cluster
6. Node N的部分,重新處理1~4的步驟,差異點如下
Node N.
vim /etc/my.con.f/server.cnf
[mysqld]
innodb_use_sys_malloc = 1
event_scheduler = ON
max_connections = 1024
log-bin-trust-function-creators = 1
default-time-zone = '+8:00'
character-set-server=utf8
[galera]
wsrep_on=ON
binlog_format=ROW
default_storage_engine = innodb
innodb_autoinc_lock_mode = 2
innodb_buffer_pool_size = 122M
query_cache_type = 0
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_name='mycluster'
wsrep_cluster_address='gcomm://192.168.1.1:4567,192.168.1.N:4567(看有幾台都設上去)'
wsrep_node_name='DB-N'
wsrep_node_address='192.168.1.N'
bind-address=0.0.0.0
[mysqld]
innodb_use_sys_malloc = 1
event_scheduler = ON
max_connections = 1024
log-bin-trust-function-creators = 1
default-time-zone = '+8:00'
character-set-server=utf8
wsrep_sst_auth=sync:Password
wsrep_sst_method=rsync
#wsrep_sst_method=xtrabackupwsrep_sst_method=rsync
[galera]
wsrep_on=ON
binlog_format=ROW
default_storage_engine = innodb
innodb_autoinc_lock_mode = 2
innodb_buffer_pool_size = 122M
query_cache_type = 0
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_name='mycluster'
wsrep_cluster_address='gcomm://192.168.1.1:4567,192.168.1.N:4567(看有幾台都設上去)'
wsrep_node_name='DB-N'
wsrep_node_address='192.168.1.N'
bind-address=0.0.0.0
啟動Node N DB
service mysql start
7. 當第2台DB同步後,記得回到第一台設定
wsrep_cluster_address='gcomm://192.168.1.1:4567,192.168.1.N:4567(看有幾台都設上去)'
啟動Node 1 DB
service mysql start
8. 檢查狀態
netstat -ant ... 注意3306與4567是否有啟動
mysql -u root -p -e "show status like 'wsrep%'" ... 檢查相關的Node是否有上線
沒有留言:
張貼留言