Mysql-mmm 架构部署

    xiaoxiao2021-03-25  124

    前言 防止单点故障,虽然有master/master, master/slave 等架构,但是仅仅这样,在实际应用中,还是有诸多考虑。 再则,现如今一个企业为了节约成本,除了核心稳定无赖外,更多的考虑开源数据库,通过第三方软件,实现HA 架构。 话,不多说,说正事: MMM (Master-Master Replication Manager for MySQL) is a set of flexible scripts to per- form monitoring/failover and management of MySQL Master-Master replication configura- tions (with only one node writable at any time). The toolset also has the ability to read balance standard master/slave configurations with any number of slaves, so you can use it to move virtual IP addresses around a group of servers depending on whether they are behind in replication. In addition to that, it also has scripts for data backups, resynchronization between nodes etc. mmm_mond monitoring daemon which does all monitoring work and makes all decisions about roles moving and so on. mmm_agentd agent daemon which runs on each MySQL server and provides monitoring node with simple set of remote services. mmm_control simple script dedicated to management of the mmm mond processes by com- mands. Requirements For an MMM setup with n MySQL servers, you’ll need n + 1 hosts One host for each MySQL server; one host for the MMM monitor. 2 * (n + 1) IPs One IP for each host (see above); one IP for the writer role; n IPs for one reader role per host. monitor user A MySQL user with privileges REPLICATION CLIENT for MMM monitor. agent user A MySQL user with privileges SUPER, REPLICATION CLIENT, PROCESS for MMM agent. replication user A MySQL user with privileges REPLICATION SLAVE used for replication. tools user A MySQL user with privileges SUPER, REPLICATION CLIENT, RELOAD for MMM tools. Requirements - monitoring host perl with ithreads support • fping (if you want to run mmm_mond as non-root user) • Perl modules: − Algorithm::Diff − Class:Singleton − DBI and DBD::mysql − File::Basename − File::stat − File::Temp − Log::Dispatch − Log::Log4perl − Mail::Send − Net::Ping − Proc::Daemon − Thread::Queue − Time::HiRes 环境: Redhat 6.4 x86 64bit , Mysql 5.7.21 mmm 下载地址: http://mysql-mmm.org/doku.php 1, 配置 yum 源: 配置局域网yum源: [root@martin01 ~]# cat /etc/exports /data/YUM *(ro) [root@martin01 ~]# /etc/init.d/nfs restart [root@martin01 ~]# /etc/init.d/portreserve restart showmount -e 10.20.30.41 其他节点: /etc/init.d/nfs restart showmount -e 10.20.30.41 mount 10.20.30.41:/data/YUM /mnt/ 安装 rpm 包(我这里已经安装过oracle数据库,大部分的rpm 包已包含): yum install -y perl-* yum install -y libart_lgpl.x86_64 yum install -y rrdtool.x86_64  yum install -y rrdtool-perl.x86_64 yum install -y binutils* compat-libstdc++ elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers kernel-headers ksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel binutils-* compat-* gcc-* 2, 创建mysql 用户及素组: groupadd -g 1200 mysql useradd -m -g 1201 mysql mysql mkdir -pv /dba/mysql/data /dba/mysql/logfile 3, 关闭iptables selinux 4, 配置NTP ,同步时间 yum -y install ntpvi /etc/ntp.conf增加3个时间服务器server s2d.time.edu.cn iburst #西南地区网络中心server s2e.time.edu.cn iburst #西北地区网络中心server s2f.time.edu.cn iburst #东北地区网络中心启动ntp服务 systemctl start ntpd systemctl enable ntpd 查看状态ntpq -p 5, 安装Mysql 数据库 (主主复制) 在MySQL的主配置文件中修改/添加如下内容: Server-1上:  [mysqld]  server-id = 10  log-bin = mysql-bin  replicate-do-db = mydb  auto-increment-increment = 2  auto-increment-offset = 1 # service mysqld restart   Server-2上  [mysqld]  server-id = 20  log-bin = mysql-bin  replicate-do-db = mydb  auto-increment-increment = 2  auto-increment-offset = 2  # service mysqld restart 主1; (root@(none)) Mysql >flush tables with read lock; Query OK, 0 rows affected (0.00 sec) (root@(none)) Mysql >show master status; +-----------------+----------+--------------+------------------+---------------------------------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +-----------------+----------+--------------+------------------+---------------------------------------------+ | bin_3308.000008 | 194 | | | d6bcd601-f065-11e6-8e79-080027e19201:1-2238 | +-----------------+----------+--------------+------------------+---------------------------------------------+ 1 row in set (0.00 sec) (root@(none)) Mysql >UNLOCK TABLES; Query OK, 0 rows affected (0.00 sec) --my.cnf : (主主) [root@martin03 ~]# cat /etc/my.cnf [mysqld] basedir=/usr/local/mysql-5.7.16 datadir=/data/mysqldata port=3308 server_id=3 ########log settings######## slow_query_log = 1 log_error = /data/mysqllog/error_3308.log slow_query_log_file = /data/mysqllog/slow_3308.log log_queries_not_using_indexes = 1 log_slow_admin_statements = 1 log_slow_slave_statements = 1 log_throttle_queries_not_using_indexes = 10 expire_logs_days = 20 long_query_time = 2 min_examined_row_limit = 100 #########replication settings######## master_info_repository = TABLE relay_log_info_repository = TABLE log_bin = /data/mysqllog/bin_3308.log sync_binlog = 1 #gtid_mode = on #enforce_gtid_consistency = 1 log_slave_updates binlog_format = row relay_log = relay.log relay_log_recovery = 1 #binlog_gtid_simple_recovery = 1 slave_skip_errors = ddl_exist_errors replicate_ignore_db=information_schema,performance_schema,sys auto_increment_increment = 2 auto_increment_offset = 2 skip_name_resolve ########innodb settings######## innodb_page_size = 16384 innodb_buffer_pool_size = 2G innodb_buffer_pool_instances = 8 innodb_buffer_pool_load_at_startup = 1 innodb_buffer_pool_dump_at_shutdown = 1 innodb_lru_scan_depth = 2000 innodb_lock_wait_timeout = 5 innodb_io_capacity = 4000 innodb_io_capacity_max = 8000 innodb_flush_method = O_DIRECT innodb_file_format = Barracuda innodb_file_format_max = Barracuda innodb_undo_logs = 56 innodb_flush_neighbors = 1 innodb_log_file_size = 2G innodb_log_buffer_size = 8M innodb_purge_threads = 4 innodb_large_prefix = 1 innodb_thread_concurrency = 64 innodb_print_all_deadlocks = 1 innodb_strict_mode = 1 innodb_sort_buffer_size = 67108864 sql_mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER" --Base test db --主1 (root@(none)) Mysql >change master to -> master_host='10.20.30.43', -> master_user='replicate', -> master_password='replicate123', -> master_log_file='bin_3308.000002', -> master_log_pos=145447, -> master_port=3308; Query OK, 0 rows affected, 2 warnings (0.06 sec) --主2 (root@(none)) Mysql >change master to -> master_host='10.20.30.42', -> master_user='replicate', -> master_password='replicate123', -> master_log_file='bin_3308.000008', -> master_log_pos=194, -> master_port=3308; Query OK, 0 rows affected, 2 warnings (0.07 sec) 主1,主2; (root@(none)) Mysql >START SLAVE; Query OK, 0 rows affected (0.01 sec) 主1,主2; (root@(none)) Mysql >show slave status\G; *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 10.20.30.42 Master_User: replicate Master_Port: 3308 Connect_Retry: 60 Master_Log_File: bin_3308.000008 Read_Master_Log_Pos: 194 Relay_Log_File: relay.000002 Relay_Log_Pos: 319 Relay_Master_Log_File: bin_3308.000008 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: information_schema,performance_schema,sys Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 194 Relay_Log_Space: 516 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 2 Master_UUID: d6bcd601-f065-11e6-8e79-080027e19201 Master_Info_File: mysql.slave_master_info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates Master_Retry_Count: 86400 Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: Executed_Gtid_Set: 3dc1a784-f5c6-11e6-8a3d-080027e19201:1-5 Auto_Position: 0 Replicate_Rewrite_DB: Channel_Name: Master_TLS_Version: 1 row in set (0.00 sec) -- Slave_IO_Running: Yes Slave_SQL_Running: Yes ---约--- MMM配置: mmm_monitor : 10.20.30.41 mysql_master1 : 10.20.30.42 --write mysql_master2 : 10.20.30.43 --write mysql_slave1 : 10.20.30.41 --read port : 3308 write_vip 10.20.30.50 (master2) read_vip 10.20.30.51/52 (master1/slave1) 1, /etc/hosts 配置: [root@martin01 ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 ## --Mysql-- ## 10.20.30.41 martin01 10.20.30.42 martin02 10.20.30.43 martin03 ---到时mmm 配置解析时,很重要(主机名最好标准化) 新建同步数据库需要的用户  使用mysql-mmm时一共需要三个用户: replication、mmm_agent和mmm_monitor(管理服务器上用来监控cluster状态的用户,所以可以限定只能从管理服务器登录)。使用下面三条命令新建这三个用户并分配相应的权限  所有的mysql 服务器都运行一遍 (root@(none)) Mysql > grant replication slave on *.* to 'replicate'@'10.20.30.%' identified by 'replicate123'; (root@(none)) Mysql >GRANT SUPER, REPLICATION CLIENT, PROCESS ON *.* TO'mmm_monitor'@'10.20.30.%' identified by 'mmm_monitor123'; Query OK, 0 rows affected, 1 warning (0.01 sec) (root@(none)) Mysql >GRANT SUPER, REPLICATION CLIENT, PROCESS ON *.* TO'mmm_agent'@'10.20.30.%' identified by 'mmm_agent123'; Query OK, 0 rows affected, 1 warning (0.01 sec) (root@(none)) Mysql >flush privileges; Query OK, 0 rows affected (0.00 sec) 2, 安装mmm : [root@martin01 local]# tar -xvf mysql-mmm-2.2.1 -C /usr/local/ [root@martin01 local]# cd mysql-mmm-2.2.1/ [root@martin01 mysql-mmm-2.2.1]# ls bin COPYING etc INSTALL lib Makefile README sbin UPGRADE VERSION [root@martin01 mysql-mmm-2.2.1]# make install mkdir -p /usr/share/perl5/vendor_perl/MMM /usr/lib/mysql-mmm /usr/sbin /var/log/mysql-mmm /etc /etc/mysql-mmm /etc/init.d/ cp -r lib/Common/ /usr/share/perl5/vendor_perl/MMM [ -f /etc/mysql-mmm/mmm_common.conf ] || cp etc/mysql-mmm/mmm_common.conf /etc/mysql-mmm/ mkdir -p /usr/lib/mysql-mmm/agent/ cp -r lib/Agent/ /usr/share/perl5/vendor_perl/MMM cp -r bin/agent/* /usr/lib/mysql-mmm/agent/ cp -r etc/init.d/mysql-mmm-agent /etc/init.d/ cp sbin/mmm_agentd /usr/sbin [ -f /etc/mysql-mmm/mmm_agent.conf ] || cp etc/mysql-mmm/mmm_agent.conf /etc/mysql-mmm/ mkdir -p /usr/lib/mysql-mmm/monitor/ cp -r lib/Monitor/ /usr/share/perl5/vendor_perl/MMM cp -r bin/monitor/* /usr/lib/mysql-mmm/monitor/ cp -r etc/init.d/mysql-mmm-monitor /etc/init.d/ cp sbin/mmm_control sbin/mmm_mond /usr/sbin [ -f /etc/mysql-mmm/mmm_mon.conf ] || cp etc/mysql-mmm/mmm_mon.conf /etc/mysql-mmm/ mkdir -p /usr/lib/mysql-mmm/tools/ cp -r lib/Tools/ /usr/share/perl5/vendor_perl/MMM cp -r bin/tools/* /usr/lib/mysql-mmm/tools/ cp sbin/mmm_backup sbin/mmm_clone sbin/mmm_restore /usr/sbin [ -f /etc/mysql-mmm/mmm_tools.conf ] || cp etc/mysql-mmm/mmm_tools.conf /etc/mysql-mmm/ [root@martin01 mysql-mmm]# pwd /etc/mysql-mmm 3, 配置mmm 配置文件: [root@martin01 ~]# ll /etc/mysql-mmm/mmm_* -rw-r----- 1 root root 39 Mar 9 17:13 /etc/mysql-mmm/mmm_agent.conf -rw-r----- 1 root root 769 Mar 9 17:09 /etc/mysql-mmm/mmm_common.conf -rw-r----- 1 root root 410 Mar 9 16:34 /etc/mysql-mmm/mmm_mon.conf -rw-r----- 1 root root 1293 Feb 19 13:28 /etc/mysql-mmm/mmm_tools.conf mmm_common.conf 所有节点 配置参数一样: mmm_mon.conf 所有节点 配置参数一样: mmm_agent.conf 各节点自己信息(主机名): [root@martin01 mysql-mmm]# cat mmm_common.conf active_master_role writer <host default> cluster_interface eth0 agent_port 9989 mysql_port 3308 --不写,默认为3306,启动会连接失败 pid_path /var/run/mmm_agentd.pid bin_path /usr/lib/mysql-mmm/ replication_user replicate replication_password replicate123 agent_user mmm_agent agent_password mmm_agent123 </host> <host martin03> ip 10.20.30.43 --master2 mode master peer martin02 --master1 </host> <host martin02> ip 10.20.30.42 --master1 mode master peer martin03 --master2 </host> <host martin01> ip 10.20.30.41 --salve mode slave </host> <role writer> hosts martin03,martin02 ips 10.20.30.50 --vip_write mode exclusive </role> <role reader> hosts martin03,martin02,martin01 ips 10.20.30.51,10.20.30.52 --vip_read mode balanced </role> [root@martin01 mysql-mmm]# cat mmm_agent.conf --各节点自己信息(主机名) include mmm_common.conf this martin01 [root@martin01 mysql-mmm]# cat mmm_mon.conf include mmm_common.conf <monitor> ip 127.0.0.1 port 9988 pid_path /var/run/mmm_mond.pid bin_path /usr/lib/mysql-mmm/ status_path /var/lib/misc/mmm_mond.status ping_ips 10.20.30.42,10.20.30.43,10.20.30.41 auto_set_online 10 mode active wait_for_other_master 120 </monitor> <host default> monitor_user mmm_monitor monitor_password mmm_monitor123 </host> debug 1 -------------------------------------------------------- 启动: 自动启动agent 和 monitor a. 在monitor上启动 monitor b. 在所有数据库服务器上启动 agent c, MMM启动顺序:先启动monitor,再启动 agent # /etc/init.d/mysql-mmm-monitor restart & --monitor #[root@martin03 ~]# /etc/init.d/mysql-mmm-agent restart & [1] 2894 [root@martin03 ~]# Daemon bin: '/usr/sbin/mmm_agentd' Daemon pid: '/var/run/mmm_agentd.pid' Daemon bin: '/usr/sbin/mmm_agentd' Daemon pid: '/var/run/mmm_agentd.pid' Shutting down MMM Agent daemon not running. Daemon bin: '/usr/sbin/mmm_agentd' Daemon pid: '/var/run/mmm_agentd.pid' Starting MMM Agent daemon... Ok [1]+ Done /etc/init.d/mysql-mmm-agent restart 检测, 监控日志: [root@martin03 mysql-mmm]# pwd /var/log/mysql-mmm [root@martin03 mysql-mmm]# ll total 52 -rw-r--r-- 1 root root 2954 Mar 9 21:11 mmm_agentd.log -rw-r--r-- 1 root root 45015 Mar 9 21:11 mmm_mond.log --master 2 [root@martin03 ~]# mmm_control show martin01(10.20.30.41) slave/ONLINE. Roles: reader(10.20.30.51) martin02(10.20.30.42) master/ONLINE. Roles: reader(10.20.30.52) martin03(10.20.30.43) master/ONLINE. Roles: writer(10.20.30.50) [root@martin03 ~]# mmm_control checks all martin02 ping [last change: 2017/03/09 21:10:51] OK martin02 mysql [last change: 2017/03/09 21:10:51] OK martin02 rep_threads [last change: 2017/03/09 21:10:51] OK martin02 rep_backlog [last change: 2017/03/09 21:10:51] OK: Backlog is null martin03 ping [last change: 2017/03/09 21:10:51] OK martin03 mysql [last change: 2017/03/09 21:10:51] OK martin03 rep_threads [last change: 2017/03/09 21:10:51] OK martin03 rep_backlog [last change: 2017/03/09 21:10:51] OK: Backlog is null martin01 ping [last change: 2017/03/09 21:10:51] OK martin01 mysql [last change: 2017/03/09 21:10:51] OK martin01 rep_threads [last change: 2017/03/09 21:10:51] OK martin01 rep_backlog [last change: 2017/03/09 21:10:51] OK: Backlog is null [root@martin03 ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:e1:92:01 brd ff:ff:ff:ff:ff:ff inet 10.20.30.43/24 brd 10.20.30.255 scope global eth0 inet 10.20.30.50/32 scope global eth0 inet6 fe80::a00:27ff:fee1:9201/64 scope link tentative dadfailed valid_lft forever preferred_lft forever --master 1 : [root@martin02 ~]# mmm_control show martin01(10.20.30.41) slave/ONLINE. Roles: reader(10.20.30.51) martin02(10.20.30.42) master/ONLINE. Roles: reader(10.20.30.52) martin03(10.20.30.43) master/ONLINE. Roles: writer(10.20.30.50) [root@martin02 ~]# mmm_control checks all martin02 ping [last change: 2017/03/09 21:10:56] OK martin02 mysql [last change: 2017/03/09 21:10:56] OK martin02 rep_threads [last change: 2017/03/09 21:10:56] OK martin02 rep_backlog [last change: 2017/03/09 21:10:56] OK: Backlog is null martin03 ping [last change: 2017/03/09 21:10:56] OK martin03 mysql [last change: 2017/03/09 21:10:56] OK martin03 rep_threads [last change: 2017/03/09 21:10:56] OK martin03 rep_backlog [last change: 2017/03/09 21:10:56] OK: Backlog is null martin01 ping [last change: 2017/03/09 21:10:56] OK martin01 mysql [last change: 2017/03/09 21:10:56] OK martin01 rep_threads [last change: 2017/03/09 21:10:56] OK martin01 rep_backlog [last change: 2017/03/09 21:10:56] OK: Backlog is null [root@martin02 ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:e1:92:01 brd ff:ff:ff:ff:ff:ff inet 10.20.30.42/24 brd 10.20.30.255 scope global eth0 inet 10.20.30.52/32 scope global eth0 inet6 fe80::a00:27ff:fee1:9201/64 scope link tentative dadfailed valid_lft forever preferred_lft forever --slave [root@martin01 mysql-mmm]# mmm_control show martin01(10.20.30.41) slave/ONLINE. Roles: reader(10.20.30.51) martin02(10.20.30.42) master/ONLINE. Roles: reader(10.20.30.52) martin03(10.20.30.43) master/ONLINE. Roles: writer(10.20.30.50) [root@martin01 mysql-mmm]# mmm_control checks all martin02 ping [last change: 2017/03/09 21:10:58] OK martin02 mysql [last change: 2017/03/09 21:10:58] OK martin02 rep_threads [last change: 2017/03/09 21:10:58] OK martin02 rep_backlog [last change: 2017/03/09 21:10:58] OK: Backlog is null martin03 ping [last change: 2017/03/09 21:10:58] OK martin03 mysql [last change: 2017/03/09 21:10:58] OK martin03 rep_threads [last change: 2017/03/09 21:10:58] OK martin03 rep_backlog [last change: 2017/03/09 21:10:58] OK: Backlog is null martin01 ping [last change: 2017/03/09 21:10:58] OK martin01 mysql [last change: 2017/03/09 21:10:58] OK martin01 rep_threads [last change: 2017/03/09 21:10:58] OK martin01 rep_backlog [last change: 2017/03/09 21:10:58] OK: Backlog is null [root@martin01 mysql-mmm]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:e1:92:01 brd ff:ff:ff:ff:ff:ff inet 10.20.30.41/24 brd 10.20.30.255 scope global eth0 inet 10.20.30.51/32 scope global eth0 inet6 fe80::a00:27ff:fee1:9201/64 scope link valid_lft forever preferred_lft forever [root@martin01 mysql-mmm]# mmm_control ping OK: Pinged successfully! [root@martin02 ~]# mmm_control mode ACTIVE [root@martin01 mysql-mmm]# mmm_control help Valid commands are: help - show this message ping - ping monitor show - show status checks [<host>|all [<check>|all]] - show checks status set_online <host> - set host <host> online set_offline <host> - set host <host> offline mode - print current mode. set_active - switch into active mode. set_manual - switch into manual mode. set_passive - switch into passive mode. move_role [--force] <role> <host> - move exclusive role <role> to host <host> (Only use --force if you know what you are doing!) set_ip <ip> <host> - set role with ip <ip> to host <host> 连接测试: ------------------------------------ The End -------------------------------- 备准: 在实际安装过程中less and more 出现很多问题, 以下为问题解决方法: 1, 配置完成后, 直接通过启动 monitor,或 agend 时 报错: [root@martin02 ~]# /usr/local/mysql-mmm-2.2.1/etc/init.d/mysql-mmm-agent start Daemon bin: '/usr/sbin/mmm_agentd' Daemon pid: '/var/run/mmm_agentd.pid' Starting MMM Agent daemon... Can't locate Proc/Daemon.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/sbin/mmm_agentd line 7. BEGIN failed--compilation aborted at /usr/sbin/mmm_agentd line 7. failed 解决方法: --解决方案: [root@oracle ~]# cpan Proc::Daemon [root@oracle ~]# cpan Log::Log4perl yum install -y perl-* yum install -y libart_lgpl.x86_64 yum install -y mysql-mmm.noarch fail yum install -y rrdtool.x86_64 yum install -y rrdtool-perl.x86_64 通过设置网关,/etc/resolve.conf 配置后。通过网络下载: ---another way to install lib package in network cpan -i Algorithm::Diff Class::Singleton DBI DBD::mysql Log::Dispatch Log::Log4perl Mail::Send Net::Ping Proc::Daemon Time::HiRes Params::Validate Net::ARP ---------- [root@martin03 ~]# ping www.baidu.com PING www.a.shifen.com (14.215.177.38) 56(84) bytes of data. 64 bytes from 14.215.177.38: icmp_seq=1 ttl=56 time=33.4 ms [root@martin03 ~]# cpan -i Algorithm::Diff Class::Singleton DBI DBD::mysql Log::Dispatch Log::Log4perl Mail::Send Net::Ping Proc::Daemon Time::HiRes Params::Validate Net::ARP CPAN: Storable loaded ok (v2.20) CPAN: LWP::UserAgent loaded ok (v5.833) CPAN: Time::HiRes loaded ok (v1.9721) Warning: no success downloading '/root/.cpan/sources/authors/01mailrc.txt.gz.tmp10347'. Giving up on it. at /usr/share/perl5/CPAN/Index.pm line 225 Fetching with LWP: http://www.perl.org/CPAN/authors/01mailrc.txt.gz CPAN: YAML loaded ok (v0.70) Going to read '/root/.cpan/sources/authors/01mailrc.txt.gz' ............................................................................DONE Fetching with LWP: http://www.perl.org/CPAN/modules/02packages.details.txt.gz ................ ................ ................. ---30分钟 (yes) install lib package  yum install -y perl-* yum install -y libart_lgpl.x86_64 yum install -y mysql-mmm.noarch fail yum install -y rrdtool.x86_64  yum install -y rrdtool-perl.x86_64 7.1 []another way to install lib package in network cpan -i Algorithm::Diff Class::Singleton DBI DBD::mysql Log::Dispatch Log::Log4perl Mail::Send Net::Ping Proc::Daemon Time::HiRes Params::Validate Net::ARP ---------------------- 2,[root@martin02 ~]# /etc/init.d/mysql-mmm-agent start Daemon bin: '/usr/sbin/mmm_agentd' Daemon pid: '/var/run/mmm_agentd.pid' Starting MMM Agent daemon... Unknown variable <host in '/etc/mysql-mmm/mmm_common.conf' on line 16! at /usr/share/perl5/vendor_perl/MMM/Common/Config.pm line 224 failed --- 出现这样的原因 是因为: hosts 和 mmm_common 中设置不一样: 3, [root@martin03 ~]# /etc/init.d/mysql-mmm-monitor restart Daemon bin: '/usr/sbin/mmm_mond' Daemon pid: '/var/run/mmm_mond.pid' Daemon bin: '/usr/sbin/mmm_mond' Daemon pid: '/var/run/mmm_mond.pid' Shutting down MMM Monitor daemon: not running. Daemon bin: '/usr/sbin/mmm_mond' Daemon pid: '/var/run/mmm_mond.pid' Starting MMM Monitor daemon: Ok [root@martin03 ~]# mmm_control show ERROR: Can't connect to monitor daemon! [root@martin03 ~]# mmm_control checks all ERROR: Can't connect to monitor daemon! 错误描述: 在monitor启动后执行mmm_contorl show时显示下列信息 ERROR: Can't connect to monitor daemon! 解决方法: 修改配置文件 将debug=0 改为 debug=1 然后重新启动mysql-mmm-monitor 4, 错误描述: 2017/03/09 04:54:48 DEBUG rep_threads(db2) = 'UNKNOWN: Connect error (host = 10.20.30.43:3306, user = mmm_monitor)! Lost connection to MySQL server at 'reading initial communication packet', system error: 111' 2017/03/09 04:54:48 DEBUG Trying initial check 'rep_threads' on host 'db3' 2017/03/09 04:54:48 DEBUG rep_threads(db3) = 'UNKNOWN: Connect error (host = 10.20.30.41:3306, user = mmm_monitor)! Lost connection to MySQL server at 'reading initial communication packet', system error: 111' 2017/03/09 04:54:48 DEBUG Trying initial check 'rep_threads' on host 'db1' 2017/03/09 04:54:48 DEBUG rep_threads(db1) = 'UNKNOWN: Connect error (host = 10.20.30.42:3306, user = mmm_monitor)! Lost connection to MySQL server at 'reading initial communication packet', system error: 111' 2017/03/09 04:54:48 INFO Shutting down checker 'rep_threads'... 2017/03/09 04:54:48 WARN No binary found for killing hosts (/usr/lib/mysql-mmm//monitor/kill_host). 2017/03/09 04:54:48 FATAL There are more than two hosts configured which can handle the active master role. There are more than two hosts configured which can handle the active master role. at /usr/share/perl5/vendor_perl/MMM/Monitor/Monitor.pm line 262 2017/03/09 04:54:49 FATAL Child exited with exitcode 2 and has failed more than 10 times consecutively in the last 5 minutes, not restarting 错误原因: 因为你的agent配置文件里写的是this master2 .this master1.在host里没有对应的解析.所以无法连接。 解决方法: 1.可以在hosts.conf中写入每台mysql的主机名和IP的对应关系 2.可以使用DNS服务 3.可以在my.cnf中加入skip-name-resolve 然后重新启动mysql-mmm-monitor 4,mmm_common 中设置 mysql_port 参数: ----参考: http://mysql-mmm.org/mysql-mmm.html http://blog.csdn.net/mchdba/article/details/8633840 http://www.jb51.net/article/47095.htm http://blog.csdn.net/blog_liuliang/article/details/52850320 http://blog.chinaunix.net/uid-16844903-id-3152138.html
    转载请注明原文地址: https://ju.6miu.com/read-17447.html

    最新回复(0)