#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. PHP上传大文件配置

    使用PHP上传比较大的文件时,发现程序没反应,那是因为PHP的默认设置限制了上传文件的大小,所以要修改配置文件php.ini中的一些选项:(以下只是我个人的配置,大家可根据自己的实际需要配置) fil ...

  2. LeetCode 243. Shortest Word Distance (最短单词距离)$

    Given a list of words and two words word1 and word2, return the shortest distance between these two ...

  3. LeetCode 121. Best Time to Buy and Sell Stock (买卖股票的最好时机)

    Say you have an array for which the ith element is the price of a given stock on day i. If you were ...

  4. mysql用户权限设置,远程访问设置、设置固定ip远程访问,设置root用户不能远程访问mysql数据库

    关于mysql的用户管理,笔记   1.创建新用户 通过root用户登录之后创建 >> grant all privileges on *.* to testuser@localhost ...

  5. Windows环境下多线程编程原理与应用读书笔记(6)————临界段及其应用

    <一>临界段 临界段对象通过提供所有线程必须共享的对象来控制线程.只有拥有临界段对象的线程才能够访问保护的资源.在另一个线程可以访问该资源之前,前一线程必须释放临界段对象,一遍新的线程可以 ...

  6. 深入理解JavaScript中的继承:原型链篇

    一.何为原型链 原型是一个对象,当我调用一个对象的方法时,如果该方法没有在对象里面,就会从对象的原型去寻找.JavaScript就是通过层层的原型,形成原型链. 二.谁拥有原型 任何对象都可以有原型, ...

  7. JavaScript系列----一切皆是对象

    1.判断对象类型 1.1.typeof 运算符 首先要认识到,typepof是一个运算符,其运算需要一个参数,返回值是参数的类型. typeof使用方法 typeof parameter //使用方法 ...

  8. jQuery实现checkbox即点即改,批量计数,以及中间遇到的坑

    最近要用jQuery实现一个批量删除操作,效果如下图 最终页面page.html,此页面使用了bootstrap和jQuery,如果没有需要下载一下 <!DOCTYPE html> < ...

  9. Jquery中attr 和 prop的区别和联系

    昨天在选择借款方类型的时候总是会出现选择要点两次的现象,比如点击公司,第一次点击选择公司,没有选中,必须在次点击才可以选中,总感觉是有点延迟加载的意思,后来审查元素, 发现是redio元素,这样的话就 ...

  10. Wordpress上传文件 “无法建立目录wp-content/uploads/2018/25。有没有上级目录的写权限?”

    可能的原因有两个: wp-content/uploads 文件夹权限所限制 解决方法:修改wp-content/uploads 文件夹权限,可以借助ftp等工具: wp_options表中upload ...