適用CentOS/RedHat類操作系統(tǒng)
一、版本信息
- Kong: 2.0.1
注意:Kong的安裝包里自帶OpenResty奸远,不需要單獨安裝Openresty
二、安裝
在線安裝RPM
sudo yum install -y wget
wget https://bintray.com/kong/kong-rpm/rpm -O bintray-kong-kong-rpm.repo
export major_version=`grep -oE '[0-9]+\.[0-9]+' /etc/redhat-release | cut -d "." -f1`
sed -i -e 's/baseurl.*/&\/centos\/'$major_version''/ bintray-kong-kong-rpm.repo
sudo mv bintray-kong-kong-rpm.repo /etc/yum.repos.d/
sudo yum install -y kong
離線安裝RPM
sudo yum install -y wget
wget https://bintray.com/kong/kong-rpm/rpm -O bintray-kong-kong-rpm.repo
export major_version=`grep -oE '[0-9]+\.[0-9]+' /etc/redhat-release | cut -d "." -f1`
sed -i -e 's/baseurl.*/&\/centos\/'$major_version''/ bintray-kong-kong-rpm.repo
sudo mv bintray-kong-kong-rpm.repo /etc/yum.repos.d/
sudo yum install -y yum-utils
sudo yumdownloader kong-2.0.1
sudo yum install -y kong
三讽挟、檢查是否安裝成功
- 查看Kong版本信息
kong version
- 使用DB-less模式啟動Kong
cp /etc/kong/kong.conf.default /etc/kong/kong.conf
sed -i "/^#database/i\database = off" /etc/kong/kong.conf
kong start
curl http://127.0.0.1:8001
四懒叛、運行目錄
- /usr/local/kong Kong的運行目錄
- /usr/local/kong/pids/nginx.pid nginx-master進(jìn)程號
- /usr/local/kong/logs/access.log 數(shù)據(jù)口的訪問日志文件
- /usr/local/kong/logs/admin_access.log 管理口的訪問日志
- /usr/local/kong/logs/error.log 錯誤日志
五、監(jiān)聽端口
-
數(shù)據(jù)口:8000
curl http://127.0.0.1:8000/
-
管理口:8001
curl http://127.0.0.1:8001/
六耽梅、查看連接數(shù)統(tǒng)計
# curl http://127.0.01:8001/status 2>/dev/null | jq .server
{
"connections_writing": 1,
"total_requests": 13,
"connections_handled": 13,
"connections_accepted": 13,
"connections_reading": 0,
"connections_active": 1,
"connections_waiting": 0
}
七薛窥、查看內(nèi)存統(tǒng)計
# curl http://127.0.01:8001/status 2>/dev/null | jq .memory
{
"workers_lua_vms": [
{
"http_allocated_gc": "0.05 MiB",
"pid": 1310
}
],
"lua_shared_dicts": {
"kong_rate_limiting_counters": {
"allocated_slabs": "0.08 MiB",
"capacity": "12.00 MiB"
},
"kong_locks": {
"allocated_slabs": "0.06 MiB",
"capacity": "8.00 MiB"
},
"kong_healthchecks": {
"allocated_slabs": "0.04 MiB",
"capacity": "5.00 MiB"
},
"kong_cluster_events": {
"allocated_slabs": "0.04 MiB",
"capacity": "5.00 MiB"
......
八、日志文件自動切割
cat > /etc/logrotate.d/kong <<EOF
/usr/local/kong/logs/*.log {
daily
missingok
rotate 30
compress
delaycompress
dateext
notifempty
create root root
sharedscripts
postrotate
[ -f /usr/local/kong/pids/nginx.pid ] && kill -USR1 `cat /usr/local/kong/pids/nginx.pid`
endscript
}
EOF
九眼姐、監(jiān)控指標(biāo)
- 連接數(shù)
- 內(nèi)存
- 錯誤日志