当前位置:   article > 正文

Centos7安装PostgreSQL12_centos7.9 安装 postgres12

centos7.9 安装 postgres12
一、环境
  • 系统:Centos7.9
  • 镜像源:阿里云PostgreSQL
二、配置镜像源
# 创建repo镜像源文件
touch /etc/yum.repos.d/pgsql12.repo
# 编辑配置文件
vi /etc/yum.repos.d/pgsql12.repo
  • 1
  • 2
  • 3
  • 4
  • pgsql12.repo参考:
[pgdg12]
name=PostgreSQL 12 for RHEL/CentOS $releasever - $basearch
baseurl=https://mirrors.aliyun.com/postgresql/repos/yum/12/redhat/rhel-$releasever-$basearch
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/postgresql/repos/yum/RPM-GPG-KEY-PGDG
repo_gpgcheck = 1
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
# 更新yum缓存
yum makecache
  • 1
  • 2
三、安装并配置PostgreSQL12
# 安装postgresql12-server
yum install postgresql12-server
# 编辑服务配置 修改数据库目录位置
# Environment=PGDATA=/opt/pgsql/12/data
vi /usr/lib/systemd/system/postgresql-12.service
# 初始化数据库
/usr/pgsql-12/bin/postgresql-12-setup initdb
# 修改配置文件  允许来自任何主机的连接
# listen_addresses = '*'
vi /opt/pgsql/12/data/postgresql.conf
# 修改配置文件 授权主机密码连接
# host    all             all             0.0.0.0/0            md5
vi /opt/pgsql/12/data/pg_hba.conf
# 启动服务
systemctl start postgresql-12.service
# 开机自动启动
systemctl enable postgresql-12.service
# 切换到postgres用户
su -l postgres
# 登录pg数据库
psql
# 设置postgres密码
\password postgres
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
四、防火墙配置
# 放行postgresql服务
firewall-cmd --zone=public --add-service=postgresql --permanent
# 重载防火墙
firewall-cmd --reload
  • 1
  • 2
  • 3
  • 4
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/458754
推荐阅读
相关标签
  

闽ICP备14008679号