API gateway 之 kong 安裝


kong安裝:

https://getkong.org/install/centos/

下載指定版本rpm:

wget https://bintray.com/kong/kong-community-edition-rpm/download_file?file_path=centos/7/kong-community-edition-0.12.3.el7.noarch.rpm
yum install epel-release
yum install xxx.rpm

 

kong數據庫安裝:

kong支持2種數據庫存儲(postgreSQL 和 Cassandra )

postgreSQL官網:https://www.postgresql.org/download/

Cassandra官網:http://cassandra.apache.org/download/

安裝postgreSQL:

yum install https://download.postgresql.org/pub/repos/yum/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-3.noarch.rpm
yum install postgresql94
yum install postgresql94-server
/usr/pgsql-9.4/bin/postgresql94-setup initdb

修改postgreSQL配置文件:

vim /var/lib/pgsql/9.4/data/postgresql.conf
修改為:listen_addresses = '*'
vim /var/lib/pgsql/9.4/data/pg_hba.conf
修改為:host    all             all             127.0.0.1/32            trust

啟動postgreSQL:

systemctl enable postgresql-9.4
systemctl start postgresql-9.4

創建kong需要的庫、授權  並 把相關的數據寫入庫:

#su - postgres
-bash-4.2$ psql
postgres=# CREATE USER kong; CREATE DATABASE kong OWNER kong;
postgres=# \
 
# kong migrations up

啟動kong:

# cp /etc/kong/kong.conf.default /etc/kong/kong.conf
# kong start
# curl -i -X GET http://localhost:8001/
HTTP/1.1 200 OK
Date: Thu, 10 May 2018 07:43:18 GMT
....

安裝kong-dashboard:

安裝說明:https://github.com/PGBI/kong-dashboard

安裝kong管理工具的環境依賴  nodejs 及 npm

nodejs 及 npm安裝教程:https://nodejs.org/en/download/package-manager/#enterprise-linux-and-fedora

curl --silent --location https://rpm.nodesource.com/setup_9.x | sudo bash -
yum install -y nodejs
npm install -g kong-dashboard
nohup kong-dashboard start --kong-url http://0.0.0.0:8001 &
 
也可以基於basic 認證,在登錄是要求輸入密碼
nohup kong-dashboard start --kong-url http://0.0.0.0:8001 --basic-auth admin=123456 &

訪問 kong-dashboard   http://x,x,x,x:8080 (輸入剛剛配置的賬號密碼)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM