install pgsql
install pgsql yum repo
wget https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-6-x86_64/pgdg-centos95-9.5-3.noarch.rpm
rpm -ivh pgdg-centos95-9.5-3.noarch.rpm
ls /etc/yum.repos.d/pgdg-redhat-all.repo
install pgsql9.5 server
yum install postgresql95 postgresql95-server
/etc/rc.d/init.d/postgresql-9.5 initdb
/etc/rc.d/init.d/postgresql-9.5 start
config pgsql 驗(yàn)證和listen 監(jiān)聽地址
sed '/all.*127.0.0.1/ s/ident/trust/' /var/lib/pgsql/9.5/data/pg_hba.conf
sed -i "/^#listen_addresses/a\listen_addresses='*'" /var/lib/pgsql/9.5/data/postgresql.conf
pgsql hba認(rèn)證配置
認(rèn)證權(quán)限配置文件為 /var/lib/pgsql/9.5/data/pg_hba.conf
常見的四種身份驗(yàn)證為:
- trust:凡是連接到服務(wù)器的纤子,都是可信任的搬瑰。只需要提供psql用戶名,可以沒有對(duì)應(yīng)的操作系統(tǒng)同名用戶.
- password 和 md5:對(duì)于外部訪問控硼,需要提供 psql 用戶名和密碼泽论。對(duì)于本地連接,提供 psql 用戶名密碼之外卡乾,還需要有操作系統(tǒng)訪問權(quán)翼悴。(用操作系統(tǒng)同名用戶驗(yàn)證)password 和 md5 的區(qū)別就是外部訪問時(shí)傳輸?shù)拿艽a是否用 md5 加密.
- ident:對(duì)于外部訪問,從 ident 服務(wù)器獲得客戶端操作系統(tǒng)用戶名,然后把操作系統(tǒng)作為數(shù)據(jù)庫(kù)用戶名進(jìn)行登錄對(duì)于本地連接鹦赎,實(shí)際上使用了peer.
- peer:通過客戶端操作系統(tǒng)內(nèi)核來獲取當(dāng)前系統(tǒng)登錄的用戶名谍椅,并作為psql用戶名進(jìn)行登錄.
create pgsql db user
sudo -u postgres psql
CREATE USER kong; CREATE DATABASE kong OWNER kong;
ALTER USER kong WITH PASSWORD '123456';
grant all privileges on database kong to kong;/
install kong
cd /opt
wget https://kong.bintray.com/kong-community-edition-rpm/centos/6/kong-community-edition-1.1.0.el6.noarch.rpm
yum install -y epel-release
yum install -y kong-community-edition-1.1.0.el6.noarch.rpm
config kong
訪問數(shù)據(jù)庫(kù)的信息,我們上面創(chuàng)建庫(kù)和用戶和密碼時(shí)候就是按照下面配置創(chuàng)建的古话,所以這里用默認(rèn)配置雏吭。
cp /etc/kong/kong.conf.default /etc/kong/kong.conf
#####截圖部分配置
cat /etc/kong/kong.conf
#pg_host = 127.0.0.1 # 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 = 123456 # Postgres user's password.
#pg_database = kong # The database name to connect to.
start kong
#導(dǎo)入數(shù)據(jù)
/usr/local/bin/kong migrations bootstrap -c /etc/kong/kong.conf
#啟動(dòng)
/usr/local/bin/kong start -c /etc/kong/kong.conf
#check
curl -i http://localhost:8001/
kong port
Kong默認(rèn)監(jiān)聽下面端口:
8000,監(jiān)聽來自客戶端的HTTP流量陪踩,轉(zhuǎn)發(fā)到你的upstream服務(wù)上杖们。
8443,監(jiān)聽HTTPS的流量肩狂,功能跟8000一樣摘完。可以通過配置文件禁止傻谁。
8001孝治,Kong的HTTP監(jiān)聽的api管理接口。
8444审磁,Kong的HTTPS監(jiān)聽的API管理接口谈飒。
kong dashboard
curl --silent --location https://rpm.nodesource.com/setup_9.x | bash -
yum install nodejs -y
npm install -g kong-dashboard
kong-dashboard start --kong-url http://localhost:8001 --port 8002
image.png