设为首页 收藏本站
查看: 956|回复: 0

[经验分享] mysql galera HA-CD潜者

[复制链接]

尚未签到

发表于 2018-10-9 09:27:55 | 显示全部楼层 |阅读模式
  MariaDB+gelera  HA
  环境信息
  centos 7.2.1511
  版本信息
  MariaDB 10.1.19-client
  MariaDB 10.1.19-common
  MariaDB 10.1.19-server
  安装mariadb
  yum install MariaDB-serverMariaDB-client
  测试mysql是否正常
  Service mysql start
  Service mysql stop
  创建mysql数据存放目录并授权
  mkdir -p  /data
  chown -R mysql.mysql /data
  删除存在的数据库文件
  rm -rf /var/lib/mysql/*
  修改/etc/my.cnf
  [mysqld]
  binlog_format=ROW
  bind-address = 172.16.16.1
  collation-server = utf8_general_ci
  character-set-server = utf8
  default_storage_engine=innodb
  datadir = /data
  max_connections = 4096
  pid-file = /data/mysql/mysql.pid
  query_cache_size=0
  socket = /tmp/mysql.sock
  #*Innodb setting
  #
  innodb_file_per_table
  innodb_autoinc_lock_mode=2
  innodb_flush_log_at_trx_commit=0
  innodb_buffer_pool_size=256M
  初始化数据库
  mysql_install_db
  重新启动数据库
  service mysql start
  创建链接文件
  ln -s /tmp/mysql.sock /var/lib/mysql/
  安全安装
  mysql_secure_installation
  NOTE: RUNNING ALL PARTS OF THISSCRIPT IS RECOMMENDED FOR ALL MariaDB
  SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
  In order to log into MariaDB tosecure it, we'll need the current
  password for the root user.  If you've just installed MariaDB, and
  you haven't set the root passwordyet, the password will be blank,
  so you should just press enterhere.
  Enter current password for root(enter for none):
  OK, successfully used password,moving on...
  Setting the root password ensuresthat nobody can log into the MariaDB
  root user without the properauthorisation.
  Set root password? [Y/n] Y
  New password:
  Re-enter new password:
  Password updated successfully!
  Reloading privilege tables..
  ... Success!
  By default, a MariaDB installationhas an anonymous user, allowing anyone
  to log into MariaDB without havingto have a user account created for
  them.  This is intended only for testing, and tomake the installation
  go a bit smoother.  You should remove them before moving into a
  production environment.
  Remove anonymous users? [Y/n] Y
  ... Success!
  Normally, root should only beallowed to connect from 'localhost'. This
  ensures that someone cannot guess atthe root password from the network.
  Disallow root login remotely?[Y/n] n
  ... skipping.
  By default, MariaDB comes with adatabase named 'test' that anyone can
  access.  This is also intended only for testing, andshould be removed
  before moving into a productionenvironment.
  Remove test database and access toit? [Y/n] y
  - Dropping test database...
  ... Success!
  - Removing privileges on test database...
  ... Success!
  Reloading the privilege tableswill ensure that all changes made so far
  will take effect immediately.
  Reload privilege tables now? [Y/n]y
  ... Success!
  Cleaning up...
  All done!  If you've completed all of the above steps,your MariaDB
  installation should now be secure.
  Thanks for using MariaDB!
  创建同步用户

  grant all privileges on *.* to 'wsrep_user'@'controller2'>  flush privileges;
  更新gelera下wsrep信息
  编辑/etc/my.cnf.d/server.cnf
  [galera]
  wsrep_on=ON
  wsrep_provider=/usr/lib64/galera/libgalera_smm.so
  wsrep_cluster_address=gcomm://
  wsrep_cluster_name='dbcluster'
  wsrep_node_address='172.16.16.1'
  wsrep_sst_method=rsync
  #wsrep_sst_method=xtrabackup
  wsrep_sst_auth=wsrep_user:wsreppasswd
  wsrep_node_name='HA-1'
  wsrep_node_address=172.16.16.1
  wsrep_provider_options="pc.recovery=TRUE;gcache.size=300M"
  此时没有同步对象,所以wsrep_cluster_address=gcomm://留空
  启动节点
  sudo -u mysql mysqld --wsrep-cluster-address='gcomm://'
  首先配置节点2
  使用1的配置文件直接复制后,修改信息
  [mysqld]
  bind-address = 172.16.16.2
  [gelera]
  wsrep_cluster_address=gcomm://172.16.16.1
  wsrep_node_address='172.16.16.2'
  wsrep_node_name='HA-2'
  wsrep_node_address=172.16.16.2
  此时数据同步方向为2同步1
  启动节点2上的服务
  同步完成后
  关闭节点1服务
  service mysql stop
  修改同步对象wsrep_cluster_address=gcomm://172.16.16.2
  重启服务后,双向同步完成,验证服务
  MariaDB
  [(none)]>show global status like 'wsrep_cluster%';
  从此处可以看出当有其他节点加入到集群中时,wsrep_cluster_size可以反映出当前集群节点数量,wsrep_cluster_status可以判定当前节点属于primary还是slave
  GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
  GRANT ALL PRIVILEGES ON *.* TO 'root'@'' WITH GRANT OPTION;
  mysqladmin flush-hosts -h172.16.16.1 -P3306 -uroot -pdftcpass
  mysql -uroot -h172.16.16.10 -P3307 -pdftcpass


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-619414-1-1.html 上篇帖子: centos7配置mysql的主从复制 下篇帖子: mysql密码忘记了怎么办
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表