这几天学习了一下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 安装
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 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
避免踩坑,免费持续更新
1. 启动 Nginx:/usr/local/nginx/sbin/nginx 或 /etc/init.d/nginx start 2. 停止 Nginx:/etc/init.d/nginx stop 3. 重启 Nginx:/etc/init.d/nginx restart 4. 查看 Nginx 的版本:/usr/local/nginx/sbin/nginx -...
配置nginx服务添加启动脚本到/etc/init.d/nginx,可以网上找一个模板或者自定义编写,确保服务可以启动、停止、重启。8. 配置nginx服务文件编辑 /usr/local/nginx/conf/nginx.conf ,添加以下内容: ```perl server...
查看面板入口:/etc/init.d/bt default bt 6修改宝塔账户 bt 5修改宝塔密码 3.登陆宝塔,安装环境 php7.0 nginx mysql 4.安装freeswitch yum install -y ...
Nginx的主配置文件位于`/usr/local/nginx/conf/nginx.conf`。为了保持主配置文件简洁,通常会采用包含多个子配置文件的方式。 - 在`nginx.conf`中添加如下行: ```bash include vhost/*.conf; ``` - 创建...
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/...
Restarting nginx daemon: nginxcat: /usr/local/nginx/logs/nginx.pid: No such file or directorykill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec … or kill -l [sigspec]nginx not ...
- Linux安装:通常通过编译源码完成,首先解压nginx-1.21.6.tar.gz,然后执行./configure,make,sudo make install等步骤,最后编辑/etc/nginx/nginx.conf配置文件并启动服务。 4. Nginx核心功能 - 静态文件服务...
安装好nginx环境及其依赖之后,配置nginx/conf/nginx.conf文件 server { listen 80; server_name #当前主机的域名或主机名; location / { proxy_pass http://放置html的服务器的ip:端口; } location /...