1.装置kong

## centos7 参考 https://docs.konghq.com/install/centos/## 下载包,如果环境没联网,能够通过本地下载好上传至服务器wget https://bintray.com/kong/kong-rpm/download_file?file_path=centos/7/kong-2.3.0.el7.amd64.rpmsudo yum install /path/to/kong-2.3.0.el7.amd64.rpm --nogpgcheck## ubuntu 参考 https://docs.konghq.com/install/ubuntu/## 下载包,如果环境没联网,能够通过本地下载好上传至服务器wget https://bintray.com/kong/kong-deb/download_file?file_path=kong-2.3.0.bionic.amd64.debsudo apt-get updatesudo apt-get install /absolute/path/to/kong-2.3.0.bionic.amd64.deb

2.装置插件 canary

2.1. 在线装置

## 在线装置 lua-resty-iputilsluarocks install lua-resty-iputils## 在线装置 canaryluarocks install canary

2.2. 离线装置

在有网的中央下载好源码文件

## 提前下载并重命名为 lua-resty-iputils-0.3.0.zipwget https://github.com/hamishforbes/lua-resty-iputils/archive/v0.3.0.zip## 拜访 https://github.com/raoxiaoyan/kong-plugins-canary 下载源码 kong-plugins-canary-master.zip## 下载最新的 canary-1.0.4-1.rockspec,因为源码我的项目没有wget https://luarocks.org/manifests/raoxiaoyan/canary-1.0.4-1.rockspec

将 lua-resty-iputils-0.3.0.zip , kong-plugins-canary-master.zip , canary-1.0.4-1.rockspec 上传至指定服务器

## 解压 lua-resty-iputils-0.3.0.zipunzip lua-resty-iputils-0.3.0.zipcd lua-resty-iputils-0.3.0## 装置luarocks make lua-resty-iputils-0.3.0-1.rockspec## 解压kong-plugins-canary-master.zipunzip kong-plugins-canary-master.zipcd kong-plugins-canary-master## 将之前下载的 canary-1.0.4-1.rockspec 放到当前目录下cp canary-1.0.4-1.rockspec .## 装置luarocks make canary-1.0.4-1.rockspec

3.配置kong

kong启动是会读取/etc/kong/kong.conf文件,配置文件内容具体如下:
装置cassandra集群

log_level = noticeplugins = bundled,canaryproxy_listen = 0.0.0.0:8000#  依据理论状况批改admin_listen = 127.0.0.2:8001database = cassandracassandra_contact_points = 127.0.0.1,127.0.0.2#依据理论状况批改cassandra_port = 9042db_update_propagation = 5cassandra_repl_strategy = SimpleStrategycassandra_repl_factor = 2#异步从Cassandra更新配置worker_consistency = eventual#nginx最大body size 20mnginx_http_client_max_body_size = 20m

配置好/etc/kong/kong.conf文件,需执行以下命令:

## 初始化数据库sudo kong migrations bootstrap## 启动kongsudo kong start## 如果启动胜利,可胜利调用admin的api申请curl -i http://localhost:8001/

4.启动kong

sudo cp /etc/kong/kong.conf.default /etc/kong/kong.conf## 批改数据库为 cassandrasudo vi kong.confdatabase = cassandra## 初始化数据库sudo kong migrations bootstrap## 启动kongsudo kong start## 如果启动胜利,可胜利调用admin的api申请curl -i http://127.0.0.2:8001/

5.装置治理平台konga

5.1. 在线装置

kong提供了丰盛的admin api 接口,为了不便的调用这些接口,装置konga来治理。

git clone https://github.com/pantsel/konga.gitcd konga## 装置依赖包npm i## 后盾启动nohup npm start &

拜访 http://localhost:1337

5.2. 离线装置

离线装置的形式是在与指标服务器雷同操作系统的服务器上,执行在线装置,而后将konga整个文件夹打包成konga-master-package.zip,传到指标服务器。