postgresql在线安装很简单
进入官网:
https://www.posthttps://www.postgresql.org/gresql.org/
如文档所示,在线安装步骤与命令:
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm sudo yum install -y postgresql10-server sudo /usr/pgsql-10/bin/postgresql-10-setup initdb sudo systemctl enable postgresql-10 sudo systemctl start postgresql-10
但是很多情况,服务器不能联网,需要离线安装。
下面是离线安装的步骤:
在能联网的机器上下载yum源
yum install https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-6-x86_64/pgdg-centos95-9.5-3.noarch.rpm 下载postgres软件 yum search postgres mkdir psql95 yum install --downloadonly --downloaddir=psql95 postgresql95 postgresql95-server
查看下载的软件包
# ls
postgresql95-9.5.13-1PGDG.rhel6.x86_64.rpm
postgresql95-libs-9.5.13-1PGDG.rhel6.x86_64.rpm
postgresql95-server-9.5.13-1PGDG.rhel6.x86_64.rpm
打包并传送到需要安装的离线服务器上
# tar -zcvf pg.tar.gz *
postgresql95-9.5.13-1PGDG.rhel6.x86_64.rpm
postgresql95-libs-9.5.13-1PGDG.rhel6.x86_64.rpm
postgresql95-server-9.5.13-1PGDG.rhel6.x86_64.rpm
在需要安装端解压,安装
rpm -ivh postgresql95-*
启动
# service postgresql-9.5 initdb
# service postgresql-9.5 start
# chkconfig postgresql-9.5 on