Ansible Role: tengine
安裝tengine
介紹
Tengine是由淘寶網(wǎng)發(fā)起的Web服務(wù)器項(xiàng)目浩淘。它在Nginx的基礎(chǔ)上咳焚,針對大訪問量網(wǎng)站的需求洽损,添加了很多高級功能和特性。Tengine的性能和穩(wěn)定性已經(jīng)在大型的網(wǎng)站如淘寶網(wǎng)革半,天貓商城等得到了很好的檢驗(yàn)碑定。它的最終目標(biāo)是打造一個(gè)高效、穩(wěn)定又官、安全延刘、易用的Web平臺(tái)。
官方網(wǎng)站:http://tengine.taobao.org/
官方文檔地址:http://tengine.taobao.org/documentation.html
要求
此角色僅在RHEL及其衍生產(chǎn)品上運(yùn)行六敬。
測試環(huán)境
ansible主機(jī)
ansible: 2.3.1.0
os: Centos 7.2 X64
python: 2.7.5
ansible管理主機(jī)
os: Centos 6.7 X64, Centos 7.2 X64
角色變量
software_files_path: "/opt/software"
software_install_path: "/usr/local"
tengine_version: "2.2.0"
tengine_file: "tengine-{{ tengine_version }}.tar.gz"
tengine_file_path: "{{ software_files_path }}/{{ tengine_file }}"
tengine_file_url: "http://tengine.taobao.org/download/tengine-{{ tengine_version }}.tar.gz"
tengine_temp_path: "/var/tmp/tengine"
tengine_conf_path: "{{ software_install_path }}/tengine-{{ tengine_version }}/conf/"
tengine_conf_file_path: "{{ software_install_path }}/tengine-{{ tengine_version }}/conf/nginx.conf"
tengine_user: 'tengine'
tengine_group: 'tengine'
tengine_build_options: ''
tengine_configure_command: >
./configure
--prefix={{ software_install_path }}/tengine-{{ tengine_version }}
--user={{ tengine_user }}
--group={{ tengine_group }}
--with-poll_module
--with-file-aio
--with-http_sub_module
--with-http_ssl_module
--with-http_flv_module
--with-http_dav_module
--with-http_mp4_module
--with-http_stub_status_module
--with-http_gunzip_module
--with-http_gzip_static_module
--with-http_realip_module
--with-http_slice_module
--with-http_image_filter_module
--with-http_auth_request_module
--with-http_concat_module
--with-http_random_index_module
--with-http_secure_link_module
--with-http_sysguard_module
--with-http_degradation_module
--with-http_v2_module
--http-client-body-temp-path={{ tengine_temp_path }}/client/
--http-proxy-temp-path={{ tengine_temp_path }}/proxy/
--http-fastcgi-temp-path={{ tengine_temp_path }}/fcgi/
--http-uwsgi-temp-path={{ tengine_temp_path }}/uwsgi
--http-scgi-temp-path={{ tengine_temp_path }}/scgi
--with-pcre
{{ tengine_build_options }}
tengine_pidfile: '/var/run/tengine.pid'
tengine_worker_processes: "{{ ansible_processor_vcpus | default(ansible_processor_count) }}"
tengine_worker_connections: "10240"
tengine_multi_accept: "off"
tengine_pid_file: "/var/run/tengine.pid"
tengine_logpath: "/var/log/tengine"
tengine_error_log: "{{ tengine_logpath }}/error.log"
tengine_access_log: "{{ tengine_logpath }}/access.log"
tengine_mime_file_path: "mime.types"
tengine_sendfile: "on"
tengine_tcp_nopush: "on"
tengine_tcp_nodelay: "off"
tengine_keepalive_timeout: "65"
tengine_keepalive_requests: "1000"
tengine_client_max_body_size: "64m"
tengine_server_names_hash_bucket_size: "64"
tengine_proxy_cache_path: ""
tengine_extra_conf_options: ""
tengine_extra_http_options: ""
tengine_remove_default_vhost: false
tengine_vhosts: []
tengine_upstreams: ''
tengine_proxys: false
tengine_gzip: false
tengine_stub_status: false
tengine_stream: false
依賴
沒有
github地址
https://github.com/kuailemy123/Ansible-roles/tree/master/tengine
Example Playbook
默認(rèn)安裝tengine
- hosts: node1
roles:
- tengine
反向代理
- hosts: node1
vars:
- tengine_vhosts:
- listen: 80
locations:
- name: /
proxy_pass: http://192.168.77.135:8080
proxy_set_headers:
Host: $host
X-Real-IP: $remote_addr
X-Forwarded-For: $proxy_add_x_forwarded_for
roles:
- tengine
反向代理緩存,采用擴(kuò)展選項(xiàng)
- hosts: node1
vars:
- tengine_proxy_cache_path: /data/nginx/cache levels=1:2 keys_zone=STATIC:10m inactive=24h max_size=5g
- tengine_vhosts:
- listen: 80
extra_parameters: |
location / {
proxy_pass http://192.168.77.135:8080;
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_cache STATIC;
proxy_cache_valid 200 1d;
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
}
roles:
- tengine
反向負(fù)載均衡
- hosts: node1
vars:
- tengine_upstreams:
- name: upstremtest
servers:
- 127.0.0.1:8000 weight=3 max_fails=2 fail_timeout=2
- 127.0.0.1:8001
- 127.0.0.1:8002
- 127.0.0.1:8003 backup
- tengine_vhosts:
- listen: 80
locations:
- name: /
proxy_pass: http://upstremtest
roles:
- tengine
使用
/etc/init.d/tengine
Usage: /etc/init.d/tengine {start|stop|reload|configtest|status|force-reload|upgrade|restart|reopen_logs}