Tengine + ABTestingGateway做灰度发布方案

汤英豪
2023-12-01

依赖软件版本

  1. tengine-2.3.2
  2. lua-5.1.5-coco (openresty-1.13.6.2中集成的版本,在lua-5.1.5的基础上打了补丁 LuaCoco-1.1.9)
  3. LuaCoco-1.1.9
  4. redis-5.0.8
  5. lua-cjson-2.1.0.6 (openresty-1.13.6.2中集成的版本,bundle下面)
  6. LuaJIT-2.1-20180420 (openresty-1.13.6.2中集成的版本,bundle下面)
  7. lua-rds-parser-0.06 (openresty-1.13.6.2中集成的版本,bundle下面)
  8. lua-redis-parser-0.13 (openresty-1.13.6.2中集成的版本,bundle下面)

安装步骤

依赖库安装

yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel gcc g++ gcc-c++ gd-devel libuuid-devel && yum install readline-devel && yum -y install patch && yum -y install libxslt-devel && yum -y install perl-devel perl-ExtUtils-Embed && sudo yum install -y GeoIP-devel.x86_64

lua-5.1.5 安装

  1. cd …/openresty-1.13.6.2/bundle/lua-5.1.5
  2. make linux
  3. make install

lua-5.1.5安装补丁

  1. tar -zxvf LuaCoco-1.1.9
  2. mv lua-5.1.5 lua-5.1.5-coco
  3. cd lua-5.1.5-coco
  4. patch -p1 …/LuaCoco-1.1.9/lua-5.1.5-coco-1.1.9.patch
  5. make linux
  6. make install
  7. ./src/lua …/LuaCoco-1.1.9/test/cotest.lua(看到成功表示补丁包安装成功)

LuaJIT-2.1-20180420安装

  1. cd openresty-1.13.6.2/bundle/LuaJIT-2.1-20180420
  2. make PREFIX=/usr/local/luajit install
  3. export LUAJIT_LIB=/usr/local/luajit/lib 环境变量设置
  4. export LUAJIT_INC=/usr/local/luajit/include/luajit-2.1 环境变量设置
  5. 这里还可以设置一下动态库,不设置也不会报错,不过切换到别的账号启动你的tengine会找不到动态库,还是手动设置一下,cd /etc/ld.so.conf.d && touch luajitlib.conf && vim luajitlib.conf 写上/usr/local/luajit install后esc退出:wq保存即可

lua-cjson-2.1.0.6安装

  1. openresty-1.13.6.2/bundle/lua-cjson-2.1.0.6
  2. make && make instlal
  3. cp cjson.so /usr/lib64/lua/5.1/cjson.so 复制库文件

lua-rds-parser-0.06安装

  1. make && make install

lua-redis-parser-0.13

  1. make && make install

ABTestingGateway安装

  1. git clone https://github.com/SinaMSRE/ABTestingGateway

redis-5.0.8 安装

  1. tar -zxvf redis-5.0.8.tar.gz
  2. cd redis-5.0.8
  3. make install
  4. cp /usr/ABTestingGateway/utils/conf/redis.conf /usr/redis-5.0.8/redis.conf 将ABTestingGateway里面的redis.conf复制到redis里面,因为有一些配置需要配置,我这里不想配置了,就直接复制过去,具体配置有什么用看下ABTestingGateway的doc下面的文件就明白了
  5. 修改redis.config里面的daemonize yes
  6. Q.redis启动 ./src/redis-server …/redis.conf
  7. R.修改/usr/ABTestingGateway/utils/conf/vhost.conf里面的redis链接,如果是同一台服务器,可以不改

tengine-2.3.2 安装

  1. tar -zxvf tengine-2.3.3.tar.gz
  2. cd tengine-2.3.3
  3. ./configure --user=www --group=www
    –prefix=/data/tengine/nginx
    –with-http_stub_status_module
    –with-http_ssl_module
    –with-http_v2_module
    –with-http_realip_module
    –with-http_gzip_static_module
    –with-mail
    –with-mail_ssl_module
    –add-module=./modules/ngx_http_upstream_check_module
    –add-module=./modules/ngx_http_upstream_session_sticky_module
    –add-module=./modules/ngx_http_user_agent_module
    –add-module=./modules/ngx_http_footer_filter_module
    –add-module=./modules/ngx_http_proxy_connect_module
    –add-module=./modules/ngx_http_trim_filter_module
    –add-module=./modules/ngx_http_upstream_consistent_hash_module
    –add-module=./modules/ngx_http_upstream_dynamic_module
    –add-module=./modules/ngx_http_reqstat_module
    –add-module=./modules/ngx_http_headers_more_filter_module
    –add-module=./modules/incubator-pagespeed-ngx-1.13.35.2-stable
    –add-module=./modules/ngx_http_upstream_dyups_module
    –add-module=./modules/ngx_multi_upstream_module
    –add-module=./modules/ngx_http_concat_module
    –add-module=…/openresty-1.13.6.2/bundle/ngx_lua-0.10.13
    –add-module=…/openresty-1.13.6.2/bundle/ngx_devel_kit-0.3.0
    –add-module=…/openresty-1.13.6.2/bundle/rds-csv-nginx-module-0.09
    –add-module=…/openresty-1.13.6.2/bundle/rds-json-nginx-module-0.15
    –add-module=…/openresty-1.13.6.2/bundle/redis2-nginx-module-0.15
    –add-module=…/openresty-1.13.6.2/bundle/redis-nginx-module-0.3.7
    –add-module=…/openresty-1.13.6.2/bundle/encrypted-session-nginx-module-0.08
    –add-module=…/openresty-1.13.6.2/bundle/form-input-nginx-module-0.12
    –add-module=…/openresty-1.13.6.2/bundle/iconv-nginx-module-0.14
    –add-module=…/openresty-1.13.6.2/bundle/ngx_lua_upstream-0.07
    –add-module=…/openresty-1.13.6.2/bundle/srcache-nginx-module-0
  4. make
  5. make install

应用测试

安装完成后,进入ABTestingGateway文件夹,可以看到abtesting.sh和shutdownabtesting.sh两个文件,修改里面的ngnix指向刚刚tengine安装的ngnix文件中的路径,启动即可
后面关于怎么配置策略,参看doc下面的文档,描述很详细

 类似资料: