当前位置:  操作系统/服务器>linux
本页文章导读:
    ▪Nginx的configure中文说明      编译安装nginx时,须用到configure,本文为大家提供configure的中文说明,希望对大家有所帮助。 在不同版本间,选项可能会有些许变化,请总是使用 ./configure --help 命令来检查  --prefix=<path>.........
    ▪Nginx 实现简单负载均衡      本文仅提供nginx简单负载均衡的配置文件nginx.conf,供大家学习参考。 www.xxx.com 和 blog.xxx.com 域名均指向 Nginx 所在的服务器IP。 用户访问http://www.xxx.com,将其负载均衡到192.168.1.2:80、192.168.1.3:.........
    ▪关于nginx负载均衡配置的思考      虽然本文不是一篇讲解nginx负载均衡详细配置的文章,但其中的知识点,对有意深入学习nginx负载均衡配置的朋友,还是可称之为点睛之笔,仔细阅读,大有禆益咯。 在项目实施过程中发现,.........

[1]Nginx的configure中文说明
    来源: 互联网  发布时间: 2013-12-24

编译安装nginx时,须用到configure,本文为大家提供configure的中文说明,希望对大家有所帮助。

在不同版本间,选项可能会有些许变化,请总是使用 ./configure --help 命令来检查 

--prefix=<path> -- Nginx安装路径。如果没有指定,默认为 /usr/local/nginx。
--sbin-path=<path> -- Nginx可执行文件安装路径。只能安装时指定,如果没有指定,默认为<prefix>/sbin/nginx。
--conf-path=<path> -- 在没有给定-c选项下默认的nginx.conf的路径。如果没有指定,默认为<prefix>/conf/nginx.conf。
--pid-path=<path> -- 在nginx.conf中没有指定pid指令的情况下,默认的nginx.pid的路径。如果没有指定,默认为<prefix>/logs/nginx.pid。
--lock-path=<path> -- nginx.lock文件的路径。
--error-log-path=<path> -- 在nginx.conf中没有指定error_log指令的情况下,默认的错误日志的路径。如果没有指定,默认为<prefix>/logs/error.log。
--http-log-path=<path> -- 在nginx.conf中没有指定access_log指令的情况下,默认的访问日志的路径。如果没有指定,默认为<prefix>/logs/access.log。
--user=<user> -- 在nginx.conf中没有指定user指令的情况下,默认的nginx使用的用户。如果没有指定,默认为 nobody。
--group=<group> -- 在nginx.conf中没有指定user指令的情况下,默认的nginx使用的组。如果没有指定,默认为 nobody。
--builddir=DIR -- 指定编译的目录
--with-rtsig_module -- 启用 rtsig 模块
--with-select_module --without-select_module -- 允许或不允许开启SELECT模式,如果 configure 没有找到更合适的模式,比如:kqueue(sun os),epoll (linux kenel 2.6+), rtsig(实时信号)或者/dev/poll(一种类似select的模式,底层实现与SELECT基本相 同,都是采用轮训方法) SELECT模式将是默认安装模式
--with-poll_module --without-poll_module -- Whether or not to enable the poll module. This module is enabled by default if a more suitable method such as kqueue, epoll, rtsig or /dev/poll is not discovered by configure.
--with-http_ssl_module -- 开启HTTP SSL模块,使NGINX可以支持HTTPS请求。这个模块需要已经安装了OPENSSL,在DEBIAN上是libssl
--with-http_realip_module -- 启用 ngx_http_realip_module
--with-http_addition_module -- 启用 ngx_http_addition_module
--with-http_sub_module -- 启用 ngx_http_sub_module
--with-http_dav_module -- 启用 ngx_http_dav_module
--with-http_flv_module -- 启用 ngx_http_flv_module
--with-http_stub_status_module -- 启用 “server status” 页
--without-http_charset_module -- 禁用 ngx_http_charset_module
--without-http_gzip_module -- 禁用 ngx_http_gzip_module. 如果启用,需要 zlib 。
--without-http_ssi_module -- 禁用 ngx_http_ssi_module
--without-http_userid_module -- 禁用 ngx_http_userid_module
--without-http_access_module -- 禁用 ngx_http_access_module
--without-http_auth_basic_module -- 禁用 ngx_http_auth_basic_module
--without-http_autoindex_module -- 禁用 ngx_http_autoindex_module
--without-http_geo_module -- 禁用 ngx_http_geo_module
--without-http_map_module -- 禁用 ngx_http_map_module
--without-http_referer_module -- 禁用 ngx_http_referer_module
--without-http_rewrite_module -- 禁用 ngx_http_rewrite_module. 如果启用需要 PCRE 。
--without-http_proxy_module -- 禁用 ngx_http_proxy_module
--without-http_fastcgi_module -- 禁用 ngx_http_fastcgi_module
--without-http_memcached_module -- 禁用 ngx_http_memcached_module
--without-http_limit_zone_module -- 禁用 ngx_http_limit_zone_module
--without-http_empty_gif_module -- 禁用 ngx_http_empty_gif_module
--without-http_browser_module -- 禁用 ngx_http_browser_module
--without-http_upstream_ip_hash_module -- 禁用 ngx_http_upstream_ip_hash_module
--with-http_perl_module -- 启用 ngx_http_perl_module
--with-perl_modules_path=PATH -- 指定 perl 模块的路径
--with-perl=PATH -- 指定 perl 执行文件的路径
--http-log-path=PATH -- 指定access log 文件的路径
--http-client-body-temp-path=PATH -- 指定http客户端请求缓存文件存放的目录
--http-proxy-temp-path=PATH -- 指定http反向代理缓存文件存放的目录
--http-fastcgi-temp-path=PATH -- 指定http fastCGI缓存文件存放的目录
--without-http -- 禁用 HTTP server
--with-mail -- 启用 IMAP4/POP3/SMTP 代理模块
--with-mail_ssl_module -- 启用 ngx_mail_ssl_module
--with-cc=PATH -- 指定 C 编译器的路径
--with-cpp=PATH -- 指定 C 预处理器的路径
--with-cc-opt=OPTIONS -- Additional parameters which will be added to the variable CFLAGS. With the use of the system library PCRE in FreeBSD, it is necessary to indicate --with-cc-opt=”-I /usr/local/include”. If we are using select() and it is necessary to increase the number of file descriptors, then this also can be assigned here: --with-cc-opt=”-DFD_SETSIZE=2048″.
--with-ld-opt=OPTIONS -- Additional parameters passed to the linker. With the use of the system library PCRE in FreeBSD, itis necessary to indicate --with-ld-opt=”-L /usr/local/lib”.
--with-cpu-opt=CPU -- 为特定的 CPU 编译,有效的值包括:pentium, pentiumpro, pentium3, pentium4, athlon, opteron, amd64,

