hp-ux nginx实现webservice请求负载均衡,并监控nginx进程
来源:互联网 发布:中国网民数据统计 编辑:程序博客网 时间:2024/06/16 10:15
下载nginx-1.5.7.tar.gz, zlib-1.2.8.tar.gz安装nginx:./configure: error: the HTTP rewrite module requires the PCRE library.root安装pcre-8.33.tar.gz perl库再nginx:./configure: error: the HTTP gzip module requires the zlib library.gzip -d或者gunzip 解压tar.gz文件tar xvf zlib-1.2.8.tar安装nginx时还是报错:./configure: error: the HTTP gzip module requires the zlib library.nginx without去除安装模块,默认安装到/usr/local/nginx下./configure --user=root --group=sys --without-http_gzip_module即可成功安装(./cofigure ,make,make install)修改/usr/local/nginx/conf/nginx.conf增加配置: #设定负载均衡的服务器列表 upstream localhost { # #weigth参数表示权值,权值越高被分配到的几率越大 # #本机上的Squid开启3128端口 # #server 192.168.8.3:80 weight=6; server 10.25.79.97:9998; server 10.25.79.98:9998; }server { #listen 80; listen 9999; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; #webservice conf proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://localhost; }启动/停止:参考http://blog.csdn.net/lhl62411570/article/details/8108627启动:[interface1]:/usr/local/nginx/sbin #/usr/local/nginx/sbin/nginxnginx: [emerg] bind() to 0.0.0.0:9999 failed (226: Unknown error)------端口被占用了查看进程:ps -ef|grep nginx停止:./nginx -s stop
nginx多站点配置:http://www.jb51.net/article/27533.htm
http://blog.csdn.net/ouyangzhan/article/details/6015243
monNginx.sh:监控脚本#Deploy to nginx/sbinWORK_HOME=/usr/local/nginxRestart(){ $WORK_HOME/sbin/nginx -s stop sleep 1 $WORK_HOME/sbin/nginx msg=`hostname`,Ngnix,`date +%Y%m%d%H%M%S`,$1 echo "$msg" >> $WORK_HOME/sbin/mon.log #sh $WORK_HOME/sh/sendmail.sh $msg}MonPname(){ pid=`ps -ef | grep "$WORK_HOME/sbin/nginx" |grep -v grep| wc -l` if [ $pid -le 0 ] ; then Restart "MonPname,restart" fi}MonPort(){ pid=`netstat -an |grep 9999 |grep LISTEN` if [ "$pid" = "" ] then Restart "MonPort,restart" fi}MonPnameMonPort