其他分享
首页 > 其他分享> > Mariadb Galera Cluster 群集 安装部署

Mariadb Galera Cluster 群集 安装部署

作者:互联网

Mariadb Galera Cluster 群集 安装部署

##centos 7.2
##主机节点###: node1 node2 node3
##################################################### # #配置内核 # echo ' # * soft nofile 65536 # * hard nofile 65536 # '>>/etc/security/limits.conf # # # echo ' # fs.file-max=655350 # net.ipv4.ip_local_port_range = 1025 65000 # net.ipv4.tcp_tw_recycle = 1 # '>>/etc/sysctl.conf # sysctl -p # ########################### ###所有节点执行 cat >/etc/yum.repos.d/CentOS-OpenStack-liberty.repo <<EOF [centos-openstack-liberty] name=CentOS-7 - OpenStack liberty baseurl=http://vault.centos.org/centos/7.3.1611/cloud/x86_64/openstack-liberty/ gpgcheck=0 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Centos-7 EOF yum install -y mariadb mariadb-server mariadb-galera-server yum install expect -y #配置数据库 echo "# [mysqld] bind-address = 0.0.0.0 default-storage-engine = innodb innodb_file_per_table max_connections = 4096 collation-server = utf8_general_ci character-set-server = utf8 #" >/etc/my.cnf.d/test.cnf #启动数据库服务 systemctl enable mariadb.service systemctl start mariadb.service #mysql_secure_installation #初始化设置密码,自动交互 ####初始化数据库服务,只在一个节点进行 yum install expect -y /usr/bin/expect << EOF set timeout 30 spawn mysql_secure_installation expect { "enter for none" { send "\r"; exp_continue} "Y/n" { send "Y\r" ; exp_continue} "password:" { send "123456\r"; exp_continue} "new password:" { send "123456\r"; exp_continue} "Y/n" { send "Y\r" ; exp_continue} eof { exit } } EOF ######## mysql -u root -p123456 -e "show databases;" #########galera配置 cp /etc/my.cnf.d/galera.cnf{,.bak} egrep -v "#|^$" /etc/my.cnf.d/galera.cnf.bak >/etc/my.cnf.d/galera.cnf sed -i 's/wsrep_on=1/wsrep_on=ON/' /etc/my.cnf.d/galera.cnf sed -i 's/wsrep_sst_auth=root:/wsrep_sst_auth=root:'123456'/' /etc/my.cnf.d/galera.cnf ################# ######node1节点 , #sed -i "s/bind-address = 0.0.0.0/bind-address = $(ip addr |grep global |grep $(route |grep default |awk '{print $NF}') |head -n1 |awk '{print $2}' |cut -d '/' -f1)/" /etc/my.cnf.d/test.cnf
echo " wsrep_cluster_address="gcomm://node1,node2,node3"
wsrep_node_address=$(ip addr |grep global |grep $(route |grep default |awk '{print $NF}') |head -n1 |awk '{print $2}' |cut -d '/' -f1) ">>/etc/my.cnf.d/galera.cnf cat /etc/my.cnf.d/galera.cnf systemctl daemon-reload systemctl stop mariadb.service #启动第一个节点 galera_new_cluster ########################### ######其它节点运行 #sed -i "s/bind-address = 0.0.0.0/bind-address = $(ip addr |grep global |grep $(route |grep default |awk '{print $NF}') |head -n1 |awk '{print $2}' |cut -d '/' -f1)/" /etc/my.cnf.d/test.cnf
echo " wsrep_cluster_address="gcomm://node1,node2,node3" wsrep_node_address=$(ip addr |grep global |grep $(route |grep default |awk '{print $NF}') |head -n1 |awk '{print $2}' |cut -d '/' -f1) ">>/etc/my.cnf.d/galera.cnf

cat /etc/my.cnf.d/galera.cnf
systemctl restart mariadb.service ########################### #####其它节点启动后,重启第一个节点 node1 systemctl restart mariadb.service #####检测 netstat -antp|grep mysqld mysql -u root -p123456 -e "show status like 'wsrep_cluster_size';" mysql -u root -p123456 -e "show status like 'wsrep_incoming_addresses';"

 

 

标签:Galera,grep,etc,wsrep,cnf,Cluster,print,Mariadb,my
来源: https://www.cnblogs.com/blog-lhong/p/11684867.html