模块简略规划——用HA确保效劳高可用性ITeye - 众发娱乐

模块简略规划——用HA确保效劳高可用性ITeye

2019-01-10 18:04:21 | 作者: 碧萱 | 标签: 效劳,简略,浏览器 | 浏览: 3003

为了保证效劳的安稳运转,咱们能够选用keepalived或许HA的解决方案,下面是一个HA的装置装备示例:

 

首要别离在两台效劳器上装置HA(yast -i heartbeat)

server1:192.168.1.100

server2:192.168.1.101

 

修改/etc/ha.d/authkeys

auth 3
#1 crc
#2 sha1 HI!
3 md5 ciaoskey

 

修改/etc/ha.d/ha.cf

logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
warntime 10
udpport 19871
ucast eth0 192.168.1.101
#for server 2 configure 
#ucast eth0 192.168.1.100
auto_failback on
node server1 server2
ping 102.168.1.1

 

修改/etc/ha.d/haresources

server1 IPaddr::192.168.1.110/32 nginxd

 两台效劳器均监听110这个虚拟IP,前端浏览器拜访192.168.1.110即可。

 

ha效劳就能够经过/etc/init.d/heartbeat start|stop|reload等管理了

 

下面做一个简略的测验

A,别离发动两台机器的heartbeat

 

ciaos:~ # /etc/init.d/heartbeat start
Starting High-Availability services2012/11/22_17:10:41 INFO: Resource is stopped
heartbeat: udpport setting must precede media statementsheartbeat: baudrate setting must precede media statementsheartbeat[10368]: 2012/11/22_17:10:41 info: Version 2 support: false
heartbeat[10368]: 2012/11/22_17:10:41 WARN: Logging daemon is disabled --enabling logging daemon is recommended
heartbeat[10368]: 2012/11/22_17:10:41 info: **************************
heartbeat[10368]: 2012/11/22_17:10:41 info: Configuration validated. Starting heartbeat 2.1.3
 done

(用浏览器拜访192.168.1.110显现first server)

B,封闭100上面的HA,如下:

 

ciaos:~ # /etc/init.d/heartbeat stop
Stopping High-Availability services done
logd[10282]: 2012/11/22_17:10:04 debug: Stopping ha_logd with pid 9650
logd[10282]: 2012/11/22_17:10:04 info: Waiting for pid=9650 to exit
logd[10282]: 2012/11/22_17:10:05 info: Pid 9650 exited

(用浏览器拜访192.168.1.110显现second server)

C,重启100的HA,用浏览器拜访成果康复为first server

 

这样,一个简略的主备WEB效劳器就建立结束

 

附LSB格局脚本/etc/init.d/nginxd如下(需求拷贝到heartbeat的装置目录下)(网上那个版别找不到status指令,我这儿写了个函数简略替代,程序还有点问题)

 

#!/bin/sh
. /usr/lib/ocf/resource.d//heartbeat/.ocf-shellfuncs
RETVAL=0
prog="nginx"
nginxDir=/usr/local/nginx
nginxd=$nginxDir/sbin/nginx
nginxConf=$nginxDir/conf/nginx.conf
nginxPid=$nginxDir/logs/nginx.pid
nginx_check()
 if [[ -e $nginxPid ]]; then
 ps aux |grep -v grep |grep -q nginx
 if (( $? == 0 )); then
 echo "$prog already running..."
 exit 1
 else
 rm -rf $nginxPid /dev/null
start()
 nginx_check
 if (( $? != 0 )); then
 true
 else
 echo -n $"Starting $prog:"
 `$nginxd -c $nginxConf`
 RETVAL=$?
 echo
 [ $RETVAL = 0 ] touch /var/lock/subsys/nginx
 return $RETVAL
stop()
 echo -n $"Stopping $prog:"
 killproc $nginxd
 RETVAL=$?
 echo
 [ $RETVAL = 0 ] rm -f /var/lock/subsys/nginx $nginxPid
reload()
 echo -n $"Reloading $prog:"
 killproc $nginxd -HUP
 RETVAL=$?
 echo
status()
 nginx_check
 if (( $? != 0 )); then
 return 0
 else
 return 1
monitor()
 status $prog /dev/null
 if (( $? == 0 )); then
 RETVAL=0
 else
 RETVAL=7
case "$1" in
 start)
 start
 stop)
 stop
 restart)
 stop
 start
 reload)
 reload
 status)
 status $prog
 RETVAL=$?
 monitor)
 monitor
 echo $"Usage: $0 {start|stop|restart|reload|status|monitor}"
 RETVAL=1
exit $RETVAL
版权声明
本文来源于网络,版权归原作者所有,其内容与观点不代表众发娱乐立场。转载文章仅为传播更有价值的信息,如采编人员采编有误或者版权原因,请与我们联系,我们核实后立即修改或删除。

猜您喜欢的文章

阅读排行

  • 1

    (转)sshdITeye

    运用,设定,这个
  • 2

    几种监控用守时使命ITeye

    监控,网络连接,进程
  • 3

    Ubuntu下装置php扩展ITeye

    装置,扩展,办法
  • 4
  • 5
  • 6
  • 7

    浅谈https\ssl\数字证书(2)ITeye

    证书,数字证书,客户端
  • 8
  • 9
  • 10