- YUM Installation
- Contents
- Instructions
- Configure your YUM repository
- Install PGDG Repo RPM and PostgreSQL
- Post-installation commands
- Data Directory
- Initialize
- Startup
- Control service
- Removing
- Support
- Русские Блоги
- 2. Удалить
- 3. Установите последнюю версию
- 3.1 Установить репозиторий PostgreSQL Yum
- 3.2 Установить PostgreSQL
- Удаление postgresql linux centos
YUM Installation
PostgreSQL can be installed using RPMs (binary) or SRPMs (source) managed by YUM or DNF . This is available for the following Linux distributions (both 32- and 64-bit platforms; for the current release and prior release or two):
- Fedora
- Red Hat Enterprise Linux
- CentOS
- Scientific Linux (EOLed)
- Oracle Enterprise Linux
See links from the main repository, http://yum.postgresql.org:
Contents
Instructions
Configure your YUM repository
Locate and edit your distributions .repo file, located:
- On Fedora: /etc/yum.repos.d/fedora.repo and /etc/yum.repos.d/fedora-updates.repo, [fedora] sections
- On CentOS: /etc/yum.repos.d/CentOS-Base.repo, [base] and [updates] sections
- On Red Hat: /etc/yum/pluginconf.d/rhnplugin.conf[main] section
To the section(s) identified above, you need to append a line (otherwise dependencies might resolve to the postgresql supplied by the base repository):
Install PGDG Repo RPM and PostgreSQL
Other packages can be installed according to your needs.
Post-installation commands
After installing the packages, a database needs to be initialized and configured.
In the commands below, the value of will vary depending on the version of PostgreSQL used.
For PostgreSQL versions from 10 and above, the includes the major version of PostgreSQL, e.g., 12
For PostgreSQL versions from 9.4 to 9.6, the includes the major.minor version of PostgreSQL, e.g., 9.6
Data Directory
The PostgreSQL data directory contains all of the data files for the database. The variable PGDATA is used to reference this directory.
The default data directory is:
Initialize
The first command (only needed once) is to initialize the database in PGDATA.
For RHEL/CentOS 7, 8, and Fedora 30 and above:
If the previous command did not work, try directly calling the setup binary, located in a similar naming scheme:
/usr/pgsql-y.x/bin/postgresqlyx-setup initdb
For versions 10 and above:
/usr/pgsql-12/bin/postgresql-12-setup initdb (Notice the extra dash before major version)
/usr/pgsql-9.6/bin/postgresql96-setup initdb
service postgresql-9.6 initdb
Startup
If you want PostgreSQL to start automatically when the OS starts, do the following:
In RHEL 7+, and Fedora 30+ try:
systemctl enable postgresql-12.service
In RHEL 6 and PostgreSQL 12:
chkconfig postgresql-12 on
Control service
To control the database service, use:
With RHEL/CentOS 7, 8 , and Fedora 30:
systemctl enable postgresql-12.service systemctl start postgresql-12.service
- start : start the database
- stop : stop the database
- restart : stop/start the database; used to read changes to core configuration files
- reload : reload pg_hba.conf file while keeping database running
service postgresql-12 start
Removing
yum erase postgresql12* or dnf remove postgresql12* for RHEL 8 and Fedora 30+
Or remove individual packages as desired.
Support
Русские Блоги
Команда установки Yum по умолчанию выглядит следующим образом:
Эта команда устанавливает более низкие версии PostgreSQL 8.4, конкретный процесс выглядит следующим образом:
[[email protected] ~]# yum install postgresql Loaded plugins: fastestmirror, security Determining fastest mirrors * base: mirrors.163.com * extras: mirrors.163.com * updates: mirrors.163.com base | 3.7 kB 00:00 extras | 3.3 kB 00:00 extras/primary_db | 20 kB 00:00 updates | 3.4 kB 00:00 updates/primary_db | 3.1 MB 00:00 Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package postgresql.i686 0:8.4.20-8.el6_9 will be installed --> Processing Dependency: postgresql-libs(x86-32) = 8.4.20-8.el6_9 for package: postgresql-8.4.20-8.el6_9.i686 --> Processing Dependency: libpq.so.5 for package: postgresql-8.4.20-8.el6_9.i686 --> Running transaction check ---> Package postgresql-libs.i686 0:8.4.20-8.el6_9 will be installed --> Finished Dependency Resolution Dependencies Resolved =============================================================================================================================== Package Arch Version Repository Size =============================================================================================================================== Installing: postgresql i686 8.4.20-8.el6_9 base 2.6 M Installing for dependencies: postgresql-libs i686 8.4.20-8.el6_9 base 206 k Transaction Summary =============================================================================================================================== Install 2 Package(s) Total download size: 2.8 M Installed size: 14 M Is this ok [y/N]: y Downloading Packages: (1/2): postgresql-8.4.20-8.el6_9.i686.rpm | 2.6 MB 00:00 (2/2): postgresql-libs-8.4.20-8.el6_9.i686.rpm | 206 kB 00:00 ------------------------------------------------------------------------------------------------------------------------------- Total 1.8 MB/s | 2.8 MB 00:01 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : postgresql-libs-8.4.20-8.el6_9.i686 1/2 Installing : postgresql-8.4.20-8.el6_9.i686 2/2 Verifying : postgresql-8.4.20-8.el6_9.i686 1/2 Verifying : postgresql-libs-8.4.20-8.el6_9.i686 2/2 Installed: postgresql.i686 0:8.4.20-8.el6_9 Dependency Installed: postgresql-libs.i686 0:8.4.20-8.el6_9 Complete!
2. Удалить
Если мы хотим установить последнюю версию PostgreSQL, эта команда, очевидно, не соответствует нашим требованиям. Удалите предыдущую версию PostgreSQL 8.4, команда выглядит следующим образом:
Конкретный процесс выглядит следующим образом:
[[email protected] ~]# yum remove postgresql* Loaded plugins: fastestmirror, security Setting up Remove Process Resolving Dependencies --> Running transaction check ---> Package postgresql.i686 0:8.4.20-8.el6_9 will be erased ---> Package postgresql-libs.i686 0:8.4.20-8.el6_9 will be erased --> Finished Dependency Resolution Dependencies Resolved =============================================================================================================================== Package Arch Version Repository Size =============================================================================================================================== Removing: postgresql i686 8.4.20-8.el6_9 @base 14 M postgresql-libs i686 8.4.20-8.el6_9 @base 614 k Transaction Summary =============================================================================================================================== Remove 2 Package(s) Installed size: 14 M Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Erasing : postgresql-8.4.20-8.el6_9.i686 1/2 Erasing : postgresql-libs-8.4.20-8.el6_9.i686 2/2 Verifying : postgresql-8.4.20-8.el6_9.i686 1/2 Verifying : postgresql-libs-8.4.20-8.el6_9.i686 2/2 Removed: postgresql.i686 0:8.4.20-8.el6_9 postgresql-libs.i686 0:8.4.20-8.el6_9 Complete!
3. Установите последнюю версию
3.1 Установить репозиторий PostgreSQL Yum
[[email protected] ~]# rpm -i http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/pgdg-centos92-9.2-8.noarch.rpm
3.2 Установить PostgreSQL
[[email protected] ~]# yum install postgresql92-server postgresql92-contrib Loaded plugins: fastestmirror, security Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.163.com * updates: mirrors.163.com pgdg92 | 4.1 kB 00:00 pgdg92/primary_db | 131 kB 00:00 Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package postgresql92-contrib.i686 0:9.2.24-5PGDG.rhel6 will be installed --> Processing Dependency: postgresql92 = 9.2.24 for package: postgresql92-contrib-9.2.24-5PGDG.rhel6.i686 --> Processing Dependency: libpq.so.5 for package: postgresql92-contrib-9.2.24-5PGDG.rhel6.i686 --> Processing Dependency: libossp-uuid.so.16 for package: postgresql92-contrib-9.2.24-5PGDG.rhel6.i686 ---> Package postgresql92-server.i686 0:9.2.24-5PGDG.rhel6 will be installed --> Running transaction check ---> Package postgresql92.i686 0:9.2.24-5PGDG.rhel6 will be installed ---> Package postgresql92-libs.i686 0:9.2.24-5PGDG.rhel6 will be installed ---> Package uuid.i686 0:1.6.1-10.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved =============================================================================================================================== Package Arch Version Repository Size =============================================================================================================================== Installing: postgresql92-contrib i686 9.2.24-5PGDG.rhel6 pgdg92 444 k postgresql92-server i686 9.2.24-5PGDG.rhel6 pgdg92 3.9 M Installing for dependencies: postgresql92 i686 9.2.24-5PGDG.rhel6 pgdg92 996 k postgresql92-libs i686 9.2.24-5PGDG.rhel6 pgdg92 198 k uuid i686 1.6.1-10.el6 base 54 k Transaction Summary =============================================================================================================================== Install 5 Package(s) Total download size: 5.6 M Installed size: 23 M Is this ok [y/N]: y Downloading Packages: (1/5): postgresql92-9.2.24-5PGDG.rhel6.i686.rpm | 996 kB 00:01 (2/5): postgresql92-contrib-9.2.24-5PGDG.rhel6.i686.rpm | 444 kB 00:00 (3/5): postgresql92-libs-9.2.24-5PGDG.rhel6.i686.rpm | 198 kB 00:00 (4/5): postgresql92-server-9.2.24-5PGDG.rhel6.i686.rpm | 3.9 MB 00:01 (5/5): uuid-1.6.1-10.el6.i686.rpm | 54 kB 00:00 ------------------------------------------------------------------------------------------------------------------------------- Total 959 kB/s | 5.6 MB 00:05 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Warning: RPMDB altered outside of yum. Installing : postgresql92-libs-9.2.24-5PGDG.rhel6.i686 1/5 Installing : postgresql92-9.2.24-5PGDG.rhel6.i686 2/5 Installing : uuid-1.6.1-10.el6.i686 3/5 Installing : postgresql92-contrib-9.2.24-5PGDG.rhel6.i686 4/5 Installing : postgresql92-server-9.2.24-5PGDG.rhel6.i686 5/5 Verifying : postgresql92-9.2.24-5PGDG.rhel6.i686 1/5 Verifying : postgresql92-server-9.2.24-5PGDG.rhel6.i686 2/5 Verifying : postgresql92-contrib-9.2.24-5PGDG.rhel6.i686 3/5 Verifying : uuid-1.6.1-10.el6.i686 4/5 Verifying : postgresql92-libs-9.2.24-5PGDG.rhel6.i686 5/5 Installed: postgresql92-contrib.i686 0:9.2.24-5PGDG.rhel6 postgresql92-server.i686 0:9.2.24-5PGDG.rhel6 Dependency Installed: postgresql92.i686 0:9.2.24-5PGDG.rhel6 postgresql92-libs.i686 0:9.2.24-5PGDG.rhel6 uuid.i686 0:1.6.1-10.el6 Complete!
Удаление postgresql linux centos
The purpose of uninstalling PostgreSQL on CentOS is to remove the PostgreSQL software and all associated components from the system. There could be several reasons to uninstall PostgreSQL, such as upgrading or downgrading with different versions, reinstalling, releasing disk space, and many more.
This article will teach the step-by-step procedure to uninstall PostgreSQL from CentOS.
— How to Uninstall PostgreSQL on CentOS?
— Stop the PostgreSQL Service
— Remove the PostgreSQL Package
— Remove the PostgreSQL Data Directory
— Remove the PostgreSQL User
How to Uninstall PostgreSQL on CentOS?
Uninstalling PostgreSQL on CentOS refers to the process of removing PostgreSQL software and all associated components, such as the data directory, configuration files, and user accounts, from a CentOS system.
To uninstall PostgreSQL on CentOS, follow the below steps:
Step 1: Stop the PostgreSQL Service
Before users uninstall PostgreSQL, users need to stop the PostgreSQL service. For this, run the following command:
$ systemctl stop postgresql
Step 2: Remove the PostgreSQL Package
Once the service has stopped, remove the PostgreSQL package using the “yum” package manager. To do this, run the following command:
$ sudo yum remove postgresql-server postgresql-contrib
This command removes the PostgreSQL server and the contrib package.
Step 3: Remove the PostgreSQL Data Directory
After removing the package, users need to remove the PostgreSQL data directory. By default, the data directory is located at “/var/lib/pgsql/data”. To remove this directory and its contents execute the following command:
$ sudo rm -rf /var/lib/pgsql/data
Step 4: Remove the PostgreSQL User
Finally, users need to remove the PostgreSQL user. For this, run the below command as the root user:
This command removes the PostgreSQL user from the system.
To uninstall PostgreSQL from CentOS, execute the “yum remove postgresql-server postgresql-contrib” command. It removes all the associated packages with the dependencies. Users can also remove the PostgreSQL data directory by running the “sudo rm -rf /var/lib/pgsql/data” command in the terminal. This article has presented step-by-step guidelines to uninstall PostgreSQL from CentOS.