1.通过二进制安装包安装 centos 7
通过这个 https://www.postgresql.org/download
选择对应的版本,就可以获得相应的安装方法,官网支持很强大。
Centos 7版本安装如下
安装PostgreSQL yum仓库
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
安装PostgreSQL:
sudo yum install -y postgresql13-server
安装扩展模块
sudo yum install -y postgresql13-contrib.x86_64
初始化数据库,设置开机启动
sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
sudo systemctl enable postgresql-13
sudo systemctl start postgresql-13
在Centos或Redhat下,默认安装上的PostgreSQL的数据目录在/var/lib/pgsql/13/data/
[root@node1 ~]# ls -l /var/lib/pgsql/13/data/
total 64
drwx------ 5 postgres postgres 38 Feb 27 01:25 base
-rw------- 1 postgres postgres 30 Feb 27 01:25 current_logfiles
drwx------ 2 postgres postgres 4096 Feb 27 01:26 global
drwx------ 2 postgres postgres 31 Feb 27 01:25 log
drwx------ 2 postgres postgres 6 Feb 27 01:25 pg_commit_ts
drwx------ 2 postgres postgres 6 Feb 27 01:25 pg_dynshmem
-rw------- 1 postgres postgres 4548 Feb 27 01:25 pg_hba.conf
-rw------- 1 postgres postgres 1636 Feb 27 01:25 pg_ident.conf
drwx------ 4 postgres postgres 65 Feb 27 03:25 pg_logical
drwx------ 4 postgres postgres 34 Feb 27 01:25 pg_multixact
drwx------ 2 postgres postgres 6 Feb 27 01:25 pg_notify
drwx------ 2 postgres postgres 6 Feb 27 01:25 pg_replslot
drwx------ 2 postgres postgres 6 Feb 27 01:25 pg_serial
drwx------ 2 postgres postgres 6 Feb 27 01:25 pg_snapshots
drwx------ 2 postgres postgres 6 Feb 27 01:25 pg_stat
drwx------ 2 postgres postgres 60 Feb 27 03:40 pg_stat_tmp
drwx------ 2 postgres postgres 17 Feb 27 01:25 pg_subtrans
drwx------ 2 postgres postgres 6 Feb 27 01:25 pg_tblspc
drwx------ 2 postgres postgres 6 Feb 27 01:25 pg_twophase
-rw------- 1 postgres postgres 3 Feb 27 01:25 PG_VERSION
drwx------ 3 postgres postgres 58 Feb 27 01:25 pg_wal
drwx------ 2 postgres postgres 17 Feb 27 01:25 pg_xact
-rw------- 1 postgres postgres 88 Feb 27 01:25 postgresql.auto.conf
-rw------- 1 postgres postgres 28017 Feb 27 01:25 postgresql.conf
-rw------- 1 postgres postgres 58 Feb 27 01:25 postmaster.opts
-rw------- 1 postgres postgres 103 Feb 27 01:25 postmaster.pid