更新升级 专属应用 系统故障 硬件故障 电脑汽车 鸿蒙刷机 鸿蒙开发Linux教程 鸿蒙开发Linux命令
当前位置:HMXT之家 > 鸿蒙开发Linux教程 > 在Rocky Linux 8/AlmaLinux 8上安装PostgreSQL 15

在Rocky Linux 8/AlmaLinux 8上安装PostgreSQL 15

更新时间:2023-01-12 10:39:40浏览次数:575+次

本文介绍如何在Rocky Linux 8/AlmaLinux 8系统上安装PostgreSQL 15数据库服务器的方法。

1、添加PostgreSQL 15存储库

默认的Rocky Linux 8/AlmaLinux 8存储库提供PostgreSQL 10,要验证这一点,请使用以下命令:

$ dnf provides postgresql-server

通常会返回postgresql-server-10.21-2.module+el8.6.0+977+ab6e685c.x86_64之类的信息,如下图:

\

为了安装PostgreSQL 15,我们需要将存储库添加到Rocky Linux 8/AlmaLinux 8。这可以使用以下命令完成:

##对于x86_64

sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm

##对于ppc64le

sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-ppc64le/pgdg-redhat-repo-latest.noarch.rpm

##对于aarch64

sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-aarch64/pgdg-redhat-repo-latest.noarch.rpm

接下来,禁用内置PostgreSQL模块:

sudo dnf -qy module disable postgresql

2、在Rocky Linux 8/AlmaLinux 8上安装PostgreSQL 15

使用上述命令添加存储库后,我们将在Rocky Linux 8/AlmaLinux 8上安装PostgreSQL 15。

此命令为:

sudo dnf install postgresql15-server -y

依赖关系树:

Transaction Summary

Install  3 Packages

Total download size: 7.8 M

Installed size: 33 M

Is this ok [y/N]: y

请按y键继续安装。

安装完成后,初始化PostgreSQL 15:

$ sudo /usr/pgsql-15/bin/postgresql-15-setup initdb

Initializing database ... OK

现在启动并启用PostgreSQL 15服务:

sudo systemctl enable postgresql-15

sudo systemctl start postgresql-15

检查服务是否正在运行:

$ systemctl status postgresql-15

会返回如下图信息:

\

至此,安装PostgreSQL 15成功。