sparc32, sparc64, ppc64
--without-pcre -- 禁止 PCRE 库的使用。同时也会禁止 HTTP rewrite 模块。在 “location” 配置指令中的正则表达式也需要 PCRE 。
--with-pcre=DIR -- 指定 PCRE 库的源代码的路径。
--with-pcre-opt=OPTIONS -- 设置pcre库的源代码路径
--with-md5=DIR -- 设置MD5库的源代码 路径
--with-md5-opt=OPTIONS -- MD5库的额外编译选项
--with-md5-asm -- MD5汇编源码
--with-sha1=DIR -- sha1库的 源代码 路径
--with-sha1-opt=OPTIONS -- sha1库的 额外编译选项
--with-sha1-asm -- 使用sha1 汇编源码
--with-zlib=DIR -- zlib库的源代码路径
--with-zlib-opt=OPTIONS -- zlib库的编译选项
--with-zlib-asm=CPU -- zlib库针对CPU优化,值有: pentium, pentiumpro
--with-openssl=DIR -- openssl库的源代码路径
--with-openssl-opt=OPTIONS -- openssl编译选项
--with-debug -- 启用调试日志
--add-module=PATH -- 增加第三方模块所在的路径


    
[2]Nginx 实现简单负载均衡
    来源: 互联网  发布时间: 2013-12-24

本文仅提供nginx简单负载均衡的配置文件nginx.conf,供大家学习参考。

www.xxx.com 和 blog.xxx.com 域名均指向 Nginx 所在的服务器IP。
用户访问http://www.xxx.com,将其负载均衡到192.168.1.2:80、192.168.1.3:80、192.168.1.4:80、192.168.1.5:80四台服务器。
用户访问http://blog.xxx.com,将其负载均衡到192.168.1.7服务器的8080、8081、8082端口。

配置文件nginx.conf:
 

代码如下:

user  www www;
worker_processes 10;
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

#最大文件描述符
worker_rlimit_nofile 51200;

events
{
      use epoll;
      worker_connections 51200;
}

http
{
      include       conf/mime.types;
      default_type  application/octet-stream;
      keepalive_timeout 120;
      tcp_nodelay on;

      upstream  www.xxx.com  {
              server   192.168.1.2:80;
              server   192.168.1.3:80;
              server   192.168.1.4:80;
              server   192.168.1.5:80;
      }

      upstream  blog.xxx.com  {
              server   192.168.1.7:8080;
              server   192.168.1.7:8081;
              server   192.168.1.7:8082;
      }

      server
      {
              listen  80;
              server_name  www.xxx.com;

              location / {
                       proxy_pass        http://www.xxx.com;
                       proxy_set_header   Host             $host;
                       proxy_set_header   X-Real-IP        $remote_addr;
                       proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
              }

              log_format  www_s135_com  '$remote_addr - $remote_user [$time_local] $request '
                                '"$status" $body_bytes_sent "$http_referer" '
                                '"$http_user_agent" "$http_x_forwarded_for"';
              access_log  /data1/logs/www.log  www_s135_com;
      }

      server
      {
              listen  80;
              server_name  blog.xxx.com;

              location / {
                       proxy_pass        http://blog.xxx.com;
                       proxy_set_header   Host             $host;
                       proxy_set_header   X-Real-IP        $remote_addr;
                       proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
              }

              log_format  blog_s135_com  '$remote_addr - $remote_user [$time_local] $request '
                                '"$status" $body_bytes_sent "$http_referer" '
                                '"$http_user_agent" "$http_x_forwarded_for"';
              access_log  /data1/logs/blog.log  blog_s135_com;
      }
}


    
[3]关于nginx负载均衡配置的思考
    来源: 互联网  发布时间: 2013-12-24

