Debian 10 | Debian 9 system installation PostgreSQL 13 detailed process

PostgreSQL is an open source, powerful, resilient and fault-tolerant relational database management system that can provide support for many mission-critical applications. The PostgreSQL database is based on POSTGRES 4.2. As of now, the latest stable version of PostgreSQL is version 13. All new features, improvements and bug fix reports about PostgreSQL 13 can be found on the official release page.

Here are some notable new features of PostgreSQL 13:

  • Improvements brought by deduplication of B-tree index entries-space saving and performance improvement
  • Queries that use aggregate tables or partitioned tables can improve performance.
  • Incremental sort
  • Better query plans when using extended statistics
  • Parallel cleaning of indexes

Update the system and its software packages

If you follow the next step of the procedure in this article, you should get a runnable and runnable PostgreSQL 13 on the Debian 10 | Debian 9 system. It is recommended to update the Linux system and all installed packages before proceeding.

sudo apt update
sudo apt -y upgrade

Restart the server.

sudo reboot

Add PostgreSQL 12 repository

Before configuring the APT repository, import the GPG key used to sign the software package and add the PostgreSQL 12 repository. The command is as follows:

sudo apt update
sudo apt -y install gnupg2
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

Organize the created file to check its content:

$ cat /etc/apt/sources.list.d/pgdg.list
deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main

Install PostgreSQL 13 on Debian 10 | Debian 9

Now that the repository has been successfully added, just update the package list here, and install PostgreSQL 13 on the Debian 10 / Debian 9 system. The server can run in a cloud server, a local LAMP environment, or any other effective virtualized environment.

sudo apt update

Finally, start PostgreSQL 13 on Debian 10 | Debian 9 system:

sudo apt -y install postgresql-13 postgresql-client-13

Start the database server with the following command:

sudo pg_ctlcluster 13 main start

Confirm the service status and the profile being used.

$ sudo pg_ctlcluster 13 main status
pg_ctl: server is running (PID: 4209)
/usr/lib/postgresql/13/bin/postgres "-D" "/var/lib/postgresql/13/main" "-c" "config_file=/etc/postgresql/13/main/postgresql.conf"

Of course, you can also use the systemctl command to check the service status.

$ systemctl status [email protected]
[email protected] - PostgreSQL Cluster 13-main
Loaded: loaded (/lib/systemd/system/[email protected]; enabled-runtime; vendor preset: enabled)
Active: active (running) since Fri 2020-10-30 11:27:01 CET; 2min 11s ago
Main PID: 4209 (postgres)
Tasks: 7 (limit: 4580)
Memory: 18.1M
CGroup: /system.slice/system-postgresql.slice/[email protected]
├─4209 /usr/lib/postgresql/13/bin/postgres -D /var/lib/postgresql/13/main -c config_file=/etc/postgresql/13/main/postgresql.conf
├─4211 postgres: 13/main: checkpointer
├─4212 postgres: 13/main: background writer
├─4213 postgres: 13/main: walwriter
├─4214 postgres: 13/main: autovacuum launcher
├─4215 postgres: 13/main: stats collector
└─4216 postgres: 13/main: logical replication launcher

Oct 30 11:26:59 debian systemd[1]: Starting PostgreSQL Cluster 13-main...
Oct 30 11:27:01 debian systemd[1]: Started PostgreSQL Cluster 13-main.

Start the PostgreSQL prompt with the following command:

$ sudo su - postgres
postgres@debian:~$ psql
psql (13.0 (Debian 13.0-1.pgdg100+1))
Type "help" for help.

postgres=#

Perform test operations:

postgres=# exit
postgres@debian:~$ createuser c4geeks
postgres@debian:~$ createdb testdb -O c4geeks

postgres@debian:~$ psql -l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
testdb | c4geeks | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
(4 rows)

Connect to the database:

postgres@debian:~$ psql testdb
psql (13.0 (Debian 13.0-1.pgdg100+1))
Type "help" for help.

testdb=#

Set user password:

testdb=# alter user c4geeks with password 'StrongDBPassw0rd';
ALTER ROLE

Finally, if you want to delete the database, you can execute the command:

testdb=# \q
postgres@debian:~$ dropdb testdb

At this point, the process of installing PostgreSQL 13 on Debian 10 | Debian 9 systems has been completed. Friends who need to install can refer to the above process for operation settings.

Note: The content of the above article refers to the host www.idccoupon.com, the content is for reference only. If you have any questions, welcome to discuss together.

Guess you like

Origin blog.51cto.com/14345315/2546406