- 下载源码
打开官网,选择源码分区,选择要下载的版本,这里我要下载10的版本,所以选这个:
postgre源码下载
在linux中输入:
[root@node1 ~]# wget --no-check-certificate https://ftp.postgresql.org/pub/source/v10.0/postgresql-10.0.tar.gz
解压下载好的压缩包:
[root@node1 ~]# tar -xvf postgresql-10.0.tar.gz
- 运行configure程序配置编译选项
先准备好编译环境和安装必要的包:
[root@node1 ~]# yum groupinstall "Development tools"
[root@node1 ~]# yum install -y bison flex readline-devel zlib-devel
configure程序配置编译选项:
[root@node1 ~]# cd postgresql-10.0
[root@node1 postgresql-10.0]# ./configure --help | less
...
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local/pgsql]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
By default, `make install' will install all the files in
`/usr/local/pgsql/bin', `/usr/local/pgsql/lib' etc. You can specify
an installation prefix other than `/usr/local/pgsql' using `--prefix',
for instance `--prefix=$HOME'.
...
对软件目录和端口进行指定:
[root@node1 postgresql-10.0]# ./configure --prefix=/opt/pg10/ --with-pgport=1921
- 编译安装
[root@node1 postgresql-10.0]# gmake
[root@node1 postgresql-10.0]# gmake install
....
/usr/bin/install -c -m 755 ./missing '/opt/pg10/lib/postgresql/pgxs/config/missing'
gmake[1]: Leaving directory `/root/postgresql-10.0/config'
PostgreSQL installation complete.
安装成功后,查看数据库版本。
[root@node1 postgresql-10.0]# /opt/pg10/bin/postgres --version
postgres (PostgreSQL) 10.0