PostgreSQL数据库安装部署

一、postgresql数据库部署

  1、前往postgresql安装包的目录(这里我部署的是10.5的版本)

[root@web1 ~]# cd /package/
[root@web1 package]# ls
apache-tomcat-8.5.39.tar.gz  jdk-8u131-linux-x64.tar.gz  postgresql-10.5.tar.gz  redis-3.2.0.tar.gz
[root@web1 package]#

  2、解压缩包

[root@web1 package]# tar xf postgresql-10.5.tar.gz
[root@web1 package]# ls
apache-tomcat-8.5.39.tar.gz  jdk-8u131-linux-x64.tar.gz  postgresql-10.5  postgresql-10.5.tar.gz  redis-3.2.0.tar.gz
[root@web1 package]#

  3、进入解压后生成的目录文件进行编译

[root@web1 postgresql-10.5]# ./configure --prefix=/usr/local/pgsql-10.5
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking which template to use... linux
checking whether NLS is wanted... no
checking for default port number... 5432
checking for block size... 8kB
checking for segment size... 1GB
checking for WAL block size... 8kB
checking for WAL segment size... 16MB

  4、提示如下信息是缺少包文件

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.  It is possible the compiler isn't looking in the proper directory.
Use --without-readline to disable readline support.

  5、安装相应的包文件文件

[root@web1 postgresql-10.5]#yum install ncurses* readline* zlib* -y
######################################
[root@web1 postgresql-10.5]# rpm -aq ncurses* readline* zlib*
readline-devel-6.2-10.el7.x86_64
zlib-static-1.2.7-18.el7.x86_64
ncurses-libs-5.9-14.20130511.el7_4.x86_64
ncurses-devel-5.9-14.20130511.el7_4.x86_64
readline-static-6.2-10.el7.x86_64
zlib-devel-1.2.7-18.el7.x86_64
readline-6.2-10.el7.x86_64
ncurses-base-5.9-14.20130511.el7_4.noarch
ncurses-5.9-14.20130511.el7_4.x86_64
zlib-1.2.7-18.el7.x86_64
[root@web1 postgresql-10.5]#

  6、安装完成后重新编译下

[root@web1 postgresql-10.5]# ./configure --prefix=/usr/local/pgsql-10.5
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking which template to use... linux
checking whether NLS is wanted... no
checking for default port number... 5432
checking for block size... 8kB
checking for segment size... 1GB
checking for WAL block size... 8kB
checking for WAL segment size... 16MB
checking for gcc... gcc

  7、解析文件(在postgresql-10.5目录执行:make install),最后输出结果没提示异常【error】便可开始安装了

rm -f pg_regress.o && ln -s ../../../src/test/regress/pg_regress.o .
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -Wl,--as-needed -Wl,-rpath,'/usr/local/pgsql-10.5/lib',--enable-new-dtags  -lpgcommon -lpgport -lpthread -lz -lreadline -lrt -lcrypt -ldl
make[2]: Leaving directory `/package/postgresql-10.5/src/test/isolation'
make -C test/perl all
make[2]: Entering directory `/package/postgresql-10.5/src/test/perl'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/package/postgresql-10.5/src/test/perl'
make[1]: Leaving directory `/package/postgresql-10.5/src'
make -C config all
make[1]: Entering directory `/package/postgresql-10.5/config'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/package/postgresql-10.5/config'
All of PostgreSQL successfully made. Ready to install.

  8、开始安装(在postgresql-10.5目录执行:make install),最后输出结果没提示异常【error】便表示安装成功

/bin/install -c -m 644 Makefile.global '/usr/local/pgsql-10.5/lib/pgxs/src/Makefile.global'
/bin/install -c -m 644 Makefile.port '/usr/local/pgsql-10.5/lib/pgxs/src/Makefile.port'
/bin/install -c -m 644 ./Makefile.shlib '/usr/local/pgsql-10.5/lib/pgxs/src/Makefile.shlib'
/bin/install -c -m 644 ./nls-global.mk '/usr/local/pgsql-10.5/lib/pgxs/src/nls-global.mk'
make[1]: Leaving directory `/package/postgresql-10.5/src'
make -C config install
make[1]: Entering directory `/package/postgresql-10.5/config'
/bin/mkdir -p '/usr/local/pgsql-10.5/lib/pgxs/config'
/bin/install -c -m 755 ./install-sh '/usr/local/pgsql-10.5/lib/pgxs/config/install-sh'
/bin/install -c -m 755 ./missing '/usr/local/pgsql-10.5/lib/pgxs/config/missing'
make[1]: Leaving directory `/package/postgresql-10.5/config'
PostgreSQL installation complete.

  9、安装完成后可以看到在/usr/local目录上成了pgsql-10.5目录

[root@web1 postgresql-10.5]# ll /usr/local/ |grep pgsql-10.5
drwxr-xr-x  6 root root  56 May 23 18:06 pgsql-10.5
[root@web1 postgresql-10.5]#

  10、创建用户及设置/usr/local/pgsql-10.5目录文件属主组

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/15dd67eb13e2cd9f8fd027e133d9cf53.html