PgAdmin4是易于使用的Web界面,用于管理PostgreSQL数据库。它可以在多个平台上使用,例如Linux,Windows和Mac OSX。在pgAdmin 4中,存在从引导程序3到引导程序4的迁移。
配置yum的安装源
# 安装源
yum -y install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm
安装源


运行在线安装
# 可以使用以下命令安装pgAdmin
yum install pgadmin4
在安装过程中,由于依赖关系,还将安装以下两个文件-pgadmin4-web和httpd Web服务器。


配置pgAdmin 4
要运行pgAdmin4,需要进行一些小的配置更改。首先,我们将示例conf文件从pgadmin4.conf.sample重命名为pgadmin4.conf:
#mv /etc/httpd/conf.d/pgadmin4.conf.sample /etc/httpd/conf.d/pgadmin4.conf

调整文件,使其如下所示:
<VirtualHost *:80>
LoadModule wsgi_module modules/mod_wsgi.so
WSGIDaemonProcess pgadmin processes=1 threads=25
WSGIScriptAlias /pgadmin4 /usr/lib/python2.7/site-packages/pgadmin4-web/pgAdmin4.wsgi
<Directory /usr/lib/python2.7/site-packages/pgadmin4-web/>
WSGIProcessGroup pgadmin
WSGIApplicationGroup %{GLOBAL}
<IfModule mod_authz_core.c>
# Apache 2.4
Require all granted
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order Deny,Allow
Deny from All
Allow from 127.0.0.1
Allow from ::1
</IfModule>
</Directory>
</VirtualHost>


接下来,我们将为pgAdmin4创建日志和lib目录,并设置它们的所有权:
# mkdir -p /var/lib/pgadmin4/
# mkdir -p /var/log/pgadmin4/
# chown -R apache:apache /var/lib/pgadmin4
# chown -R apache:apache /var/log/pgadmin4

然后我们可以扩展config_distro.py的内容
# vim /usr/lib/python2.7/site-packages/pgadmin4-web/config_distro.py

并添加以下行:
LOG_FILE = '/var/log/pgadmin4/pgadmin4.log'
SQLITE_PATH = '/var/lib/pgadmin4/pgadmin4.db'
SESSION_DB_PATH = '/var/lib/pgadmin4/sessions'
STORAGE_DIR = '/var/lib/pgadmin4/storage'

创建账户
最后,我们将创建我们的用户帐户,并使用该帐户在Web界面中进行身份验证。为此,请运行
#python /usr/lib/python2.7/site-packages/pgadmin4-web/setup.py

我这里输入的密码123456
启动http的服务
systemctl start httpd

现在,您可以访问服务器的http:// ip-address / pgadmin4或http:// localhost / pgadmin4来访问pgAdmin4界面:

如果在访问PgAdmin4界面时收到403错误,则需要在以下文件上设置正确的SELinux上下文。
# chcon -t httpd_sys_rw_content_t /var/log/pgadmin4 -R
# chcon -t httpd_sys_rw_content_t /var/lib/pgadmin4 -R
要进行身份验证,请使用之前使用的电子邮件地址和密码。身份验证之后,您将看到pgAdmin4接口:

登录pgAdmin4
首次登录时,您将需要添加新服务器进行管理。点击“ 添加新服务器 ”。

您将需要配置PostgresQL连接。在第一个标签“ 常规 ”中,输入以下设置:
名称 –输入您要配置的服务器的名称。
注释 –留下注释以提供实例的描述。

第二个选项卡“ 连接 ”更为重要,因为您必须输入:
主机 – PostgreSQL实例的主机/ IP地址。
端口 –默认端口为5432。
维护数据库 –应该是postgres。
用户名–将要连接的用户名。您可以使用postgres用户。
密码 –上述用户的密码。

填满所有内容后,保存更改。如果连接成功,您应该看到以下页面:

就是这样 你pgAdmin4安装完成后,你可以开始管理你的PostgreSQL数据库。
网友评论