linux中manager的使用
发表于:2026-11-01 作者:千家信息网编辑
千家信息网最后更新 2026年11月01日,1、在manager节点写入此脚本[root@manager scripts]# cat /scripts/master_ip_failover #!/usr/bin/env perluse stri
千家信息网最后更新 2026年11月01日linux中manager的使用
1、在manager节点写入此脚本
[root@manager scripts]# cat /scripts/master_ip_failover #!/usr/bin/env perluse strict;use warnings FATAL => 'all';use Getopt::Long;my ( $command,$ssh_user,$orig_master_host,$orig_master_ip,$orig_master_port,$new_master_host,$new_master_ip,$new_master_port);my $vip = '192.168.20.100'; #这里指定VIP地址my $key = '0';my $ssh_start_vip = "/sbin/ifconfig ens33:$key $vip"; #这条指令是启动VIPmy $ssh_stop_vip = "/sbin/ifconfig ens33:$key down"; #这条指令是停止VIPGetOptions( 'command=s' => \$command, 'ssh_user=s' => \$ssh_user, 'orig_master_host=s' => \$orig_master_host, 'orig_master_ip=s' => \$orig_master_ip, 'orig_master_port=i' => \$orig_master_port, 'new_master_host=s' => \$new_master_host, 'new_master_ip=s' => \$new_master_ip, 'new_master_port=i' => \$new_master_port,);exit &main();sub main { print "\n\nIN SCRIPT TEST====$ssh_stop_vip==$ssh_start_vip===\n\n"; if ( $command eq "stop" || $command eq "stopssh" ) { my $exit_code = 1; eval { print "Disabling the VIP on old master: $orig_master_host \n"; &stop_vip(); $exit_code = 0; }; if ($@) { warn "Got Error: $@\n"; exit $exit_code; } exit $exit_code; } elsif ( $command eq "start" ) { my $exit_code = 10; eval { print "Enabling the VIP - $vip on the new master - $new_master_host\n"; &start_vip(); $exit_code = 0; }; if ($@) { warn $@; exit $exit_code; } exit $exit_code; } elsif ( $command eq "status" ) { print "Checking the Status of the script.. OK \n"; #`ssh $ssh_user\@cluster1 \" $ssh_start_vip \"`; exit 0; } else { &usage(); exit 1; }}# A simple system call that enable the VIP on the new mastersub start_vip() { `ssh $ssh_user\@$new_master_host \" $ssh_start_vip \"`;}# A simple system call that disable the VIP on the old_mastersub stop_vip() { return 0 unless ($ssh_user); `ssh $ssh_user\@$orig_master_host \" $ssh_stop_vip \"`;}sub usage { print "Usage: master_ip_failover --command=start|stop|stopssh|status --orig_master_host=host --orig_master_ip=ip --orig_master_port=port --new_master_host=host --new_master_ip=ip --new_master_port=port\n";}[root@manager ~]# ll /scripts/master_ip_failover #需要保证脚本有可执行权限-rwxr-xr-x 1 root root 2006 2月 24 16:32 /scripts/master_ip_failover2、修改manager配置文件
[root@manager ~]# cat /etc/masterha/app1.cnf #配置文件指定脚本的位置[server default]manager_workdir=/var/log/masterha/app1manager_log=/var/log/masterha/app1/manager.loguser=managerpassword=123.comssh_user=rootrepl_user=mhareprepl_password=123.comping_interval=1master_ip_failover_script=/scripts/master_ip_failover #增加改行,指定脚本的位置即可。[server1]hostname=192.168.20.2port=3306master_binlog_dir=/usr/local/mysql/datacandidate_master=1[server2]hostname=192.168.20.3port=3306master_binlog_dir=/usr/local/mysql/datacandidate_master=1[server3]hostname=192.168.20.4port=3306master_binlog_dir=/usr/local/mysql/datano_master=1做到这里,就可以保证在切换master时,VIP地址也会随之切换到新的master主机上。
脚本
位置
地址
指令
文件
保证
切换
配置
主机
权限
节点
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
互联网科技
广东猪兼强互联网科技有限公司
互联网和科技技术
美国互联网保险保险科技
科技和互联网公司
易互联网科技有限公司
重庆科技学院互联网
恒生科技互联网指数分析
互联网科技公司需要的职位
隆华科技工业互联网
中国的互联网科技企业的崛起
现代互联网科技股
互联网为啥属于高科技
速维有品互联网信息科技(苏州)有限公司
如何创新互联网科技
佛山市翊博互联网络科技有限公司
朱啸虎曾投资哪些互联网科技企业
厦门江牛科技互联网
银川新华互联网科技学校是国营吗
科技互联网专业务虚会材料
亿人帮互联网科技有限公司
中国互联网科技工作委员会毛军
上海互联网科技有限公司
互联网科技英文
恒生科技互联网指数分析
重庆威客帮互联网科技
全球顶尖互联网科技公司
山东有哪些互联网科技公司
科技美学互联网 艺术
如何强化互联网金融科技