机器IP:172.16.123.123
postgresql版本(docker):postgres:9.6
kong版本(rpm):kong-2.0.5.el7.amd64.rpm
konga版本(docker):pantsel/konga:latest
注:pantsel/konga:latest不支持postgres:12及以上版本
docker pull postgres:9.6 #拉取镜像
docker run -d \
-p 5432:5432 \
--name postgres \
-e LANG="C.UTF-8" \
-e 'TZ=Asia/Shanghai' \
-e "POSTGRES_DB=postgres" \
-e "POSTGRES_USER=postgres" \
-e "POSTGRES_PASSWORD=postgres" \
-v /data/software/postgresqldata:/var/lib/postgresql/data \
postgres:9.6 #创建并运行pg容器
docker exec -it -u postgres postgres /bin/bash #进入pg容器
psql #进入pg
postgres=# create user kong with password '123321'; #创建用户
postgres=# create database kong owner kong; #创建数据库
postgres=# grant all privileges on database kong to kong; #授权
postgres=# create user konga with password '123321'; #创建用户
postgres=# create database konga owner konga; #创建数据库
postgres=# grant all privileges on database konga to konga; #授权
host all all 127.0.0.1/32 md5
psql -U konga -d konga -h 172.16.123.123 -p 5432
yum install epel-release
yum install kong-2.1.0.*.noarch.rpm --nogpgcheck
cp /etc/kong/kong.conf.default /etc/kong/kong.conf
vim /etc/kong/kong.conf
根据实际情况修改以下配置:
database = postgres # Determines which of PostgreSQL or Cassandra
# this node will use as its datastore.
# Accepted values are `postgres`,
# `cassandra`, and `off`.
pg_host = 172.16.123.123 # Host of the Postgres server.
pg_port = 5432 # Port of the Postgres server.
pg_timeout = 5000 # Defines the timeout (in ms), for connecting,
# reading and writing.
pg_user = kong # Postgres user.
pg_password = 123321 # Postgres user's password.
pg_database = kong # The database name to connect to.
/usr/local/openresty/nginx/sbin/nginx -p /usr/local/kong -c /usr/local/kong/kong.conf
注:nginx配置文件(nginx.conf、nginx-kong.conf)默认在/usr/local/kong/目录下,可根据实际情况修改nginx-kong.conf
kong migrations up -c /etc/kong/kong.conf
kong start
curl 172.16.123.123:8001
注:本机IP,有返回信息即安装成功
注:konga是kong的可视化管理工具之一,同样依赖数据库
docker pull pantsel/konga
docker run --rm pantsel/konga:latest -c prepare -a postgres -u postgresql://konga:[email protected]:5432/konga #将konga库的“用户:密码”以及“IP:端口”换成自己的
docker run -d -p 1337:1337 \
-e "DB_ADAPTER=postgres" \
-e "DB_HOST=172.16.123.123" \
-e "DB_PORT=5432" \
-e "DB_USER=konga" \
-e "DB_PASSWORD=123321" \
-e "DB_DATABASE=konga" \
-e "DB_PG_SCHEMA=public"\
-e "NODE_ENV=production" \
--name konga \
pantsel/konga
curl 172.16.123.123:1337
有条件可直接在浏览器访问172.16.123.123:1337
有正常返回则说明安装启动成功!