这几天学习了一下heartbeat的资料,想参照 Two Apache Web Servers in an Active/Active Configuration
做个Two Nginx Web Services in Active/Active HA。研究发现,heartbeat所管理的资源代理(Resource Agent),有OCF、LSB等几种
。LSB这种shell脚本我还能依葫芦画瓢的写一点,参考linux系统中的原有脚本和网上资料,写了一个很简单的:
#!/bin/bash
#
# nginx: Control the nginx Daemon
#
# Version: @(#) /etc/init.d/nginx 0.1
#
# description: This is a init.d script for nginx. Tested on CentOS4. \
# Change DAEMON and PIDFILE if neccessary.
#
#Location of nginx binary. Change path as neccessary
DAEMON=/usr/local/nginx/sbin/nginx
NAME=`basename $DAEMON`
#Pid file of nginx, should be matched with pid directive in nginx config file.
PIDFILE=/var/run/$NAME.pid
#this file location
SCRIPTNAME=/etc/init.d/$NAME
#only run if binary can be found
test -x $DAEMON || exit 0
RETVAL=0
start() {
echo $"Starting $NAME"
$DAEMON
RETVAL=0
}
stop() {
echo $"Graceful stopping $NAME"
[ -s "$PIDFILE" ] && kill -QUIT `cat $PIDFILE`
RETVAL=0
}
forcestop() {
echo $"Quick stopping $NAME"
[ -s "$PIDFILE" ] && kill -TERM `cat $PIDFILE`
RETVAL=$?
}
reload() {
echo $"Graceful reloading $NAME configuration"
[ -s "$PIDFILE" ] && kill -HUP `cat $PIDFILE`
RETVAL=$?
}
status() {
if [ -s $PIDFILE ]; then
echo $"$NAME is running."
RETVAL=0
else
echo $"$NAME stopped."
RETVAL=3
fi
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
force-stop)
forcestop
;;
restart)
stop
start
;;
reload)
reload
;;
status)
status
;;
*)
echo $"Usage: $0 {start|stop|force-stop|restart|reload|status}"
exit 1
esac
exit $RETVAL
注意对应的Nginx配置的PID指令。
参考资料:
LSBResourceAgent
Running and Controlling Nginx
分享到:
相关推荐
vi /etc/init.d/nginx 修改nginx后 chmod +x /etc/init.d/nginx /sbin/chkconfig nginx on sudo /sbin/chkconfig --list nginx /etc/init.d/nginx start
sudo /etc/init.d/nginx start 3.优雅停止Nginx服务 sudo /etc/init.d/nginx quit 4.加载最新配置 sudo /etc/init.d/nginx reload 5.立即停止Nginx服务 sudo /etc/init.d/nginx stop 感谢卢林威
在/etc/init.d下创建文件nginx [root@localhost ~]# vim /etc/init.d/nginx 其内容参考nginx官方文档 需要注意的配置: nginx=”/usr/local/nginx/sbin/nginx” //修改成nginx执行程序的路径。 NGINX_CONF_FILE=”/...
前言 自己通过nginx uwsgi 部署django项目,...sudo /etc/init.d/nginx start #重启nginx 8sudo /etc/init.d/nginx restart #停止nginx sudo /etc/init.d/nginx stop #很暴力的方法,我喜欢 sudo killall nginx 安装
查看面板入口:/etc/init.d/bt default bt 6修改宝塔账户 bt 5修改宝塔密码 3.登陆宝塔,安装环境 php7.0 nginx mysql 4.安装freeswitch yum install -y http://files.freeswitch.org/freeswitch-release
# echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf # /sbin/ldconfig 3:重新编译nginx 不会安装的看这里 http://www.yunwei8.com/nginx124/ # cd /soft/nginx-1.2.4 # ./configure --user=...
Nginx需要依赖的包: ssl功能需要openssl库(https://www.openssl.org/) gzip模块需要zlib库(http://www.zlib.net/) rewrite模块需要pcre库... Nginx包下载地址:http://nginx.org/en/download.html
查看面板入口:/etc/init.d/bt default bt 6修改宝塔账户 bt 5修改宝塔密码 3.登陆宝塔,安装环境 php7.0 nginx mysql 4.安装freeswitch yum install -y http://files.freeswitch.org/freeswitch-release
避免踩坑,免费持续更新
sudo ./configure sudo make sudo make install # 安装zlib库 cd /usr/local/src sudo wget http://zlib.net/zlib-1.2.11.tar.gz sudo tar -zxvf zlib-1.2.11.tar.gz cd zlib-1.2.11 sudo ./configure sudo make ...
查看面板入口:/etc/init.d/bt default bt 6修改宝塔账户 bt 5修改宝塔密码 3.登陆宝塔,安装环境 php7.0 nginx mysql 4.安装freeswitch yum install -y ...
vim /etc/nginx/conf.d/nginx.conf 5.重启nginx服务 service nginx restart 6.页面尝试访问本地资源 7.访问成功! 总结 以上所述是小编给大家介绍的linux服务器上使用nginx访问本地静态资源的方法,希望对大家...
/application/nginx-1.6.3/conf/nginx.conf.default /application/nginx-1.6.3/conf/scgi_params /application/nginx-1.6.3/conf/scgi_params.default /application/nginx-1.6.3/conf/uwsgi_params /application/...
很多人都会遇到这样的情况,主域名后缀:index.html被百度收录了,为了不被分权! 想把index.html后缀301重定向到主域名,例: ... 这样的好处: 主页权重不会分散太厉害,301要比再robots里频闭的效果要好。
./init_system.sh #此脚本参见http://kerry.blog.51cto.com/172631/555535 三、LVS+keeplived #关于LVS+keeplived的配置请参考我的另一篇博文《CentOS5.5环境下布署LVS+keepalived 》...
安装好nginx环境及其依赖之后,配置nginx/conf/nginx.conf文件 server { listen 80; server_name #当前主机的域名或主机名; location / { proxy_pass http://放置html的服务器的ip:端口; } location /...
vim /etc/init.d/nginxd 2.输入如下内容: 注意:该文件中的如下几个变量,都需要根据你实际的目录来改写。 nginx=/usr/local/nginx/sbin/nginx ##nginx的可执行文件路径 lockfile=/var/nginx/nginx.lock ##需要先...
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 4、开始推流 做好以上的配置后,就可以开始推流了,我们可以使用obs来推流。 在设置->串流 中填写信息:URL为 rtmp://xxx:1935/hls,xxx为你的...
nginx安装与使用 ... Nginx开发从入门到精通 ... nginx官网上下载相应的安装包,--- 直接解压就行了 http://nginx.org/en/download.html 相应的命令: nginx.exe -s stop //停止nginx ...nginx.exe -s quit //退出nginx