lxy777 发表于 2018-10-7 06:13:34

MySQL数据管理7-hj

  部署mysql高可集群 mysql-mmm + mysql主从同步
  环境准备(四台数据库服务器 12   11    10    9 )
  systemctlstop firewalld
  setenforce0
  配置YUM源
  yum -yinstallgccgcc-c++   perl-*
  systemctl   startmysqld
  ++++++++++++++++++++++++++++++
  一 配置mysql主从同步(12   11    10    9 )
  9 和10   配置为主主结构
  12和11配置为 10 的从数据库服务器
  要求:客户端访问数据库服务器9时 创建的库表记录 在 11 和12
  上也要有。
  用户授权:
  1 有同步数据权限的用户(9 和 10)
  grantreplicationslaveon*.*   toslaveuser@"%"
  identified by "123456";
  把9 和10   配置为主主结构
  9
  vim /etc/my.cnf
  
  server_id=9
  log_bin=master9
  binlog_format="mixed"
  :wq
  10
  vim /etc/my.cnf
  
  server_id=10
  log_bin=master10
  binlog_format="mixed"
  log_slave_updates
  :wq
  9
  mysql> change masterto
  master_host="192.168.4.10",master_user="slaveuser",
  master_password="123456",master_log_file="master10
  .000001",master_log_pos=154;
  mysql> show slave status\G;
  10
  mysql> change masterto
  master_host="192.168.4.9",master_user="slaveuser",m
  aster_password="123456",master_log_file="master9.00
  0001",master_log_pos=154;
  mysql> show slave status\G;
  12和11配置为 10 的从数据库服务器
  11
  vim /etc/my.cnf
  
  server_id=11
  :wq
  12
  vim /etc/my.cnf
  
  server_id=12
  :wq
  11 和 12
  mysql> change masterto
  master_host="192.168.4.10",master_user="slaveuser",
  master_password="123456",master_log_file="master10
  .000001",master_log_pos=154;
  mysql> show slave status\G;
  测试注册同步配置:
  9
  mysql> createdatabase gamedb;

  mysql>grant all on gamedb.*tostu10@"%">  by "123456";
  254
  mysql-h192.168.4.9-ustu10-p123456gamedb
  mysql> createtablet1(id int);
  mysql> insert intot1values(100);
  在其他3台数据库服务器上能够查看记录和授权用户
  selectuser,hostfrom mysql.userwhereuser="stu10";
  select* from gamedb.t1;
  二、配置mysql-mmm
  mysql-mmm软件介绍
  mmm_monitor 监控服务 运行在监控端
  mmm_agentd代理服务运行在数据库服务器上
  ip规划
  写vip地址 192.168.4.100 (9、10)
  读vip地址 192.168.4.101/102 (11、12)
  配置监控服务器8
  systemctlstop firewalld
  setenforce0
  配置YUM源
  yum -yinstallgccgcc-c++   perl-*
  装包 (12、 11   、 10 、 9 、8)
  5unzip mysql-mmm.zip
  cd mysql-mmm/
  tar -zxvf mysql-mmm-2.2.1.tar.gz
  cd mysql-mmm-2.2.1/
  make install
  配置文件说明
  ls /etc/mysql-mmm/
  mmm_mon.conf   mmm_monitor 监控服务的主配置文件
  mmm_agent.conf   mmm_agentd代理服务
  mmm_common.conf公共文件( 监控服务器和数据库服务器
  都要有)
  修改配置文件
  1、修改4台数据库服务器上mmm_agentd代理服务的主配置
  文件
  vim/etc/mysqlmmm/mmm_agent.conf
  include mmm_common.conf
  this 主机名#自定义
  :wq
  2 修改监控服务器上的mmm_monitor 监控服务的主配置文件
  3 修改公共文件mmm_common.conf公共文件
  4 在4台数据库服务器上根据mmm_common.conf配置文件中
  的设置添加对应的授权用户。
  mysql>grantreplicationclienton *.*to

  monitor@"%">  mysql>grantreplication client,process,super on *.*to

  agent@“%">  四、启动服务
  4.2 启动数据库服务器上agnetd服务
  2rpm -ivh perl-Log-Log4perl-1.26-1.el6.rf.noarch.rpm
  4tar -zxvf Algorithm-Diff-1.1902.tar.gz
  6cd Algorithm-Diff-1.1902/
  8perl Makefile.PL
  9make
  10make install
  13tar -zxvf Proc-Daemon-0.03.tar.gz
  14cd Proc-Daemon-0.03/
  16perl Makefile.PL
  17make
  18make install
  21gunzip Net-ARP-1.0.8.tgz
  23tar -xvf Net-ARP-1.0.8.tar
  25cd Net-ARP-1.0.8/
  27perl Makefile.PL
  28make
  29make install
  31/etc/init.d/mysql-mmm-agent status
  32/etc/init.d/mysql-mmm-agent start
  33netstat -utnalp| grep :9989
  ls /var/log/mysql-mmm/mmm_agentd.log
  4.3 启动监控服务器上monitor服务
  2rpm -ivh perl-Log-Log4perl-1.26-1.el6.rf.noarch.rpm
  4tar -zxvf Algorithm-Diff-1.1902.tar.gz
  6cd Algorithm-Diff-1.1902/
  8perl Makefile.PL
  9make
  10make install
  13tar -zxvf Proc-Daemon-0.03.tar.gz
  14cd Proc-Daemon-0.03/
  16perl Makefile.PL
  17make
  18make install
  27/etc/init.d/mysql-mmm-monitor status
  28/etc/init.d/mysql-mmm-monitor start
  29netstat -utnalp| grep :9988
  30ls /var/log/mysql-mmm/mmm_mond.log
  登录监控服务器8的管理页面查看数据库服务器的状态
  # mmm_control help
  # mmm_control show
  # mmm_controlset_onlinemaster9
  # mmm_controlset_onlinemaster10
  # mmm_controlset_onlinemaster11
  # mmm_controlset_onlinemaster12
  # mmm_control show
  在数据库服务器本机查看获取的虚拟ip地址
  #ipaddrshow| grep192.168.4.100
  测试配置
  254客户端访问
  ping192.168.4.100
  mysql-h192.168.4.100   -ustu10-p123456   gamedb

页: [1]
查看完整版本: MySQL数据管理7-hj