#Mariadb Galera Cluster 群集 安装部署

openstack pike 部署  目录汇总 http://www.cnblogs.com/elvi/p/7613861.html

#Mariadb Galera Cluster群集

# ###########################
# ##基本设置 # #配置hosts
# echo '#Ha
# 192.168.58.21 controller1
# 192.168.58.22 controller2
# 192.168.58.23 controller3
# '>>/etc/hosts # #免密验 # #controller1 ssh免密验证
# ssh-keygen -t rsa -P '' -f ~/.ssh/id_dsa
# ssh-copy-id -i ~/.ssh/id_dsa.pub root@controller2
# ssh-copy-id -i ~/.ssh/id_dsa.pub root@controller2
# #其它节点一样
# #shell批量配置http://www.cnblogs.com/elvi/p/7681779.html # ########################### # #每个节点执行 # #配置内核
# echo '
# * soft nofile
# * hard nofile
# '>>/etc/security/limits.conf
# #
# echo '
# fs.file-max=
# net.ipv4.ip_local_port_range =
# net.ipv4.tcp_tw_recycle =
# '>>/etc/sysctl.conf
# sysctl -p
# ########################### #MariaDB Galera 安装
yum install mariadb mariadb-server mariadb-galera-server -y
yum install expect -y #SQL root密码
DBPass=open2017 #配置数据库
echo "#
[mysqld]
bind-address = 0.0.0.0
default-storage-engine = innodb
innodb_file_per_table
max_connections =
collation-server = utf8_general_ci
character-set-server = utf8
#">/etc/my.cnf.d/openstack.cnf #启动数据库服务
#systemctl enable mariadb.service
systemctl start mariadb.service #mysql_secure_installation #初始化设置密码,自动交互
/usr/bin/expect << EOF
set timeout
spawn mysql_secure_installation
expect {
"enter for none" { send "\r"; exp_continue}
"Y/n" { send "Y\r" ; exp_continue}
"password:" { send "$DBPass\r"; exp_continue}
"new password:" { send "$DBPass\r"; exp_continue}
"Y/n" { send "Y\r" ; exp_continue}
eof { exit }
}
EOF #测试
mysql -u root -p$DBPass -e "show databases;"
[ $? = ] || { echo "mariadb初始化失败";exit; }
############# #galera配置
/usr/bin/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:'$DBPass'/' /etc/my.cnf.d/galera.cnf ###########
#controller1节点
sed -i 's/bind-address = 0.0.0.0/bind-address = controller1/' /etc/my.cnf.d/openstack.cnf
echo '
wsrep_cluster_address="gcomm://controller1,controller2,controller3"
wsrep_node_name=controller1
wsrep_node_address=controller1
'>>/etc/my.cnf.d/galera.cnf
cat /etc/my.cnf.d/galera.cnf systemctl daemon-reload
systemctl stop mariadb.service
galera_new_cluster #启动第一个节点 #############
#controller2节点
sed -i 's/bind-address = 0.0.0.0/bind-address = controller2/' /etc/my.cnf.d/openstack.cnf
echo '
wsrep_cluster_address="gcomm://controller1,controller2,controller3"
wsrep_node_name=controller2
wsrep_node_address=controller2
'>>/etc/my.cnf.d/galera.cnf
systemctl restart mariadb.service #controller3节点
sed -i 's/bind-address = 0.0.0.0/bind-address = controller3/' /etc/my.cnf.d/openstack.cnf
echo '
wsrep_cluster_address="gcomm://controller1,controller2,controller3"
wsrep_node_name=controller3
wsrep_node_address=controller3
'>>/etc/my.cnf.d/galera.cnf
systemctl restart mariadb.service #其它节点启动后,重启第一个节点 controller1
systemctl restart mariadb.service #检测
netstat -antp|grep mysqld
mysql -u root -p$DBPass -e "show status like 'wsrep_cluster_size';"
mysql -u root -p$DBPass -e "show status like 'wsrep_incoming_addresses';" #创建用于监控的mariadb 用户haproxy (haproxy代理,监控使用)
mysql -u root -p$DBPass -e "create user 'haproxy'@'%';flush privileges;" #root远程访问设置
mysql -u root -p$DBPass -e "
grant all privileges on *.* to 'root'@'%' identified by '$DBPass' with grant option;
flush privileges;
select user,host,password from mysql.user;" ########################################## ##部署成功,检测结果如下
# [root@controller1 ~]# mysql -u root -p$DBPass -e "show status like 'wsrep_cluster_size';"
# +--------------------+-------+
# | Variable_name | Value |
# +--------------------+-------+
# | wsrep_cluster_size | |
# +--------------------+-------+
# [root@controller1 ~]# mysql -u root -p$DBPass -e "show status like 'wsrep_incoming_addresses';"
# +--------------------------+----------------------------------------------------+
# | Variable_name | Value |
# +--------------------------+----------------------------------------------------+
# | wsrep_incoming_addresses | controller1:,controller2:,controller3: |
# +--------------------------+----------------------------------------------------+

