安裝pgsql以及kong

查看系統版本

[root@localhost ~]# cat /etc/issue
CentOS release 6.7 (Final)
Kernel \r on an \m

安裝PostgreSQL數據庫

安裝yum源
[root@localhost ~]# rpm -Uvh http://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-6.7-x86_64/pgdg-centos95-9.5-3.noarch.rpm

安裝psql
[root@localhost ~]# yum install postgresql95 postgresql95-server postgresql95-contrib

初始化PostgreSQL數據庫
[root@localhost ~]# service postgresql-9.5 initdb

設置開機自啓動

[root@localhost ~]# service postgresql-9.5 start
[root@localhost ~]# chkconfig postgresql-9.5 on

修改監聽地址、端口

[root@localhost ~]# vim /var/lib/pgsql/9.5/data/postgresql.conf   //把註釋符號去掉,顯示如下:
...
listenaddress=''localhost"
port=5432
...

重啓psql
service postgresql-9.5 restart

創建postgresql數據庫中的用戶
在安裝完postgresql數據庫之後,會有一個默認的用戶postgres,切換到postgres用戶,然後執行psql命令,連接postgresql,然後再創建pgdbuser用戶,創建數據庫,最後退出

[root@wc1 ~]# su - postgres
-bash-4.1$ psql
psql (9.4.11)
Type "help" for help.
postgres=# create user pgdbuser  with superuser login password '666666';
CREATE ROLE
postgres=# create database kong;
CREATE DATABASE
postgres=# \q

修改/var/lib/pgsql/9.5/data/pg_hba.conf文件如下:
其中ident是linux系統下postgresql默認的local認證方式,通過操作系統用戶映射的數據庫用戶,不需要輸入密碼,就可以登錄。
而md5,不需要在操作系統層建立對應的同名的用戶。

[root@localhost ~]# vim /var/lib/pgsql/9.5/data/pg_hba.conf
...
# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
...

修改完重啓
service postgresql-9.5 restart

通過pgdbuser用戶登錄數據庫kong

[root@localhost ~]# psql -U pgdbuser -d kong           //-d指定登錄的數據庫
用戶 pgdbuser 的口令:                   //這裏的口令是上面創建的pgdbuser用戶的密碼666666
psql (9.5.16)
輸入 "help" 來獲取幫助信息.

kong=# 

安裝kong

下載kong
下載地址:https://bintray.com/kong/kong-rpm/download_file?file_path=centos/6/kong-0.14.1.el6.noarch.rpm

下載下來後安裝
[root@localhost ~]# sudo yum install kong-0.14.1.*.noarch.rpm --nogpgcheck

修改數據庫密碼

[root@localhost ~]# vim /usr/local/share/lua/5.1/kong/templates/kong_defaults.lua
...
pg_database = kong         //數據庫名
pg_user = pgdbuser         //修改成自己的用戶名
pg_password = 666666   //修改成自己的密碼
...

生成數據庫模板文件
[root@localhost ~]# kong migrations up

啓動kong
[root@localhost ~]# kong start

查看啓動情況

[root@localhost ~]# netstat  -ntpl | grep 8001
tcp        0      0 0.0.0.0:8001                0.0.0.0:*                   LISTEN      15820/nginx

瀏覽器訪問
通過8001端口管理kong後臺信息,zabbix監控中用到
http://192.168.5.103:8001/status
想要用別的機器訪問8001端口,在kong和nginx配置文件中將127.0.0.1:8001修改爲0.0.0.0:8001
安裝pgsql以及kong

kong從0.11版本之後就取消了cluster管理的功能,只要是連接到同一個數據庫上的節點默認爲一個集羣,配置文件中也沒有了cluster參數;0.11版本之後status管理只反映數據庫連接狀態的布爾值,不反映數據庫本身的運行狀況。

安裝kong-dashboard

下載安裝npm,綠色安裝
[root@localhost ~]# npm install -g [email protected]

修改環境變量

[root@localhost ~]# vim /etc/profile
export PATH=/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/Disk/node/bin

kong安裝對應版本
我們安裝的kong是0.14.1,所以kong-dashboard選擇安裝了最新版本3.6.x

Kong-Dashboard versions Kong versions Node versions
1.x.x >= 0.6, < 0.10
2.x.x 0.10
3.0.x >= 0.9, <0.12 >= 6.0.0
3.1.x, 3.2.x >= 0.9, <0.13 >= 6.0.0
3.3.x, 3.4.x >= 0.9, <0.14 >= 6.0.0
3.5.x >= 0.9, <0.15 >= 6.0.0
3.6.x >= 0.9, <2.0.0 >= 6.0.0

後臺啓動
[root@localhost ~]# nohup kong-dashboard start --kong-url http://127.0.0.1:8001 --basic-auth kong=666666 &gt; /Disk/node/bin/kong-dashboard.log &

瀏覽器訪問
http://192.168.5.103:8080/#!/
安裝pgsql以及kong

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章