创建数据目录(Create data folder)
[iyunv@Darren2 ~]# mkdir -p /usr/local/pgsql/data
配置.bash_profile(Configure .bash_profile)
[iyunv@Darren2 pgsql]# cat /usr/local/pgsql/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PGHOME=/usr/local/pgsql
export PGDATA=/usr/local/pgsql/data
export PATH=$PATH:/usr/local/pgsql/bin
set umask to 022
umask 022
PS1=`uname -n`":"'$USER'":"'$PWD'":>"; export PS1
#启动数据库
Darren2:postgres:/usr/local/pgsql:>pg_ctl start
server starting
Darren2:postgres:/usr/local/pgsql:>LOG: database system was shut down at 2017-07-12 00:49:17 CST
LOG: MultiXact member wraparound protections are now enabled
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
创建用户和数据库(Create user and database)
psql
psql (9.6.3)
Type "help" for help.
postgres=# create user admin password'admin' login;
CREATE ROLE
postgres=# create database testdb with owner=admin;
CREATE DATABASE
Darren2:postgres:/usr/local/pgsql:>pg_ctl status
pg_ctl: server is running (PID: 51498)
/usr/local/pgsql/bin/postgres
安装过程中常见报错
编译时候报错:
[iyunv@Darren2 postgresql-9.6.3]# ./configure --prefix=/usr/local/pgsql --without-zlib
......
configure: error: readline library not found --提示找不到readline
If you have readline already installed, see config.log for details on the
failure. It is possible the compiler isn't looking in the proper directory.
Use --without-readline to disable readline support.
查看系统已经安装readline:
[iyunv@Darren2 postgresql-9.6.3]# rpm -qa |grep readline
compat-readline5-5.2-17.1.el6.x86_64
readline-6.0-4.el6.x86_64
通过yum search可以发现没有安装readline-devel:
[iyunv@Darren2 postgresql-9.6.3]# yum search readline
......
readline-devel.i686 : Files needed to develop programs which use the readline library
readline-devel.x86_64 : Files needed to develop programs which use the readline library
......
通过yum安装之后,在编译即可通过:
[iyunv@Darren2 postgresql-9.6.3]# yum install -y readline-devel