| 
                        副标题[/!--empirenews.page--]
                          1、Nginx 
业务背景 
现公司需求快速搭建web服务器,对外提供给用户web服务。 
需求拆分 
需要基于http协议的软件,搭建服务实现 
介绍 
常见用法: 
1) web服务器软件 httpd http协议 
同类的web服务器软件:apache(老牌) nginx(俄罗斯) IIS(微软) 
2)代理服务器 反向代理 
3)邮箱代理服务器 IMAP POP3 SMTP 
4)负载均衡功能 LB loadblance 
Nginx架构的特点: 
    - ①高可靠:稳定性 master进程 管理调度请求分发到哪一个worker=> worker进程 响应请求 一master多worker②热部署  :(1)平滑升级 (2)可以快速重载配置③高并发:可以同时响应更多的请求 事件 epoll模型 几万④响应快:尤其在处理静态文件上,响应速度很快  sendfile⑤低消耗:cpu和内存 1w个请求 内存2-3MB⑥分布式支持 :反向代理 七层负载均衡
 
 
官方网址:http://nginx.org/ 
  
1.2、安装 
常见安装方式: 
①yum安装配置,需使用Nginx官方源或者EPEL源②源码编译 
- #添加运行用户 
 - shell > useradd -s/sbin/nologin -M www 
 - #安装依赖 
 - shell > yum -y install pcre-devel zlib-devel openssl-devel 
 - #编译安装 
 - shell > cd /root/soft 
 - shell > tar xvf nginx-1.14.2.tar.gz 
 - shell > cd nginx-1.14.2 
 - shell > ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module && make && make install 
 
  
编译参数说明 
  
1.3、目录介绍 
查看安装目录/usr/local/nginx 
 
1.4、软件操作参数 
查看nginx的二进制可执行文件的相关参数 
- shell > cd /usr/local/nginx/sbin 
 -  shell > ./nginx -h 
 
  
执行后显示 
- nginx version: nginx/1.14.2 
 -  Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives] 
 -   
 -  Options: 
 -  #查看帮助 
 -  -?,-h : this help 
 -  #查看版本并退出 
 -  -v : show version and exit 
 -  #查看版本和配置选项并退出 
 -  -V : show version and configure options then exit 
 -  #检测配置文件语法并退出 
 -  -t : test configuration and exit 
 -  #检测配置文件语法打印它并退出 
 -  -T : test configuration, dump it and exit 
 -  #在配置测试期间禁止显示非错误信息 
 -  -q : suppress non-error messages during configuration testing 
 -  #发送信号给主进程 stop强制退出 quit优雅的退出 reopen重开日志 reload重载配置 
 -  -s signal : send signal to a master process: stop, quit, reopen, reload 
 -  #设置nginx目录 $prefix路径 
 -  -p prefix : set prefix path (default: /usr/local/nginx/) 
 -  #指定启动使用的配置文件 
 -  -c filename : set configuration file (default: conf/nginx.conf) 
 -  #在配置文件之外设置全局指令 
 -  -g directives : set global directives out of configuration file 
 
  
一般主要使用: 
    - -s参数控制管理nginx服务-V参数查看nginx开启的模块和编译参数-t参数检测配置文件是否有错误
 
 
2、Keepalived实现高可用 
业务背景 
单例web服务器能够满足业务基本需求,提供web服务。但是,存在单点故障的问题,即当服务器宕机后,用户将无法获取到服务响应。 
为了能够提高用户体验度,能够持续得给用户提供优质的服务,当web服务器不可用时,可以有备用服务器接替web服务器的工作,继续为用户提供响应。其中,还要解决一个问题,需要备用服务器能够快速自动切换过来。 
一般将以上业务需求,称为实现服务的高可用HA。 
需求拆分 
也就是高可用的实现核心: 
①冗余服务器(备份服务器) 
                        (编辑:滁州站长网) 
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! 
                     |