nginx调度器

文章目录

环境准备

iptables和selinux关闭
服务器:
server1: 172.25.35.51
server2: 172.25.35.52
server3: 172.25.35.53
安装nginx

[root@server1 ~]# ls
nginx-1.14.0.tar.gz
[root@server1 ~]# tar zxf nginx-1.14.0.tar.gz
[root@server1 ~]# cd nginx-1.14.0/src/core
[root@server1 cc]# ./configure --help
[root@server1 nginx-1.14.0]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-threads --with-file-aio //检测编译环境是否完善
[root@server1 nginx-1.14.0]# make
[root@server1 nginx-1.14.0]# make install
[root@server1 nginx-1.14.0]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-threads --with-file-aio
[root@server1 nginx-1.14.0]# cd /usr/local/nginx/sbin/
[root@server1 sbin]# ln -s /usr/local/nginx/sbin/nginx /sbin/
[root@server1 sbin]# nginx -t //检测语法错误
[root@server1 sbin]# nginx //打开nginx
[root@server1 sbin]# nginx -s reload //重新加载
[root@server1 sbin]# nginx -s stop //关闭nginx
[root@server1 sbin]# cd …
[root@server1 nginx]# cd html
[root@server1 html]# vim ying.html

www.ying.org

[root@server1 html]# nginx

nginx做调度器

[root@server1 ~]# cd /usr/local/nginx/conf
[root@server1 conf]# lscpu
CPU(s):                2



[root@server1 conf]# vim nginx.conf
user  nginx nginx;
worker_processes  2;
worker_cpu_affinity 01 10;
events {
    worker_connections  65535;
}
http {
        upstream ying {
#ip_hash;  //Ip不变后端服务器不变,持续的后端连接
        server 172.25.35.52:80;
        server 172.25.35.53:80;
server 127.0.0.1;
        }
server{
                listen 80;
                server_name www.westos.org;  //域名访问
                location / {
                proxy_pass http://ying;  //调度ying
        }
        }


[root@server1 conf]# vim /etc/security/limits.conf
 nginx   -       nofile 65536


[root@server1 conf]# useradd -M -d /usr/local/nginx/ nginx

[root@server1 conf]# id nginx
uid=500(nginx) gid=500(nginx) groups=500(nginx)

[root@server1 conf]# nginx -t
[root@server1 conf]# nginx

[root@server1 conf]# nginx -s reload

打开服务器的httpd服务:
[root@server2 ~]# cat /var/www/html/index.html
www.westos.org -server2

[root@server3 ~]# cat /var/www/html/index.html
www.westos.org


扩展模块

[root@server1 ~]# nginx -s stop
[root@server1 ~]# tar zxf nginx-1.10.1.tar.gz 
[root@server1 ~]# tar zxf nginx-sticky-module-ng.tar.gz
[root@server1 ~]# cd nginx-1.10.1
[root@server1 nginx-1.10.1]# ./configure --prefix=/opt/nginx --with-http_ssl_module --with-http_stub_status_module --with-threads --with-file-aio --add-module=/root/nginx-sticky-module-ng
[root@server1 nginx-1.10.1]# make
[root@server1 nginx-1.10.1]# make install
[root@server1 conf]# cd /opt/nginx/conf
[root@server1 conf]# cp /usr/local/nginx/conf/nginx.conf .
[root@server1 conf]# vim nginx.conf
http {
        upstream ying {
        sticky;  //上面14版本不支持本算法
        server 172.25.35.52:80;
        server 172.25.35.53:80;
        #server 127.0.0.1;
        }
[root@server1 conf]# /opt/nginx/sbin/nginx -t
[root@server1 conf]# /opt/nginx/sbin/nginx
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值