如何在RHEL 8中安装PostgreSQL和pgAdmin

2023-06-0512:36:06数据库教程Comments983 views字数 2049阅读模式
如何在RHEL 8中安装PostgreSQL和pgAdmin

Pgadmin4是用于管理PostgreSQL数据库的基于Web的开源管理工具。这是一个基于Python的Web应用程序,使用后端的flask框架以及前端的HTML5,CSS3和Bootstrap开发。Pgadmin4是对Pgadmin 3的重写,它是用C ++编写的,并具有以下显着功能:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/44562.html

Pgadmin4功能

  • 精致的网页界面,带有优美的图标和面板。
  • 全面响应的Web布局,带有用于实时监控的仪表板
  • 具有语法突出显示功能的实时SQL查询工具/编辑器
  • 强大的管理对话框和常用任务工具
  • 有用的提示可帮助您入门
  • 还有更多

在本文中,您将了解如何使用RHEL8上的WSGI模块在服务器模式下安装PostgreSQL和pagAdmin4,并且Apache web服务器在后端运行。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/44562.html

在RHEL 8上安装PostgreSQL

安装PgAdmin4的第一步是安装PostgreSQL数据库服务器。PostgreSQL在Appstream存储库中有不同版本。您可以通过使用dnf软件包管理器启用首选软件包来进行选择。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/44562.html

要列出PostgreSQL的可用模块,请运行以下命令:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/44562.html

# dnf module list postgresql
如何在RHEL 8中安装PostgreSQL和pgAdmin
列出Postgresql的模块

输出表明可以从AppStream存储库中下载3个版本:版本9.6、10和12。我们还可以看到默认版本为标记所指示的Postgresql 10[d]。这是通过运行以下命令来安装的内容。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/44562.html

# dnf install postgresql-server

但是,我们要安装最新版本,即PostgreSQL 12。因此,我们将启用该模块并覆盖默认模块流。为此,运行命令:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/44562.html

# dnf module enable postgresql:12
如何在RHEL 8中安装PostgreSQL和pgAdmin
为PostgreSQL启用模块

一旦为Postgresql 12启用了模块,请继续并安装Postgresql 12及其依赖关系,如下所示。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/44562.html

# dnf install postgresql-server
如何在RHEL 8中安装PostgreSQL和pgAdmin
在RHEL 8中安装PostgreSQL

首先,您需要创建数据库集群。集群包含由服务器实例管理的数据库的集合。要创建数据库集群,请调用以下命令:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/44562.html

# postgresql-setup --initdb

如果一切顺利,您应该在下面获得输出。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/44562.html

如何在RHEL 8中安装PostgreSQL和pgAdmin
初始化PostgreSQL数据库

创建集群后,您现在可以启动并启用PostgreSQL实例,如下所示:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/44562.html

# systemctl start postgresql
# systemctl enable postgresql

要确认Postgresql已启动并正在运行,请执行:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/44562.html

# systemctl status postgresql
如何在RHEL 8中安装PostgreSQL和pgAdmin
验证PostgreSQL状态

在RHEL 8中安装Pgadmin4

要安装Pgadmin4,首先,添加如下所示的外部仓库。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/44562.html

# rpm -i https://ftp.postgresql.org/pub/pgadmin/pgadmin4/yum/pgadmin4-redhat-repo-1-1.noarch.rpm

接下来,运行以下命令以服务器模式安装pgadmin4。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/44562.html

# dnf install pgadmin4-web  
如何在RHEL 8中安装PostgreSQL和pgAdmin
在RHEL 8中安装Pgadmin4

接下来,安装policycoreutils软件包,这些软件包提供SELinux所需的核心实用程序。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/44562.html

$ sudo dnf install policycoreutils-python-utils
如何在RHEL 8中安装PostgreSQL和pgAdmin
在RHEL 8中安装Python Policycoreutils

安装后,如图所示运行Pgadmin4安装脚本。这将创建一个pgadmin用户帐户,存储和日志目录,配置SELinux并启动将运行pgAdmin4的Apache Web服务器。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/44562.html

# /usr/pgadmin4/bin/setup-web.sh

出现提示时,请提供所需信息,然后单击'Y'以启动Apache Web服务器。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/44562.html

如何在RHEL 8中安装PostgreSQL和pgAdmin
运行Pgadmin安装脚本

如果您正在运行防火墙,请打开端口80以允许Web服务流量。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/44562.html

# firewall-cmd --add-port=80/tcp --permanent
# firewall-cmd --reload

接下来,配置SELinux,如下所示:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/44562.html

# setsebool -P httpd_can_network_connect 1

要访问pgadmin4,请启动浏览器并浏览显示的URL。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/44562.html

http://server-ip/pgadmin4

确保使用运行设置脚本时提供的电子邮件地址和密码登录。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/44562.html

如何在RHEL 8中安装PostgreSQL和pgAdmin
pgadmin4登录

如下所示,这将带您进入Pgadmin4仪表板。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/44562.html

如何在RHEL 8中安装PostgreSQL和pgAdminAI配图魔改
Pgadmin4控制主页

这就是在服务器模式下安装Pgadmin4的方式。现在,您可以使用SQL编辑器创建和管理PostgreSQL数据库,并使用提供的仪表板监视其性能。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/44562.html

原文链接:https://www.tecmint.com/install-postgresql-and-pgadmin-in-rhel-8/
译者:Yue Yong
文章源自菜鸟学院-https://www.cainiaoxueyuan.com/sjk/44562.html

  • 本站内容整理自互联网,仅提供信息存储空间服务,以方便学习之用。如对文章、图片、字体等版权有疑问,请在下方留言,管理员看到后,将第一时间进行处理。
  • 转载请务必保留本文链接:https://www.cainiaoxueyuan.com/sjk/44562.html

Comment

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定