微前端架构如何改变企业的开发模式与效率提升
1138
2022-09-28
「PostgreSQL 」如何在CentOS 7 / CentOS 8上安装PostgreSQL 12
本指南将引导您完成在CentOS 7 / CentOS 8 Linux服务器上安装PostgreSQL 12的步骤。PostgreSQL是一个基于POSTGRES 4.2的对象关系数据库管理系统。开发人员和数据库管理员可以使用PostgreSQL 12。PostgreSQL项目为最常见的发行版提供了所有受支持版本的软件包的存储库。支持的发行版包括所有Red Hat系列,其中包括CentOS,Fedora,Scientific Linux,Oracle Linux和Red Hat Enterprise Linux。
使用以下步骤在CentOS 8 / CentOS 7上安装PostgreSQL 12。
步骤1:将PostgreSQL Yum存储库添加到CentOS 7 / CentOS 8
PostgreSQL Yum存储库将与您的常规系统和补丁程序管理集成,并在PostgreSQL的整个支持期限内为所有受支持的PostgreSQL版本提供自动更新。
可以通过运行以下命令将其添加到CentOS系统中:
CentOS 8:
sudo yum -y install 7:
sudo yum -y install rpm -qi pgdg-redhat-repoName : pgdg-redhat-repoVersion : 42.0Release : 4Architecture: noarchInstall Date: Thu 19 Sep 2019 06:34:53 PM UTCGroup : System Environment/BaseSize : 6915License : PostgreSQLSignature : DSA/SHA1, Wed 17 Apr 2019 04:12:42 AM UTC, Key ID 1f16d2e1442df0f8Source RPM : pgdg-redhat-repo-42.0-4.src.rpmBuild Date : Wed 17 Apr 2019 04:12:41 AM UTCBuild Host : koji-centos7-x86-64-pgbuildRelocations : (not relocatable)Vendor : PostgreSQL Global Development GroupURL : : PostgreSQL PGDG RPMs- Yum Repository Configuration for Red Hat / CentOS / Scientific LinuxDescription :This package contains yum configuration for Red Hat Enterprise Linux, CentOSand Scientific Linux. and also the GPG key for PGDG RPMs.
步骤2:在CentOS 8 / CentOS 7上安装PostgreSQL 12
添加YUM存储库后,我们可以使用以下命令在CentOS 7/8上安装PostgreSQL 12。
CentOS 8上的PostgreSQL 12
禁用内置的PostgreSQL模块:
sudo dnf -qy module disable postgresql
然后安装客户端和服务器软件包:
sudo dnf -y install postgresql12 postgresql12-server
CentOS 7上的PostgreSQL 12
安装PostgreSQL客户端和服务器软件包:
sudo yum -y install epel-release yum-utils sudo yum-config-manager --enable pgdg12 sudo yum install postgresql12-server postgresql12
样本安装输出:
Dependencies Resolved===================================================================================================================================================Package Arch Version Repository Size===================================================================================================================================================Installing:postgresql12 x86_64 12beta4-1PGDG.rhel7 pgdg12-testing 1.8 Mpostgresql12-server x86_64 12beta4-1PGDG.rhel7 pgdg12-testing 5.4 MInstalling for dependencies:libicu x86_64 50.2-3.el7 base 6.9 Mpostgresql12-libs x86_64 12beta4-1PGDG.rhel7 pgdg12-testing 383 kpython3 x86_64 3.6.8-10.el7 base 69 kpython3-libs x86_64 3.6.8-10.el7 base 7.0 Mpython3-pip noarch 9.0.3-5.el7 base 1.8 Mpython3-setuptools noarch 39.2.0-10.el7 base 629 kTransaction Summary===================================================================================================================================================Install 2 Packages (+6 Dependent packages)Total download size: 24 MInstalled size: 104 MDownloading packages:(1/8): libicu-50.2-3.el7.x86_64.rpm | 6.9 MB 00:00:00warning: /var/cache/yum/x86_64/7/pgdg12-testing/packages/postgresql12-libs-12beta4-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEYPublic key for postgresql12-libs-12beta4-1PGDG.rhel7.x86_64.rpm is not installed(2/8): postgresql12-libs-12beta4-1PGDG.rhel7.x86_64.rpm | 383 kB 00:00:00(3/8): python3-3.6.8-10.el7.x86_64.rpm | 69 kB 00:00:00(4/8): python3-setuptools-39.2.0-10.el7.noarch.rpm | 629 kB 00:00:00(5/8): postgresql12-12beta4-1PGDG.rhel7.x86_64.rpm | 1.8 MB 00:00:00(6/8): python3-libs-3.6.8-10.el7.x86_64.rpm | 7.0 MB 00:00:00(7/8): postgresql12-server-12beta4-1PGDG.rhel7.x86_64.rpm | 5.4 MB 00:00:00(8/8): python3-pip-9.0.3-5.el7.noarch.rpm | 1.8 MB 00:00:00---------------------------------------------------------------------------------------------------------------------------------------------------Total 15 MB/s | 24 MB 00:00:01Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDGImporting GPG key 0x442DF0F8:Userid : "PostgreSQL RPM Building Project
步骤3:初始化并启动数据库服务
安装后,需要先进行数据库初始化,然后才能启动服务。
sudo /usr/pgsql-12/bin/postgresql-12-setup initdb
数据库主要配置ifile写入:/var/lib/pgsql/12/data/postgresql.conf
启动并启用数据库服务器服务。
sudo systemctl enable --now postgresql-12
确认服务已启动,没有任何错误。
$ systemctl status postgresql-12● postgresql-12.service - PostgreSQL 12 database serverLoaded: loaded (/usr/lib/systemd/system/postgresql-12.service; enabled; vendor preset: disabled)Active: active (running) since Thu 2019-09-19 18:50:10 UTC; 39s agoDocs: 10647 ExecStartPre=/usr/pgsql-12/bin/postgresql-12-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)Main PID: 10652 (postmaster)CGroup: /system.slice/postgresql-12.service├─10652 /usr/pgsql-12/bin/postmaster -D /var/lib/pgsql/12/data/├─10654 postgres: logger├─10656 postgres: checkpointer├─10657 postgres: background writer├─10658 postgres: walwriter├─10659 postgres: autovacuum launcher├─10660 postgres: stats collector└─10661 postgres: logical replication launcherSep 19 18:50:10 cent7.novalocal systemd[1]: Starting PostgreSQL 12 database server...Sep 19 18:50:10 cent7.novalocal postmaster[10652]: 2019-09-19 18:50:10.207 UTC [10652] LOG: starting PostgreSQL 12beta4 on x86_64-pc-lin... 64-bitSep 19 18:50:10 cent7.novalocal postmaster[10652]: 2019-09-19 18:50:10.209 UTC [10652] LOG: listening on IPv6 address "::1", port 5432Sep 19 18:50:10 cent7.novalocal postmaster[10652]: 2019-09-19 18:50:10.209 UTC [10652] LOG: listening on IPv4 address "127.0.0.1", port 5432Sep 19 18:50:10 cent7.novalocal postmaster[10652]: 2019-09-19 18:50:10.214 UTC [10652] LOG: listening on Unix socket "/var/run/postgresq...L.5432"Sep 19 18:50:10 cent7.novalocal postmaster[10652]: 2019-09-19 18:50:10.229 UTC [10652] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"Sep 19 18:50:10 cent7.novalocal postmaster[10652]: 2019-09-19 18:50:10.254 UTC [10652] LOG: redirecting log output to logging collector processSep 19 18:50:10 cent7.novalocal postmaster[10652]: 2019-09-19 18:50:10.254 UTC [10652] HINT: Future log output will appear in directory "log".Sep 19 18:50:10 cent7.novalocal systemd[1]: Started PostgreSQL 12 database server.Hint: Some lines were ellipsized, use -l to show in full.
如果您有正在运行的防火墙服务,并且远程客户端应连接到数据库服务器,则允许PostgreSQL服务。
sudo firewall-cmd --add-service=postgresql --permanent sudo firewall-cmd --reload
第4步:设置PostgreSQL管理员用户的密码
设置PostgreSQL管理员用户
$ sudo su - postgres ~]$ psql -c "alter user postgres with password 'StrongPassword'" ALTER ROLE
步骤5:启用远程访问(可选)
编辑文件/var/lib/pgsql/12/data/postgresql.conf并将所有服务器的“监听地址”设置为服务器IP地址或“ *”。
listen_addresses ='192.168.10.10'
还设置PostgreSQL接受远程连接
$ sudo vim /var/lib/pgsql/12/data/pg_hba.conf # Accept from anywhere host all all 0.0.0.0/0 md5 # Accept from trusted subnet host all all 192.168.18.0/24 md5
提交更改后,重新启动数据库服务。
sudo systemctl restart postgresql-12
步骤6:安装pgAdmin 4 Web界面
pgAdmin是领先的开源功能丰富的PostgreSQL管理和开发平台,可在Linux,Unix,Mac OS X和Windows上运行。这是在CentOS上安装pgAdmin4的链接。
如何在CentOS 8 Linux上安装pgAdmin 4在CentOS 7上安装pgAdmin4
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~