Centos7离线安装PostgreSQL11

PostgreSQL官网:https://www.postgresql.org

rpm依赖下载链接(可忽略步骤一):https://download.csdn.net/download/u011320682/11647218

  1. 找一台可以联网的centos7,下载yumdownloadonly插件(此插件的作用是可以把rpm镜像包下载到系统本地文件中)

    yum install yum-plugin-downloadonly
    插件安装完成后,下载postgresql11所需rpm文件。
    yum install --downloadonly --downloaddir=/root/pgsqlrpm postgresql11-11.5-1PGDG.rhel7.x86_64
    yum install --downloadonly --downloaddir=/root/pgsqlrpm postgresql11-libs-11.5-1PGDG.rhel7.x86_64
    yum install --downloadonly --downloaddir=/root/pgsqlrpm postgresql11-server-11.5-1PGDG.rhel7.x86_64

    下载完成后cd pgsqlrpm 查看文件是否下载成功,在这里插入图片描述

  2. 将下载文件拷贝至内网centos机器当中,依次执行
    rpm -ivh postgresql11-11.5-1PGDG.rhel7.x86_64
    rpm -ivh postgresql11-libs-11.5-1PGDG.rhel7.x86_64
    rpm -ivh postgresql11-server-11.5-1PGDG.rhel7.x86_64

    执行完以后,postgres安装完毕,初始化postgres并设置自启动
    /usr/pgsql-11/bin/postgresql-11-setup initdb
    systemctl start postgresql-11
    systemctl enable postgresql-11.service

    修改vim /var/lib/pgsql/9.6/data/postgresql.conf,
    找到listen_addresses,将其值修改为 *
    取消listen_addresses 和 port注释

    修改vim /var/lib/pgsql/9.6/data/pg_hba.conf,找到 #IPv4 local connections: 添加host
    host all all 127.0.0.1/32 trust
    host all all 0.0.0.0/0 md5

    保存后退出,重启postgres服务
    systemctl restart postgresql-11
    这时用 navicat等软件链接数据库即可,如果navicat提示 5432 端口TCP链接失败,请关闭centos7 防火墙或开启5432端口。

    备注:
    centos7 关闭防火墙
    systemctl stop firewalld.service #停止firewall
    systemctl disable firewalld.service #禁止firewall开机启动

发布了9 篇原创文章 · 获赞 2 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/u011320682/article/details/100180214