centos7安装kong和kong-dashboard

1、安装Kong

yum install -y https://kong.bintray.com/kong-community-edition-rpm/centos/7/kong-community-edition-0.13.1.el7.noarch.rpm

2.安装好后可以使用命令whereis kong查看安装路径。

3.去/etc/kong/目录下,此时只有一个文件 kong.conf.default ,复制这个文件到当前目录下,并重命名为 kong.conf(我就是把他复制到外层目录,重命名后在拷贝回来),修改kong.conf的配置文件为下边:

$ cp /etc/kong/kong.conf.default /etc/
$ mv /etc/kong.conf.default /etc/kong.conf
$ cp /etc/kong.conf /etc/kong/
$ rm -rf /etc/kong.conf
$ vi /etc/kong/kong.conf

 

 

 4.初始化数据库表

$ kong migrations up -c  /etc/kong/kong.conf

5.启动kong服务

$ kong start
Kong started

6.验证Kong是否成功启动

$ curl 127.0.0.1:8001

7.安装配置 PostgreSQL

由于测试服安装好了 PostgreSQL及其相关配置,这里就跳过这个步骤

8.安装nodejs      (由于后面安装konga对nodejs版本有要求,所以最好安装8版本以上,免得到时候还要重装)

wget https://nodejs.org/dist/v10.13.0/node-v10.13.0-linux-x64.tar.xz
xz -d node-v10.13.0-linux-x64.tar.xz
tar -xf node-v10.13.0-linux-x64.tar

9.配置node和npm。注意node所在目录,我的node目录是~/node-v10.13.0-linux-x64

ln -s ~/node-v10.13.0-linux-x64/bin/node /usr/bin/node
ln -s ~/node-v10.13.0-linux-x64/bin/npm /usr/bin/npm

10.查看版本

 

 11.安装kong-dashboard

这里刚开始我是拉取的容器并在8080端口运行容器,但总报错

 

 我以为是我的其他容器占用端口导致,所以停掉了该容器,仍然报错,也看了其他解决方法比如

 

 但我的kong明显不是容器,跟这个问题不符合,抱着试一试的态度,果然没解决。。。。

所以采用其他方式安装:

12.配置npm

npm set prefix /usr/local
echo -e '\nexport PATH=/usr/local/lib/node_modules:$PATH' >> ~/.bashrc
source ~/.bashrc

13.安装Kong Dashboard

npm install -g kong-dashboard
kong-dashboard start --kong-url http://localhost:8001
如果8001被占用,可以用别的端口启用,比如:
kong-dashboard start --kong-url http://localhost:8001 --port 8088

14.至此,访问我的服务器http://172.xx.x.xxx:8088/#!/出现界面!

 

15. 任何人都可以访问kong-dashboard,来控制kong api网关,为了增加安全性,建议设置身份认证,如下:

docker run --rm -p 8080:8080 pgbi/kong-dashboard start --kong-url http://172.17.0.1:8001 --basic-auth admin=itsvse

这样,我们打开kong-dashboard就需要输入用户名和密码了,用户名为admin,密码为itsvse。

kong还有一个比较知名的API管理的GUI -KONGA,GitHub地址:https://github.com/pantsel/konga 以后有空再研究。

 

 

 

 

 

posted on 2019-11-28 15:01  不要挡着我晒太阳  阅读(2515)  评论(0编辑  收藏  举报

导航