当前位置:网站首页>Centos7 installing postgresql12

Centos7 installing postgresql12

2022-06-23 01:26:00 Halyace

One 、 Environmental Science

  • System :Centos7.9
  • Mirror source : Alibaba cloud PostgreSQL

Two 、 Configure image source

#  establish repo Mirror source files 
touch /etc/yum.repos.d/pgsql12.repo
#  Edit profile 
vi /etc/yum.repos.d/pgsql12.repo
  • pgsql12.repo Reference resources :
[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
#  to update yum cache 
yum makecache

3、 ... and 、 Install and configure PostgreSQL12

#  install postgresql12-server
yum install postgresql12-server
#  Edit the service configuration   Modify the database directory location 
# Environment=PGDATA=/opt/pgsql/12/data
vi /usr/lib/systemd/system/postgresql-12.service
#  Initialize database 
/usr/pgsql-12/bin/postgresql-12-setup initdb
#  Modify the configuration file   Allow connections from any host 
# listen_addresses = '*'
vi /opt/pgsql/12/data/postgresql.conf
#  Modify the configuration file   Authorized host password connection 
# host all all 0.0.0.0/0 md5
vi /opt/pgsql/12/data/pg_hba.conf
#  Start the service 
systemctl start postgresql-12.service
#  Boot up automatically 
systemctl enable postgresql-12.service
#  Switch to postgres user 
su -l postgres
#  Sign in pg database 
psql
#  Set up postgres password 
\password postgres

Four 、 Firewall configuration

#  release postgresql service 
firewall-cmd --zone=public --add-service=postgresql --permanent
#  Overloaded firewall 
firewall-cmd --reload
原网站

版权声明
本文为[Halyace]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206220916546161.html