kong

Kong运维手册

2020-02-19  本文已影响0人  印随2018

适用CentOS/RedHat类操作系统

一、版本信息

注意: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

三、检查是否安装成功

  1. 查看Kong版本信息
kong version
  1. 使用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

四、运行目录

五、监听端口

六、查看连接数统计

# 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
}

七、查看内存统计

# 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

九、监控指标

上一篇 下一篇

猜你喜欢

热点阅读