Tengine 的安装与使用
来源:互联网 发布:广州茶楼你知多少钱 编辑:程序博客网 时间:2024/06/03 17:05
0. 环境和参考文档
centos-6.5
Tengine 官网
1. 安装依赖
yum -y groupinstall "Development tools"yum -y groupinstall "Server Platform Development"yum -y install pcre-devel## 编译时候提示安装的依赖yum install -y libxslt-develyum install -y gd-develyum install -y lua-devel## GeoIP 用户访问来源cd /usr/local/srcwget http://pkgs.repoforge.org/geoip/geoip-devel-1.4.6-1.el6.rf.x86_64.rpmwget http://pkgs.repoforge.org/geoip/geoip-1.4.6-1.el6.rf.x86_64.rpmrpm -ivh geoip-devel-1.4.6-1.el6.rf.x86_64.rpmrpm -ivh geoip-1.4.6-1.el6.rf.x86_64.rpm
添加Tengine的运行时用户
useradd -r tengine
编译安装
./configure \--prefix=/usr/local/tengine \--sbin-path=/usr/local/tengine/sbin/tengine \--conf-path=/usr/local/tengine/conf/tengine.conf \--error-log-path=/usr/local/tengine/logs/error.log \--http-log-path=/usr/local/tengine/logs/access.log \--pid-path=/var/run/tengine/tengine.pid \--lock-path=/var/lock/tengine.lock \--user=tengine \--group=tengine \--with-http_ssl_module \--enable-mods-shared=all \--dso-path=/usr/local/tengine/dso \--without_ngx_http_lua_module
将启动脚本引入环境变量
vim /etc/profile.d/tengine.shexport PATH=/usr/local/tengine/sbin:$PATHreboot
配置
vim /usr/local/tengine/conf/tengine.conf## 设置开启的worker数量为auto (global context) `cat /proc/cpuinfo`worker_processes auto;## 绑定cpu亲缘 (global context)worker_cpu_afinity auto;## 定义每个worker进程可以打开的文件句柄参数 (global context)worker_rlimit_nofile 51200## 设置每个worker的最大连接数 (events context)worker_connections 51200
启动 | 停止tengine
tengine -c /usr/local/tengine/conf/tengine.conftengine -s stop
做个压力测试
碰到 apr_socket_recv: Connection reset bu peer (104) 错误的解决
ulimit -n 51200
开始测试
/usr/local/apache-2.2.27/bin/ab -c 2000 -n 20000 http://192.168.1.101/index.html
在被测机器使用top
htop
vmstat
查看cpu负载和wa
值
vmstat 1 看cpu wa 数值
开启Tengine的健康监测
需要动态的加载
sysguard
模块
这样当cpu负载到达1.1
之后, Tengine停止服务,并将请求转发至loadlimit
action
## server http contextdso { ngx_http_sysguard_module.so;}http { sysguard on; sysguard_load load=1.1 action=/loadlimit; server { location /loadlimit { return 503; } }}
集群中upstream 的健康状态监测配置
http { upstream cluster1 { # simple round-robin consistent_hash $request_uri; server 192.168.0.1:80 id=1001; server 192.168.0.2:80 id=1002; check interval=3000 rise=2 fall=5 timeout=1000 type=http; check_http_send "HEAD / HTTP/1.0\r\n\r\n"; check_http_expect_alive http_2xx http_3xx; } server { listen 80; location /1 { proxy_pass http://cluster1; } location /status { check_status; access_log off; } }}
查看集群状态信息
http://127.0.0.1/status
0 0
- Tengine 的安装与使用
- Tengine-2.1.0的安装与配置
- Tengine的安装和使用(1)
- Tengine的安装
- tengine的安装
- Tengine 详细安装与配置
- 安装Tengine
- tengine安装
- 安装 tengine
- tengine安装
- tengine安装
- tengine安装
- tengine安装
- tengine安装
- tengine安装
- Tengine(一) 之 安装Tengine
- Tengine安装以及碰到的问题解决办法
- Nginx安装-Tengine(阿里baba的)
- CAGradientLayer简介
- OpenGL ES——简述
- 开发环境配置-maven的安装、配置与使用-6
- 参数列表中的self:显式不等于冗余
- git diff
- Tengine 的安装与使用
- 对接近有序的数组排序
- 第五周项目1 三角形类雏形
- 异常:org.apache.ibatis.reflection.ReflectionException
- 如何遍历newtonsoft.json的JObject里的JSON数据
- 基于git的源代码管理模型——git flow
- CSS艺术之---负margin之美
- 【学习】http的8种请求方式
- Python/PHP数字螺旋矩阵