# #排错
# #关闭selinux、防火墙
# tail /var/log/mariadb/mariadb.log
# rm -f /var/lib/mysql//galera.cache
# #关闭群集后,重启
# #在其中一台
# sed -i 's#seqno: -1#seqno: 1#' /var/lib/mysql/grastate.dat
# galera_new_cluster #启动第一个节点
# #其它节点
# systemctl start mariadb


#test
#/usr/libexec/mysqld --wsrep-new-cluster --user=root &
#systemctl start mariadb.service
#设置开机启动,设置为第一个节点
# systemctl disable mariadb.service
# echo '#作为第一个节点启动SQL
# /usr/bin/galera_new_cluster
# sleep 5
# ssh controller2 "systemctl start mariadb.service"
# ssh controller3 "systemctl start mariadb.service"
# sleep 3
# systemctl restart mariadb.service
# '>>/etc/rc.local


##########################################
#以下为openstack相关的配置 #每个节点都设置
# haproxy高可用代理mariadb
echo '#mariadb_cluster
listen mariadb_cluster
mode tcp
bind controller:
balance leastconn
option mysql-check user haproxy
server controller1 controller1: weight check inter rise fall
server controller2 controller2: weight check inter rise fall
server controller3 controller3: weight check inter rise fall
'>>/etc/haproxy/haproxy.cfg
systemctl restart haproxy.service
#测试
DBPass=open2017
mysql -h controller -u root -p$DBPass -e "show status like 'wsrep_cluster_size';" #############
#以下在controller其中一节点执行即可
#创建openstack相关数据库、用户授权
#mysql -u root -p
mysql -u root -p$DBPass -e "
create database keystone;
grant all privileges on keystone.* to 'keystone'@'localhost' identified by 'keystone';
grant all privileges on keystone.* to 'keystone'@'%' identified by 'keystone';
create database glance;
grant all privileges on glance.* to 'glance'@'localhost' identified by 'glance';
grant all privileges on glance.* to 'glance'@'%' identified by 'glance'; create database nova;
grant all privileges on nova.* to 'nova'@'localhost' identified by 'nova';
grant all privileges on nova.* to 'nova'@'%' identified by 'nova';
create database nova_api;
grant all privileges on nova_api.* to 'nova'@'localhost' identified by 'nova';
grant all privileges on nova_api.* to 'nova'@'%' identified by 'nova';
create database nova_cell0;
grant all privileges on nova_cell0.* to 'nova'@'localhost' identified by 'nova';
grant all privileges on nova_cell0.* to 'nova'@'%' identified by 'nova'; create database neutron;
grant all privileges on neutron.* to 'neutron'@'localhost' identified by 'neutron';
grant all privileges on neutron.* to 'neutron'@'%' identified by 'neutron'; flush privileges;
select user,host from mysql.user;
show databases;
" mysql -u root -p$DBPass -e "
show databases;
"

