Tengine安装配置
为了加快网站的大流量访问速度,公司要求把Nginx更换为Tengine,下面记录下整个安装配置过程:
#安装必要依赖
yum install -y pcre pcre-devel zlib zlib-devel openssl openssl-devel glibc-headers gcc-c++
#安装google-perftools支持依赖
wget http://download.savannah.gnu.org/releases/libunwind/libunwind-0.98.tar.gz
tar xf libunwind-0.98.tar.gz
cd libunwind-0.98
./configure && make && make install
#安装google-perftools
wget https://github.com/gperftools/gperftools/releases/download/gperftools-2.4/gperftools-2.4.tar.gz
tar xf gperftools-2.4.tar.gz
cd gperftools-2.4
./configure --enable-frame-pointers
make && make install
#为google-perftools添加线程目录
mkdir /tmp/tcmalloc
chmod 0777 /tmp/tcmalloc
#下载Tengine最新稳定版本
wget http://tengine.taobao.org/download/tengine-2.1.2.tar.gz
#解压
tar xf tengine-2.1.2.tar.gz
cd tengine-2.1.2
#修改nginx.h,以隐藏版本信息
sed -i "12 s/1006002/1000001/g" src/core/nginx.h
sed -i "13 s/1.6.2/1.0.0/g" src/core/nginx.h
sed -i "14 s/nginx/webserver/g" src/core/nginx.h
sed -i "16 s/\"Tengine\"/\"X\"/g" src/core/nginx.h
sed -i "17 s/2001002/2000000/g" src/core/nginx.h
sed -i "18 s/2.1.2/2.0.0/g" src/core/nginx.h
sed -i "21 s/\"NGINX\"/\"X\"/g" src/core/nginx.h
sed -i "s/\/usr\/local/\/usr\/local\/gacp\/gperftools/g" auto/lib/google-perftools/conf
#添加运行用户
useradd -s /sbin/nologin apache
#创建相应目录
mkdir -p /usr/local/gacp/nginx
mkdir -p /data/logs/nginx/{access,error}
#编译安装
./configure \
--user=apache \
--group=users \
--prefix=/usr/local/gacp/nginx \
--error-log-path=/data/logs/nginx/error/error.log \
--http-log-path=/data/logs/nginx/access/access.log \
--pid-path=/usr/local/gacp/nginx/conf/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-pcre \
--with-http_realip_module \
--with-http_gzip_static_module \
--with-google_perftools_module \
--with-file-aio
make
make install
#配置文件nginx.conf
user apache;
worker_processes 12;
worker_rlimit_nofile 65535;
pid conf/nginx.pid;
google_perftools_profiles /tmp/tcmalloc;
error_log /data/logs/nginx/error/error.log crit;
events {
use epoll;
worker_connections 20960;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'$upstream_addr $upstream_response_time $upstream_status';
access_log off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
keepalive_timeout 60;
include gzip.types;
include server.types;
include upstream.conf;
include vhosts.d/*.conf;
}
#配置文件gzip.types
zip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 5;
gzip_types text/plain application/x-javascript text/css text/xml image/jpeg image/gif image/png;
gzip_vary on;
#配置文件server.types
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
server_names_hash_bucket_size 128;
client_max_body_size 8m;
open_file_cache max=10240 inactive=60s;
open_file_cache_valid 30s;
open_file_cache_min_uses 1;
proxy_headers_hash_max_size 512;
proxy_headers_hash_bucket_size 64;
#配置文件flb_params
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_next_upstream error timeout invalid_header http_502 http_504;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
proxy_buffer_size 64k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
#配置文件upstream.conf
#负载均衡
#1、轮询(默认)
#每个请求按时间顺序逐一分配到不同的后端服务器,如果后端服务器down掉,能自动剔除。
#2、weight
#指定轮询几率,weight和访问比率成正比,用于后端服务器性能不均的情况。
#例如:
#upstream bakend {
#server 192.168.0.1 weight=10;
#server 192.168.0.2 weight=10;
#}
#3、ip_hash
#每个请求按访问ip的hash结果分配,这样每个访客固定访问一个后端服务器。
#例如:
#upstream bakend {
#ip_hash;
#server 192.168.0.1:88;
#server 192.168.0.2:80;
#}
#每个设备的状态设置为:
#1.down 表示单前的server暂时不参与负载
#2.weight 默认为1.weight越大,负载的权重就越大。
#3.max_fails :允许请求失败的次数默认为1.当超过最大次数时,返回proxy_next_upstream 模块定义的错误
#4.fail_timeout:max_fails次失败后,暂停的时间。
#5.backup: 其它所有的非backup机器down或者忙的时候,请求backup机器。所以这台机器压力会最轻。
#6.check interval=3000 rise=2 fall=2 timeout=1000 type=http;用于自动判断后端是否可用。
#####
upstream web_server
{
check interval=3000 rise=2 fall=2 timeout=1000 type=http;
server 1.1.1.1 max_fails=2 fail_timeout=30s;
server 2.2.2.2 max_fails=2 fail_timeout=30s;
ip_hash;
}
#配置文件proxy.vipbet.com.conf
server {
listen 58080;
server_name proxy.vipbet.com;
access_log /data/logs/nginx/access/proxy.vipbet.com.access.log main;
error_log /data/logs/nginx/error/proxy.vipbet.com.error.log;
location /
{
proxy_pass http://web_server;
include flb_params;
}
}
#更改目录用户组
chown -R apache.apache /usr/local/gacp/nginx
#启动脚本:cat /etc/init.d/nginx
#!/bin/bash
#
# nginx - this script starts and stops the nginx daemon #
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
TENGINE_HOME="/usr/local/gacp/nginx/"
#这里修改nginx的路径 nginx=$TENGINE_HOME"sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE=$TENGINE_HOME"conf/nginx.conf"
[ -f /etc/sysconfig/nginx ] && /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
killall -9 nginx
}
restart() {
test || return $?
stop
sleep 1
start
}
reload() {
test || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
test() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|test)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|test}"
exit 2
esac
#chmod +x /etc/init.d/nginx
#service nginx start
#报错/lib/lsb/init-functions: No such file or directory
yum install redhat-lsb
#报错error while loading shared libraries: libprofiler.so.0: cannot open shared object file: No such file or directory
查看libprofiler.so.0是否存在:whereis libprofiler.so.0
libprofiler.so: /usr/local/lib/libprofiler.so /usr/local/lib/libprofiler.so.0
添加动态库路径: vi /etc/ld.so.conf.d/extend.conf
/usr/local/lib
装载动态库:ldconfig
#service nginx start
#####查看nginx进程
ps aux|grep nginx
#####查看google_perftools_profiles
lsof -n | grep tcmalloc
Tengine安装配置的更多相关文章
- Tengine 安装配置全过程
Tengine官网上有个非常简单的教程,中间并未涉及到一些常用的设置,所以仅供参考.一下午为本人的安装步骤及过程. 1.安装必要的编译环境好 由于Tengine安装需要使用源代码自行编译,所以在安装前 ...
- Tengine 安装配置全过程(nginx 同理)
1.安装必要的编译环境好 yum update yum install gcc gcc-c++ autoconf automake 2.安装需要的组件 A.PCRE PCRE(Perl Compati ...
- Tengine 2.1.2 (nginx/1.6.2)安装配置,淘宝 Web 服务器
简介 Tengine是由淘宝网发起的Web服务器项目.它在Nginx的基础上,针对大访问量网站的需求,添加了很多高级功能和特性.Tengine的性能和稳定性已经在大型的网站如淘宝网,天猫商城等得到了很 ...
- 分布式文件系统 FastDFS 5.0.5 & Linux CentOS 7 安装配置(单点安装)——第一篇
分布式文件系统 FastDFS 5.0.5 & Linux CentOS 7 安装配置(单点安装)--第一篇 简介 首先简单了解一下基础概念,FastDFS是一个开源的轻量级分布式文件系统,由 ...
- Nginx 安装 配置 使用
Nginx 安装 配置 使用 基本的HTTP服务器特性 处理静态文件,索引文件以及自动索引:打开文件描述符缓存(缓存元数据和文件描述符,下一次可以直接从内存找到数据或者文件的位置): 使用缓存加速反向 ...
- Tengine安装(阿里baba的)-Nginx
在先前的文章中介绍过Tengine,先前只是使用了运维人员配置好的内容,未自己进行过安装配置.周末闲来无事,对于Tengine进行了尝试性的安装.记录下面方便以后再做改进. Tengine官网上有个非 ...
- linux下tengine安装
1.什么是tengine? 说到tengine,首先还是得说下nginx了,大家对于nginx并不陌生,对于基本的需求都能满足,如果是涉及高级性能,那么就必须使用商用版nginx plus了,一谈到商 ...
- 记录:CentOS 7 安装配置分布式文件系统 FastDFS 5.1.1
CentOS 7 安装配置分布式文件系统 FastDFS 5.1.1 软件下载:http://download.csdn.net/download/qingchunwuxian1993/9897458 ...
- CentOS 7 安装配置分布式文件系统 FastDFS 5.0.5
前言 项目中用到文件服务器,有朋友推荐用FastDFS,所以就了解学习了一番,感觉确实颇为强大,在此再次感谢淘宝资深架构师余庆大神开源了如此优秀的轻量级分布式文件系统,本篇文章就记录一下FastDFS ...
随机推荐
- require 和 file_get_contents
requirerequire_onceincludeinclude_oncecurlfile_get_contents---各种选择的比较 还有这么复杂的说法,怎么办? 在开发过程中发现,用requi ...
- jquery height
heigth -- 内容高度innerHeight -- 包含padding但不包含borderouterHeight -- 包含borderouterHeight(true) -- 包含margin ...
- java 多线程3(线程安全)
需求:模拟三个窗口同时买票. 问题1:static 修饰num,只创建一份在内存中,要不就会创建3份. 问题2:线程安全问题.(代码重1的红色字体) 出现的原因:存在两个或两个以上的线程对象,而且线程 ...
- mysql 免安装版本 命令安装
1.down load mysql-5.5.28-win32.zip 2.unzip it to a path such as d:/mysq/mysql-5.5.28-win32 3.copy th ...
- 关于智能指针boost::shared_ptr
boost库中的智能指针shared_ptr, 功能强大, 且开销小,故受到广大coder的欢迎. 但在实际的使用过程中,笔者也发现了一些不足. 1.定制的删除器 shared_ptr除了可以使用默认 ...
- BeautifulSoup 常用方法
#输出所得标签的‘’属性值 获取 head里面的第一个meta的content值 soup.head.meta['content'] 获取第一个span的内容 soup.span.string 获取第 ...
- Qt之Timers
简述 QObject是所有Qt objects的基类,在Qt中提供了基础定时器的支持.使用QObject::startTimer(),你可以传递一个毫秒数间隔作为参数启动一个定时器.该函数返回一个唯一 ...
- Qt之QSS(白色靓丽)
简述 Qt助手中有关于各种部件的QSS详细讲解,资源很丰富,请参考:Qt Style Sheets Examples. 白色靓丽 - 一款漂亮的QSS风格. 你可以直接使用,也可以随意转载,但请务必保 ...
- 【转载】SAP的标准对话框函数
http://blog.sina.com.cn/s/blog_721b218c01012j0y.html 在用户设计sap的程序时,经常需要一些对话框,用户可以自己编写,但使用SAP系统中提供了的对话 ...
- SQL Server数据库(SQL Sever语言 事务)
事务:保障流程的完整执行保证程序某些程序在运行时同时成功同时失败,保证程序的安全性 begin tran --在流程开始的位置加 --此处写SQL语句 if @@error>0 --ERRORS ...