api kong简单应用(0.10版本之前和0.10版本之后)-数据库安装

应用场景:

     管理微服务、开放API等。

环境搭建:

    1.安装postgres数据库(版本9.4以上),
      官网地址https://www.postgresql.org/download/

      解压postgresql-9.6.2.tar.bz2,

      tar jxvf postgresql-9.6.2.tar.bz2,

     进入解压后的目录

    cd postgresql-9.6.2

    编译postgresql源码

   ./configure --prefix=/opt/pgsql-9.6.2

  开始安装

      #make

  执行make命令

 执行make命令如果报错

*******************

a.

configure: error: zlib library not found
If you have zlib already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-zlib to disable zlib support.

解决方法

yum install zlib-devel;

b.

configure: error: readline library notfound
If you have readline already installed, see config.log for detailson the
failure.  It is possible the compiler isnt lookingin the proper directory.
Use --without-readline to disable readlinesupport.

解决办法

yum -y install -y readline-devel

*****************************

执行make install

到此刻,数据库安装完成

执行命令  ls /opt/pgsql-9.6.2

api kong简单应用(0.10版本之前和0.10版本之后)-数据库安装

2.创建postgres数据库

1) 创建postgres用户


#useradd postgres


修改postgres密码


#passwd postgres

2) 设置postgres用户的环境变量


切换到postgres用户


#su - postgres

进入postgres的主目录

#cd ~

编辑~/.bash_profile文件

#vi ~/.bash_profile

设置以下的环境变量

export PGHOME=/opt/pgsql-9.1.7

export PGDATA=~/data


api kong简单应用(0.10版本之前和0.10版本之后)-数据库安装

保存,退出vi。执行以下命令,使环境变量生效


#source ~/.bash_profile

3) 初始化postgres数据库

#initdb

4) 启动postgres数据库实例

#pg_ctl start

api kong简单应用(0.10版本之前和0.10版本之后)-数据库安装

#ps -ef | grep postgres  查看进程

5) 连接postgresql数据库


#psql -h 127.0.0.1 -d postgres -U postgres(或者直接 psql)

6) 停止postgresql数据库实例


#pg_ctl stop

7)下面这个图片copy别人的api kong简单应用(0.10版本之前和0.10版本之后)-数据库安装