虽然本文不是一篇讲解nginx负载均衡详细配置的文章,但其中的知识点,对有意深入学习nginx负载均衡配置的朋友,还是可称之为点睛之笔,仔细阅读,大有禆益咯。

在项目实施过程中发现,业务系统最前端的Cisco PIX535防火墙的外网IP映射的是内网Nginx负载均稀器的内网IP(DNAT),这时的Nginx负载均衡器的作用相当于整套系统的枢纽,如果该服务器发生故障,会导致整个网站无法访问,所以我们需要二台以上的Nginx负载均稀器,以实现故障转移和高可用性。实现的办法有如下:

一、二台Nginx负载均衡器通过Keepalived形成高可用,防火墙映射的是Keepalived形成的vip地址;keepalived是lvs 的扩展形式,部署起来非常容易,成熟的案例在sina等企业也得到应用;但Keepalived做不到监控nginx服务级别,即如果nginx服务崩溃了,Keepalived也没有办法,虽然可以通过Heartbeat来解决这个问题,但Heartbeat本身就存在着裂脑情况,所以目前我只是将 Heartbeat用于内部测试环境,生产环境我仍然是用Keepalived。

二、最前端不用Cisco防火墙映射,而用F5代替;第二层用二台或二台以上的Nginx负载均衡器,第三层才是web集群,这样的好处很明显:不存在单点Nginx负载均衡出现故障问题;但同样缺点也很明显:整个工程的成本增加,你的客户和老板很可能非常不满意。

三、张宴兄采用的办法是用DNS轮询,二台Nginx负载均衡器均提供一个虚拟的外网IP对应用DNS(应用环境为逍遥网xoyo.com),二台 Nginx上的故障转移通过自身的shell脚本来实现,具体请参见张宴的《实战Nginx-取代Apache的高性能web服务器》一书。方案很实用,而且也是线上环境,但美中不足的是我手上的证券系统,都只有IP,并无DNS域名对应,看来这个需要跟券商谈判争取了。

四、目前我手上跑的三套在线系统都是单机Nginx,是由于券商都有值班人员和监控系统Nagios,但这样会增加生产成本;我目前想的一个办法是:在Nginx负载均衡器上开启sendmail服务,运行一个监控shell脚本,每2-5分钟就wget http://172.16.110.61/test.php(为了避免Cisco防火墙某些技术上的限制,这里采用内网IP形式)即2分钟或5分钟就自动去获取一次后端web的某网页一次,如果正常就啥也不做;如果发生异常情况,就向我的139邮箱发送Ctritical警报。因为139邮箱对应了手机号码,所以此时手机将会收到报警信息,达到预警目的。

本文转自:topsage论坛。


    
最新技术文章:
▪linux系统中的列出敏感用户的脚本代码
▪a10 config backup for aXAPI
▪一键备份gitolite服务器的Shell脚本
▪nagios 分发文件实现代码
▪阿里云云服务器Linux系统更新yum源Shell脚本
▪一个监控LINUX目录和文件变化的Shell脚本分享
▪Linux下实现SSH免密码登录和实现秘钥的管理、...
▪Shell正则表达式之grep、sed、awk实操笔记
▪3个备份系统文件并邮件发送的Shell脚本分享
▪CentOS 6.3下给PHP添加mssql扩展模块教程
▪监控网站是否可以正常打开的Shell脚本分享
▪shell脚本编程之if语句学习笔记
▪shell脚本编程之循环语句学习笔记
▪shell脚本编程之case语句学习笔记
▪Shell脚本实现的阳历转农历代码分享
▪Shell脚本实现复制文件到多台服务器的代码分...
▪Shell脚本实现批量下载网络图片代码分享
▪Shell脚本实现检测文件是否被修改过代码分享
▪Shell脚本数组用法小结
▪Shell脚本批量重命名文件后缀的3种实现
▪C语言实现的ls命令源码分享
▪Linux下查找后门程序 CentOS 查后门程序的shell脚...
▪Shell 函数参数
▪linux shell 自定义函数方法(定义、返回值、变...
▪Shell实现判断进程是否存在并重新启动脚本分...
▪Shell脚本break和continue命令简明教程
▪Shell脚本函数定义和函数参数
▪让代码整洁、过程清晰的BASH Shell编程技巧
▪shell常用重定向实例讲解
▪awk中RS、ORS、FS、OFS的区别和联系小结
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3