Mariadb Galera Cluster 群集 安装部署的更多相关文章

  1. MariaDB Galera Cluster 部署(如何快速部署 MariaDB 集群)

    MariaDB Galera Cluster 部署(如何快速部署 MariaDB 集群)  OneAPM蓝海讯通7月3日 发布 推荐 4 推荐 收藏 14 收藏,1.1k 浏览 MariaDB 作为 ...

  2. MariaDB Galera Cluster 部署

    原文  http://code.oneapm.com/database/2015/07/02/mariadb-galera-cluster/MariaDB作为Mysql的一个分支,在开源项目中已经广泛 ...

  3. MariaDB Galera Cluster 部署(如何快速部署MariaDB集群)

    MariaDB Galera Cluster 部署(如何快速部署MariaDB集群) [日期:--] 来源:Linux社区 作者:Linux [字体:大 中 小] MariaDB作为Mysql的一个分 ...

  4. MariaDB Galera Cluster部署手册

    MariaDB Galera Cluster部署手册 galara保证双主数据库的同步及一致性 1.环境准备 基于新部署.最小化安装centos6.5 1>  yum install opens ...

  5. MariaDB Galera Cluster 部署 + keepalived实现高可用

    MariaDB Galera Cluster 部署 MariaDB作为Mysql的一个分支,在开源项目中已经广泛使用,例如大热的openstack,所以,为了保证服务的高可用性,同时提高系统的负载能力 ...

  6. Centos 7 MariaDB Galera cluster 部署

    一.安装环境准备 1.系统: CentOS Linux release 7.4.1708 (Core) 2.hosts 10.6.32.51 openstack1 10.6.32.52 opensta ...

  7. MariaDB Galera Cluster部署实践

    原理 官方地址:http://galeracluster.com/documentation-webpages/index.html Galera Cluster与传统的复制方式不同,不通过I/O_t ...

  8. 从 MySQL+MMM 到 MariaDB+Galera Cluster : 一个高可用性系统改造

    很少有事情比推出高可用性(HA)系统之后便经常看到的系统崩溃更糟糕.对于我们这个Rails运行机的团队来说,这个失效的HA系统是MySQL多主复制管理器(MMM). 我们已经找寻MMM的替代品有一段时 ...

  9. Centos 7 下 Mysql 5.7 Galera Cluster 集群部署

     一.介绍 传统架构的使用,一直被人们所诟病,因为MySQL的主从模式,天生的不能完全保证数据一致,很多大公司会花很大人力物力去解决这个问题,而效果却一般,可以说,只能是通过牺牲性能,来获得数据一致性 ...

随机推荐

  1. 更新Android Studio 3.0碰到的问题

    更新完后试下运行正在维护的旧项目,出现各种错误,因为后来发现问题不在这,所以没记完整,大概如下: A larger heap for the Gradle daemon is recommended ...

  2. iOS下OpenCV开发配置的两个常见问题(sign和link)

    本文为作者原创,转载请注明出处(http://www.cnblogs.com/mar-q/)by 负赑屃 先上可以运行官方推荐的<OpenCV for iOS samples>的demo链 ...

  3. 使用 Hadoop 进行语料处理(面试题)

    原创播客,如需转载请注明出处.原文地址:http://www.cnblogs.com/crawl/p/7751741.html ------------------------------------ ...

  4. Django+Nginx+uWSGI部署

    一.介绍 Django的部署可以有多种方式,采用nginx+uwsgi的方式是最常见的一种方式.在这种方式中,将nginx作为服务器前端,接收WEB的所有请求,统一管理请求.nginx把所有静态请求自 ...

  5. grunt-contrib-connect自动刷新html页面

    grunt-contrib-connect可以在我们开发的时候自动刷新页面,省去了手动刷新的时间. 下面说一下如何配置grunt-contrib-connect 1.下载插件包 npm install ...

  6. 分布式数据库TiDB的部署

    转自:https://my.oschina.net/Kenyon/blog/908370 一.环境 CentOS Linux release 7.3.1611 (Core)172.26.11.91   ...

  7. code forces 439 C. The Intriguing Obsession

    C. The Intriguing Obsession time limit per test 1 second memory limit per test 256 megabytes input s ...

  8. Maple trees(最小覆盖圆)

    Maple trees Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total S ...

  9. Is It A Tree?

    Is It A Tree? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...

  10. 用正则表达式(regex)匹配多项式(polynomial)

    因为作业的要求,我需要识别用户从命令行输入的多项式,并且要提取出其中的系数.指数以便用于后续计算. 曾经想过用一个数组把用户所有的输入全部存进来,然后在写逻辑判断.但想想那复杂的逻辑,头皮都发麻,这时 ...