#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. 相对定位的div没有出现纵向滚动条

    在一个相对定位的div中绝对定位很多html元素,纵向没有滚动条出现.原因:我们期望作为原点的点在窗口原点的下方,但是滚动条以窗口原点作为原点,所以没有出现滚动条.解决:在div外面再套一个div,o ...

  2. java springmvc+bui+bootstrap后台管理系统搭建

    先来说说bui,这个框架是阿里巴巴的一个前端团队研发的,能够用很少的代码快速搭建一个后台管理系统,很适做管理平台的开发, 之前用过类似这样的框架extjs,做个比较,这个框架实现功能比extjs的代码 ...

  3. Java基础笔记2

    1.   变量的定义 int money; int 变量类型   money 变量名 money=1000;变量的值 2.  自动类型转换 ①类型要兼容  容器 (水杯---竹篮---碗) ②目标类型 ...

  4. [译]ASP.NET Core 2.0 路由引擎之网址生成

    问题 如何在ASP.NET Core 2.0中由路由引擎来生成网址? 答案 新建一个空项目,修改Startup.cs文件,添加MVC服务和中间件: public void ConfigureServi ...

  5. 压缩感知重构算法之子空间追踪(SP)

    SP的提出时间比CoSaMP提出时间稍晚一些,但和压缩采样匹配追踪(CoSaMP)的方法几乎是一样的.SP与CoSaMP主要区别在于“In each iteration, in the SP algo ...

  6. 两个HTML地址栏传中文参数乱码

    这个不叫乱码,我非专业.这个是url编码,js本身就是读取url编码的.对于js获取url的中文你可以尝试用escape() encodeURI() encodeURIComponent() deco ...

  7. Leetcode题解(十二)

    33.Search in Rotated Sorted Array 题目 这道题目如果没有其他要求,直接遍历一遍就可以知道答案,但是,题目给出了是排序了数组,但是数组有可能经过了旋转得到,其解题思路仍 ...

  8. linux的特殊符号与正则表达式

    第1章 linux的特殊符号 1.1 通配符 * {} 1.1.1 含义 方便查找文件 通配符是用来找文件名字的. 1.1.2  * 通过find 命令找以 .sh 结尾的文件,使用*替代文件名字. ...

  9. Pandas常用函数入门

    一.Pandas Python Data Analysis Library或Pandas是基于NumPy的一种工具,该工具是为了解决数据分析任务而创建的.Pandas纳入了大量库和一些标准的数据模型, ...

  10. Spring IOC容器分析(1) -- BeanFactory

    搭建好源码阅读环境后,就可以慢慢走进Spring殿堂了.IOC是Inversion of Control的缩写,控制反转的意思.很多人可能都知道IOC是spring的核心,将对象的创建初始化等权限交由 ...