PostgreSQL 15

一、安装前的准备

1、版本信息
操作系统CentOS 7.9.2009
PostgreSQL 版本PostgreSQL 15-15.7
2、下载安装包

RPM Chart - PostgreSQL YUM Repositoryicon-default.png?t=N7T8https://yum.postgresql.org/rpmchart/进入官网,找到相应版本

点击框选内容

依次进入下载页面,下载相应版本安装包

二、安装

1、上传安装包到服务器/opt/目录下
2、安装
rpm -ivh postgresql15-libs-15.7-1PGDG.rhel7.x86_64.rpm

rpm -ivh postgresql15-15.7-1PGDG.rhel7.x86_64.rpm

rpm -ivh postgresql15-server-15.7-1PGDG.rhel7.x86_64.rpm
3、修改配置
vi /usr/lib/systemd/system/postgresql-15.service
# 修改存储目录
Environment=PGDATA=/opt/postgres/data/
4、创建目录并修改权限
mkdir -p /opt/postgres/data
chown -R postgres: postgres
chmod 700 data/
5、初始化数据库
/usr/pgsql-15/bin/postgresql-15-setup initdb
Initializing database ... OK
6、启动服务并设置开机自启
[root@localhost postgres]# systemctl start postgresql-15.service 
[root@localhost postgres]# systemctl status postgresql-15.service 
● postgresql-15.service - PostgreSQL 15 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-15.service; disabled; vendor preset: disabled)
   Active: active (running) since Fri 2024-08-02 04:59:05 EDT; 7s ago
     Docs: https://www.postgresql.org/docs/15/static/
  Process: 48801 ExecStartPre=/usr/pgsql-15/bin/postgresql-15-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 48806 (postmaster)
   CGroup: /system.slice/postgresql-15.service
           ├─48806 /usr/pgsql-15/bin/postmaster -D /opt/postgres/data/
           ├─48808 postgres: logger 
           ├─48809 postgres: checkpointer 
           ├─48810 postgres: background writer 
           ├─48812 postgres: walwriter 
           ├─48813 postgres: autovacuum launcher 
           └─48814 postgres: logical replication launcher 

Aug 02 04:59:05 localhost.localdomain systemd[1]: Starting PostgreSQL 15 database server...
Aug 02 04:59:05 localhost.localdomain postmaster[48806]: 2024-08-02 04:59:05.058 EDT [48806] LOG:  redirecting log output to logging collector process
Aug 02 04:59:05 localhost.localdomain postmaster[48806]: 2024-08-02 04:59:05.058 EDT [48806] HINT:  Future log output will appear in directory "log".
Aug 02 04:59:05 localhost.localdomain systemd[1]: Started PostgreSQL 15 database server.
[root@localhost postgres]# 
[root@localhost postgres]# 
[root@localhost postgres]# systemctl enable postgresql-15.service g
Failed to execute operation: No such file or directory
[root@localhost postgres]# systemctl enable postgresql-15.service 
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-15.service to /usr/lib/systemd/system/postgresql-15.service.
7、修改管理员密码
[root@localhost postgres]# su - postgres 
-bash-4.2$ psql 
psql (15.7)
Type "help" for help.

postgres=# alter user postgres with password 'postgres';
ALTER ROLE
8、设置允许远程登陆
vi /opt/postgres/data/postgresql.conf
# 修改下面行
listen_addresses = '*'

vi /opt/postgres/data/pg_hba.conf
# 在最后添加下面行
host    all             all             0.0.0.0/0               md5

# 重启服务,进行远程连接测试

三、错误

[root@localhost opt]# rpm -ivh postgresql15-server-15.7-1PGDG.rhel7.x86_64.rpm 
warning: postgresql15-server-15.7-1PGDG.rhel7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 73e3b907: NOKEY
error: Failed dependencies:
        libicui18n.so.50()(64bit) is needed by postgresql15-server-15.7-1PGDG.rhel7.x86_64
        libicuuc.so.50()(64bit) is needed by postgresql15-server-15.7-1PGDG.rhel7.x86_64
        libzstd.so.1()(64bit) is needed by postgresql15-server-15.7-1PGDG.rhel7.x86_64
        postgresql15(x86-64) = 15.7-1PGDG.rhel7 is needed by postgresql15-server-15.7-1PGDG.rhel7.x86_64

rpm -ivh libicu-50.2-4.el7_7.x86_64.rpm
yum -y install libzstd.x86_64
  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值