一、安装流程
1, 下载源码解压
2, ./configure
3, make
4, make install
5, Useradd postgres
6, passwd postgres
7, mkdir /usr/local/pgsql/data
8, chown postgres /usr/local/pgsql/data
9, su – postgres “ - ” shell 环境的不同 与 su 是有区别的
10, /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
11, /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 &
12, /usr/local/pgsql/bin/createdb test
13, /usr/local/pgsql/bin/psql test
二、实际安装:
1、下载源码解压
tar jxvf postgresql-9.4.4.tar.bz2 或者tar zxvf postgresql-9.4.4.tar.gz
2、创建安装的目录
mkdir /opt/pgsql-9.4.4
3、进入解压后的目录
cd postgresql-9.4.4
4、进行安装 编译源码
./configure --prefix=/opt/pgsql-9.4.4
……
checking for library containing shmget... none required
checking for library containing readline... no
configure: error: readline library not found
If you have readline already installed, see config.log for details on the failure.
提示这种错误。安装依赖包
[root@highgo postgresql-9.4.0]# yum install readline-devel
[root@highgo postgresql-9.4.0]# yum install zlib-devel
5、make
6、make install
安装完成
7、Useradd postgres
8、passwd postgres
9、配置环境变量
可以把下面的内容添加到UNIX用户的~/.bash_profile或~/.profile文件中,
[root@highgo postgresql-9.4.0]# su - postgres
[postgres@highgo ~]$ vi ~/.bash_profile
...#postgres
export PGDATA=/usr/local/pgsql/data
export PATH=/usr/local/pgsql/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/pgsql/lib:$LD_LIBRARY_PATH
[postgres@highgo ~]$ source ~/.bash_profile
10、initdb
[postgres@highgo ~]$ initdb
11、启动数据库
[postgres@highgo ~]$ pg_ctl start