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 以后有空再研究。