tengine(nginx淘宝升级版本)
下载并编译 tengine(nginx)
chmod +x tengine-2.2.3.tar.gz
tar -zxvf tengine-2.2.3.tar.gz
cd tengine-2.2.3/
yum install cmake gcc gcc-c++ openssl openssl-devel -y
./configure && make && sudo make install
配置tengine(nginx)
#配置
cd /root/nginx/tengine-2.2.3/conf/
......
nginx开机启动
#nginx开机启动
vim /lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
systemctl start nginx.service
systemctl enable nginx.service
keepalived
yum install keepalived -y
#配置
vim /etc/keepalived/keepalived.conf
注意
interface 网卡
script 检测执行脚本
virtual_ipaddress 虚拟IP
主服务器
! Configuration File for keepalived
global_defs {
notification_email {
saltstack@example.com
}
notification_email_from keepalived@example.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id node1
}
vrrp_script chk_http_port
{
script "/root/keepalived/chk_nginx.sh"
interval 2
}
vrrp_instance haproxy_ha {
state MASTER
interface eth0
virtual_router_id 36
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.11.48.77
}
track_script {
chk_http_port
}
}
备服务器
! Configuration File for keepalived
global_defs {
notification_email {
saltstack@example.com
}
notification_email_from keepalived@example.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id node2
}
vrrp_script chk_http_port
{
script "/root/keepalived/chk_nginx.sh"
interval 2
}
vrrp_instance haproxy_ha {
state BACKUP
interface eth0
virtual_router_id 36
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.11.48.77
}
track_script {
chk_http_port
}
}
设置启动
#启动
systemctl start keepalived.service
#开机启动
systemctl enable keepalived.service
#打开文件数目限制
ulimit -n 65535