Linux|centos7|postgresql数据库|yum和编译方式安装总结(全系版本)

一、

yum方式安装postgresql

这个是官方的yum源,包括postgresql的开发包,lib库什么的,很齐全,关键是包括pgbackrest

yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

以上这个命令呢,其实没有安装什么太多的东西,就是在/etc/yum.repos.d目录下生成了一个repo文件而已,该repo文件内容如下:

#######################################################
# PGDG Red Hat Enterprise Linux / CentOS repositories #
######################################################## PGDG Red Hat Enterprise Linux / CentOS stable common repository for all PostgreSQL versions[pgdg-common]
name=PostgreSQL common RPMs for RHEL / CentOS $releasever - $basearch
baseurl=https://download.postgresql.org/pub/repos/yum/common/redhat/rhel-$releasever-$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1# We provide extra package to support some RPMs in the PostgreSQL RPM repo, like
# consul, haproxy, etc.[pgdg-rhel7-extras]
name=Extra packages to support some RPMs in the PostgreSQL RPM repo RHEL / CentOS $releasever - $basearch
baseurl=https://download.postgresql.org/pub/repos/yum/common/pgdg-rhel$releasever-extras/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1# PGDG Red Hat Enterprise Linux / CentOS stable repositories:[pgdg15]
name=PostgreSQL 15 for RHEL / CentOS $releasever - $basearch
baseurl=https://download.postgresql.org/pub/repos/yum/15/redhat/rhel-$releasever-$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1[pgdg14]
name=PostgreSQL 14 for RHEL / CentOS $releasever - $basearch
baseurl=https://download.postgresql.org/pub/repos/yum/14/redhat/rhel-$releasever-$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1[pgdg13]
name=PostgreSQL 13 for RHEL / CentOS $releasever - $basearch
baseurl=https://download.postgresql.org/pub/repos/yum/13/redhat/rhel-$releasever-$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1[pgdg12]
name=PostgreSQL 12 for RHEL / CentOS $releasever - $basearch
baseurl=https://download.postgresql.org/pub/repos/yum/12/redhat/rhel-$releasever-$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1# PGDG RHEL / CentOS Updates Testing common repositories.[pgdg-common-testing]
name=PostgreSQL common testing RPMs for RHEL / CentOS $releasever - $basearch
baseurl=https://download.postgresql.org/pub/repos/yum/testing/common/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1# PGDG RHEL / CentOS Updates Testing repositories. (These packages should not be used in production)
# Available for 12 and above.[pgdg15-updates-testing]
name=PostgreSQL 15 for RHEL / CentOS $releasever - $basearch - Updates testing
baseurl=https://download.postgresql.org/pub/repos/yum/testing/15/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1[pgdg14-updates-testing]
name=PostgreSQL 14 for RHEL / CentOS $releasever - $basearch - Updates testing
baseurl=https://download.postgresql.org/pub/repos/yum/testing/14/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1[pgdg13-updates-testing]
name=PostgreSQL 13 for RHEL / CentOS $releasever - $basearch - Updates testing
baseurl=https://download.postgresql.org/pub/repos/yum/testing/13/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1[pgdg12-updates-testing]
name=PostgreSQL 12 for RHEL / CentOS $releasever - $basearch - Updates testing
baseurl=https://download.postgresql.org/pub/repos/yum/testing/12/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1# PGDG Red Hat Enterprise Linux / CentOS SRPM testing common repository[pgdg-source-common]
name=PostgreSQL 12 for RHEL / CentOS $releasever - $basearch - Source
baseurl=https://download.postgresql.org/pub/repos/yum/srpms/common/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1# PGDG RHEL / CentOS testing common SRPM repository for all PostgreSQL versions[pgdg-common-srpm-testing]
name=PostgreSQL common testing SRPMs for RHEL / CentOS $releasever - $basearch
baseurl=https://download.postgresql.org/pub/repos/yum/srpms/testing/common/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1# PGDG Source RPMs (SRPM), and their testing repositories:[pgdg15-source]
name=PostgreSQL 15 for RHEL / CentOS $releasever - $basearch - Source
failovermethod=priority
baseurl=https://download.postgresql.org/pub/repos/yum/srpms/15/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1[pgdg15-source-updates-testing]
name=PostgreSQL 15 for RHEL / CentOS $releasever - $basearch - Source updates testing
failovermethod=priority
baseurl=https://download.postgresql.org/pub/repos/yum/srpms/testing/15/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1[pgdg14-source]
name=PostgreSQL 14 for RHEL / CentOS $releasever - $basearch - Source
failovermethod=priority
baseurl=https://download.postgresql.org/pub/repos/yum/srpms/14/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1[pgdg14-source-updates-testing]
name=PostgreSQL 14 for RHEL / CentOS $releasever - $basearch - Source updates testing
failovermethod=priority
baseurl=https://download.postgresql.org/pub/repos/yum/srpms/testing/14/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1[pgdg13-source]
name=PostgreSQL 13 for RHEL / CentOS $releasever - $basearch - Source
failovermethod=priority
baseurl=https://download.postgresql.org/pub/repos/yum/srpms/13/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1[pgdg13-source-updates-testing]
name=PostgreSQL 13 for RHEL / CentOS $releasever - $basearch - Source updates testing
failovermethod=priority
baseurl=https://download.postgresql.org/pub/repos/yum/srpms/testing/13/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1[pgdg12-source]
name=PostgreSQL 12 for RHEL / CentOS $releasever - $basearch - Source
failovermethod=priority
baseurl=https://download.postgresql.org/pub/repos/yum/srpms/12/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1[pgdg12-source-updates-testing]
name=PostgreSQL 12 for RHEL / CentOS $releasever - $basearch - Source update testing
failovermethod=priority
baseurl=https://download.postgresql.org/pub/repos/yum/srpms/testing/12/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1# Debuginfo/debugsource packages for stable repos[pgdg15-debuginfo]
name=PostgreSQL 15 for RHEL / CentOS $releasever - $basearch - Debuginfo
baseurl=https://download.postgresql.org/pub/repos/yum/debug/15/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1[pgdg14-debuginfo]
name=PostgreSQL 14 for RHEL / CentOS $releasever - $basearch - Debuginfo
baseurl=https://download.postgresql.org/pub/repos/yum/debug/14/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1[pgdg13-debuginfo]
name=PostgreSQL 13 for RHEL / CentOS $releasever - $basearch - Debuginfo
baseurl=https://download.postgresql.org/pub/repos/yum/debug/13/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1[pgdg12-debuginfo]
name=PostgreSQL 12 for RHEL / CentOS $releasever - $basearch - Debuginfo
baseurl=https://download.postgresql.org/pub/repos/yum/debug/12/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1# Debuginfo/debugsource packages for testing repos
# Available for 12 and above.[pgdg15-updates-testing-debuginfo]
name=PostgreSQL 15 for RHEL / CentOS $releasever - $basearch - Debuginfo
baseurl=https://download.postgresql.org/pub/repos/yum/testing/debug/15/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1[pgdg14-updates-testing-debuginfo]
name=PostgreSQL 14 for RHEL / CentOS $releasever - $basearch - Debuginfo
baseurl=https://download.postgresql.org/pub/repos/yum/testing/debug/14/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1[pgdg13-updates-testing-debuginfo]
name=PostgreSQL 13 for RHEL / CentOS $releasever - $basearch - Debuginfo
baseurl=https://download.postgresql.org/pub/repos/yum/testing/debug/13/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1[pgdg12-updates-testing-debuginfo]
name=PostgreSQL 12 for RHEL / CentOS $releasever - $basearch - Debuginfo
baseurl=https://download.postgresql.org/pub/repos/yum/testing/debug/12/redhat/rhel-$releasever-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/PGDG-RPM-GPG-KEY-RHEL7
repo_gpgcheck = 1

🆗,查看这个repo文件,可以看到postgresql  12-15版本都有了,那么,postgresql数据库所有都安装,比如,lib库,开发库都安装的命令就是:

yum install postgresql12*

但此时会报错,缺少很多个核心依赖,比如llvm5.0-devel,python3-libs:

Error: Package: postgresql12-plpython3-12.18-1PGDG.rhel7.x86_64 (pgdg12)Requires: libpython3.6m.so.1.0()(64bit)
Error: Package: postgresql12-devel-12.18-1PGDG.rhel7.x86_64 (pgdg12)Requires: llvm-toolset-7-clang >= 4.0.1
Error: Package: postgresql12-llvmjit-12.18-1PGDG.rhel7.x86_64 (pgdg12)Requires: libLLVM-5.0.so()(64bit)
Error: Package: postgresql12-llvmjit-12.18-1PGDG.rhel7.x86_64 (pgdg12)Requires: llvm5.0 >= 5.0
Error: Package: postgresql12-devel-12.18-1PGDG.rhel7.x86_64 (pgdg12)Requires: llvm5.0-devel >= 5.0
Error: Package: postgresql12-plpython3-12.18-1PGDG.rhel7.x86_64 (pgdg12)Requires: python3-libs
Error: Package: postgresql12-devel-12.18-1PGDG.rhel7.x86_64 (pgdg12)Requires: perl(IPC::Run)You could try using --skip-broken to work around the problemYou could try running: rpm -Va --nofiles --nodigest

解决方案为增加阿里云的epel源和centos的scl源:

wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum install centos-release-scl-rh

阿里云的epel源和阿里云的基础源就不介绍了,主要是scl源, SCL是Software Collections的缩写,由CentOS 特别兴趣小组所维护。其收录了许多程序的新版本,例如gcc, PHP, git, python等。安装的软件可与旧版共存,包名多以rh-为前缀;它的repo文件 CentOS-SCLo-scl-rh.repo 内容如下:

# CentOS-SCLo-rh.repo
#
# Please see http://wiki.centos.org/SpecialInterestGroup/SCLo for more
# information[centos-sclo-rh]
name=CentOS-7 - SCLo rh
#baseurl=http://mirror.centos.org/centos/7/sclo/$basearch/rh/
mirrorlist=http://mirrorlist.centos.org?arch=$basearch&release=7&repo=sclo-rh
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo[centos-sclo-rh-testing]
name=CentOS-7 - SCLo rh Testing
baseurl=http://buildlogs.centos.org/centos/7/sclo/$basearch/rh/
gpgcheck=0
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo[centos-sclo-rh-source]
name=CentOS-7 - SCLo rh Sources
baseurl=http://vault.centos.org/centos/7/sclo/Source/rh/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo[centos-sclo-rh-debuginfo]
name=CentOS-7 - SCLo rh Debuginfo
baseurl=http://debuginfo.centos.org/centos/7/sclo/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

如果觉得这个源的速度比较慢,可以使用国内的清华源,上述的repo文件内容修改为如下即可:

[centos-sclo-sclo]
name=CentOS-7 - SCLo sclo
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7/sclo/$basearch/sclo/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo[centos-sclo-rh]
name=CentOS-7 - SCLo rh
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7/sclo/$basearch/rh/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

🆗,这四个源配置好后就可以非常方便的安装postgresql  12-15的版本了

那么,如果是有网的环境还可以,但如果是离线环境呢?这个也比较简单的,制作离线yum源就可以了

二、

yum 离线源的制作

以上面配置的四个yum源为基础,制作yum离线源,首先,需要创建一个任意名称的目录,存放一会拉取下来的rpm文件

其次,安装yum-utils ,以生成yumdownloader 这个工具,然后进入上面创建的目录 ,拉取rpm文件

最后,就是安装createrepo 这个工具,生成仓库信息

以上步骤都完成后,打包上述目录就可以扔到离线环境使用了,本文就以postgresql-12的离线yum安装包制作为例

安装离线yum源的rpm包下载工具

 yum install yum-utils -y

开始下载rpm包,等待下载完毕:

    mkdir postgresql-12-offlinecd postgresql-12-offlineyumdownloader postgresql12* pgbackrest --resolve

开始制作离线仓库:

  yum install createrepo -ycd postgresql-12-offline/yumdownloader createrepo --resolveyumdownloader deltarpm-3.6-3.el7.x86_64 python-deltarpm-3.6-3.el7.x86_64 deltarpm-3.6-3.el7.x86_64 python-deltarpm-3.6-3.el7.x86_64 --resolvecreaterepo postgresql-12-offline/
cd ..
tar cvjf postgresql-12-offline.tar.gz postgresql-12-offline

制作完毕后,tar包保存后,在其它服务器上挂载这个仓库就可以离线安装postgresql12和pgbackrest了,挂载示例如下:

1、

上述的离线包上传到服务器上,然后解压,解压后的目录移动到/opt目录下

[root@centos7 ~]# tar xf postgresql-12-offline.tar.gz 
[root@centos7 ~]# du -sh postgresql-12-offline
292M	postgresql-12-offline
[root@centos7 ~]# mv postgresql-12-offline /opt/

2、

保留本地yum源,在本地yum内编辑如下内容:

[local]
nmae=local
baseurl=file:///mnt/
enable=1
gpgcheck=0
[pgoffline]
name=pgoffline
baseurl=file:///opt/postgresql-12-offline
enable=1
gpgcheck=0

3、

安装postgresql-12

[root@centos7 ~]# yum install postgresql12-server postgresql12-lib postgresql12-devel postgresql12-contrib postgresql12-tcl postgresql12-odbc-y

4、

安装pgbackrest

[root@centos7 ~]# yum install pgbackrest -y

以上就是离线安装postgresql12的过程,其它版本的postgresql基本是一样的,yumdownload 后面的版本改一下就可以了

下面说一说数据库初始化以及简单的配置问题

三、

postgresql12-server的初始化和简单配置

1、

创建postgresql的数据存储目录

mkdir -p /data/pgsql/data

2、

配置环境变量,这些变量用于初始化,一般写入/etc/profile 或者 /etc/bashrc 这两个文件的末尾,任选一个就可以了

PGDATA=/data/pgsql/data
export PGDATA
PGHOME=/data/pgsql
export PGHOME
PATH=$PATH:$PGHOME/bin:$PGDATA
export PATH  PGHOME PGDATA

3、

postgresql数据库初始化

[root@centos7 system]# /usr/pgsql-12/bin/postgresql-12-setup initdb
Initializing database ... OK

4、

移动刚初始化的数据文件到/data/pgsql/data目录下,并更改配置文件和启动脚本:

vim /data/pgsql/data/postgresql.conf
主要是以下几项:
data_directory = '/data/pgsql/data'
listen_addresses = '*' 
port = 5432                       
max_connections = 100 vim /usr/lib/systemd/system/postgresql-12.service
主要是这个:
Environment=PGDATA=/data/pgsql/data/

5、

重新赋权,然后启动数据库

chown -Rf postgres. /data/pgsql/
chmod -Rf 0750 /data/pgsql/data/
systemctl daemon-reload
systemctl start postgresql-12 &&systemctl enable postgresql-12

6、

查看数据库状态是否正常:

[root@centos7 data]# 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 Sun 2024-03-17 05:07:42 CST; 5min agoDocs: https://www.postgresql.org/docs/12/static/Main PID: 2066 (postmaster)CGroup: /system.slice/postgresql-12.service├─2066 /usr/pgsql-12/bin/postmaster -D /data/pgsql/data/├─2067 postgres: logger   ├─2069 postgres: checkpointer   ├─2070 postgres: background writer   ├─2071 postgres: walwriter   ├─2072 postgres: autovacuum launcher   ├─2073 postgres: stats collector   └─2074 postgres: logical replication launcher   Mar 17 05:07:42 centos7 systemd[1]: Starting PostgreSQL 12 database server...
Mar 17 05:07:42 centos7 postmaster[2066]: 2024-03-17 05:07:42.320 CST [2066] LOG:  starting PostgreSQL 12.18 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
Mar 17 05:07:42 centos7 postmaster[2066]: 2024-03-17 05:07:42.320 CST [2066] LOG:  listening on IPv4 address "0.0.0.0", port 5432
Mar 17 05:07:42 centos7 postmaster[2066]: 2024-03-17 05:07:42.320 CST [2066] LOG:  listening on IPv6 address "::", port 5432
Mar 17 05:07:42 centos7 postmaster[2066]: 2024-03-17 05:07:42.321 CST [2066] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
Mar 17 05:07:42 centos7 postmaster[2066]: 2024-03-17 05:07:42.321 CST [2066] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
Mar 17 05:07:42 centos7 postmaster[2066]: 2024-03-17 05:07:42.327 CST [2066] LOG:  redirecting log output to logging collector process
Mar 17 05:07:42 centos7 postmaster[2066]: 2024-03-17 05:07:42.327 CST [2066] HINT:  Future log output will appear in directory "log".
Mar 17 05:07:42 centos7 systemd[1]: Started PostgreSQL 12 database server.

yum安装的postgresql,数据库日志是直接开启的,省去了不少麻烦,剩下的就是配置pg_hba.conf 文件开启安全访问这些了,就不在此废话了

注意:由于前面安装了postgresql12-contrib,因此,所有官方插件是可以直接使用的,非常的方便,例如pg_trgm 这个插件,就可以直接安装了:

psql (12.18)
Type "help" for help.postgres=# create extension pg_trgm;
CREATE EXTENSION

查询有哪些可用插件:

SELECT name FROM pg_available_extensions;

输出如下:

hstore
plpgsql
hstore_plperl
adminpack
hstore_plperlu
amcheck
cube
insert_username
autoinc
bloom
earthdistance
intagg
btree_gin
file_fdw
fuzzystrmatch
btree_gist
intarray
citext
dblink
jsonb_plperl
dict_xsyn
lo
dict_int
jsonb_plperlu
isn
ltree
moddatetime
pgrowlocks
pageinspect
pg_trgm
tcn
pgstattuple
pg_buffercache
xml2
postgres_fdw
pg_freespacemap
pg_prewarm
pg_visibility
refint
pgcrypto
pg_stat_statements
seg
sslinfo
tablefunc
tsm_system_rows
tsm_system_time
unaccent
uuid-ossp

yum安装方式确实是非常非常的方便的哦

四、

postgresql的编译安装

postgresql的编译安装就比较简单了,PostgreSQL: File Browser

1、在这个官方网站下载自己喜欢的版本,然后上传到服务器上,本例中我下载的是postgresql-12.5.tar.bz2

将此文件随便放置到哪都可以,按规范是/usr/local/src目录下,进入此目录,解压上传的源码压缩包

[root@centos7 ~]# mv postgresql-12.5.tar.bz2 /usr/local/src/
[root@centos7 ~]# cd !$
cd /usr/local/src/
[root@centos7 src]# ls
postgresql-12.5.tar.bz2
[root@centos7 src]# pwd
/usr/local/src
[root@centos7 src]# ls
postgresql-12.5.tar.bz2
[root@centos7 src]# tar xf postgresql-12.5.tar.bz2 
[root@centos7 src]# ls
postgresql-12.5  postgresql-12.5.tar.bz2

2、

进入解压目录,创建预编译用的目录,进入这个目录:

[root@centos7 src]# cd postgresql-12.5
[root@centos7 postgresql-12.5]# mkdir build
[root@centos7 postgresql-12.5]# cd build/

3、

查看编译帮助

[root@centos7 build]# ../configure --help
`configure' configures PostgreSQL 12.5 to adapt to many kinds of systems.Usage: ../configure [OPTION]... [VAR=VALUE]...To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.Defaults for the options are specified in brackets.Configuration:-h, --help              display this help and exit--help=short        display options specific to this package--help=recursive    display the short help of all the included packages-V, --version           display version information and exit-q, --quiet, --silent   do not print `checking ...' messages--cache-file=FILE   cache test results in FILE [disabled]-C, --config-cache      alias for `--cache-file=config.cache'-n, --no-create         do not create output files--srcdir=DIR        find the sources in DIR [configure dir or `..']Installation directories:--prefix=PREFIX         install architecture-independent files in PREFIX[/usr/local/pgsql]--exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX[PREFIX]By default, `make install' will install all the files in
`/usr/local/pgsql/bin', `/usr/local/pgsql/lib' etc.  You can specify
an installation prefix other than `/usr/local/pgsql' using `--prefix',
for instance `--prefix=$HOME'.
、、、、、、、、、、后面的略略略

可以看到,可执行文件可以指定到自己喜欢的位置,也就是 --exec-prefix=EPREFIX  ,比较有意思的一个选项是--with-pgport=PORTNUM,这个可以初始化数据库后,就指定的端口了

编译的依赖不多,大概有这些:

yum install bzip2 bzip2-devel zlib zlib-devel readline readline-devel openssl openssl-devel autoconf gcc gcc-c++ llvm llvm-devel perl perl-devel systemd-devel libbsd-devel  pam-deve perl-ExtUtils-Embed  tcl tcl-devel python-devel -y

4、

预编译阶段

根据上面的编译帮助,那么,比较全的一个编译命令是:

../configure --prefix=/opt/pgsql --exec-prefix=/opt/pgsqlb_exec --with-pgport=15433  --with-gssapi --with-tcl --with-perl --with-python  --with-icu --with-pam --with-bsd-auth --with-bonjou --with-systemd --with-includes=/opt/pgsql/includes  --with-libs=/opt/pgsql/libs

5、

编译阶段和编译安装阶段

make && make install

编译完成后,配置环境变量,然后初始化,修改配置文件这些都和yum安装基本一样,就不废话了

库什么的都按编译命令生成了,例如include,如果不指定编译,这些目录是会默认和bin什么的在一起的

[root@centos7 pgsql]# pwd
/opt/pgsql
[root@centos7 pgsql]# ls
include  share

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/750541.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Luckysheet + Exceljs:H5实现Excel在线编辑、导入、导出及上传服务器的示例代码(完整版demo)

创建xeditor.html <!DOCTYPE html> <html><head><meta charset"UTF-8" /><title>Hello World!</title><!-- <link relstylesheet href./luckysheet/plugins/css/pluginsCss.css /><link relstylesheet href./luck…

【 代码随想录算法训练营第二十四天 | LeetCode77. 组合 】

代码随想录算法训练营第二十四天 | LeetCode77. 组合 一、77. 组合 解题代码C&#xff1a; class Solution { private:vector<vector<int>> result; // 存放符合条件结果的集合vector<int> path; // 用来存放符合条件结果void backtracking(int n, int k, …

idea找不到或无法加载主类

前言 今天在运行项目的时候突然出了这样一个错误&#xff1a;IDEA 错误 找不到或无法加载主类,相信只要是用过IDEA的朋友都 遇到过它吧&#xff0c;但是每次遇到都是一顿焦头烂额、抓耳挠腮、急赤白咧&#xff01;咋整呢&#xff1f;听我给你吹~ 瞧我这张嘴~ 问题报错 找不…

vscode通过多个跳板机连接目标机(两种方案亲测成功)

1、ProxyJump&#xff08;推荐使用&#xff09; 需要OpenSSH 7.3以上版本才可使用&#xff0c;可用下列命令查看&#xff1a; ssh -V ProxyJump命令行使用方法 ssh -J [email protected]:port1,[email protected]:port2 一层跳板机&#xff1a; ssh dst_usernamedst_ip -…

基于Keras的模型剪枝(Pruning)

目录 设置在不修剪的情况下为 MNIST 训练模型评估基线测试准确性并保存模型以供以后使用预训练模型 Pruning根据 baseline 训练和评估模型Create 3x smaller modelsCreate a 10x smaller model from combining pruning and quantizationSee persistence of accuracy from TF to…

ARP和DDOS攻击防御介绍

学习目标&#xff1a; 1. 如何利用ARP漏洞进行攻击&#xff1f; 2. 怎样有效地防御ARP攻击&#xff1f; 3. 如何应对DDOS攻击&#xff1f; ARP攻击如何产生&#xff1f; ARP如何进行有效防御&#xff1f; ARP基础工作原理&#xff1a; 交换机会根据mac地址表&#xff0c;进行转…

JAVA中类,方法,构造函数,对象区别

在JAVA中&#xff0c;类&#xff08;Class&#xff09;是一个蓝图或模板&#xff0c;用于描述如何创建对象。它定义了对象的属性和方法。 方法&#xff08;Method&#xff09;是类或对象中可执行的操作。它用于执行特定的任务或操作。方法定义在类中&#xff0c;可以被对象调用…

C++之priority_queue实现

闲话少说&#xff0c;代码起步&#xff01;&#xff01;&#xff01; #pragma oncenamespace cx {template<class T,class containervector<T>, class Compare less<T>>class priority_queue{public:void adjust_up(int child){Compare com;int parent (c…

pytorch 入门基础知识一(Pytorch 01)

一 深度学习基础相关 深度学习三个主要的方向&#xff1a;计算机视觉&#xff0c;自然语言&#xff0c;语音识别。 机器学习核心组件&#xff1a;1 数据集(data)&#xff0c;2 前向传播的model(net)&#xff0c;3 目标函数(loss)&#xff0c; 4 调整模型参数和优化函数的算法…

【STM32定时器(一)内部时钟定时与外部时钟 TIM小总结】

STM32 TIM详解 TIM介绍定时器类型基本定时器通用定时器高级定时器常用名词时序图预分频时序计数器时序图 定时器中断配置图定时器定时 代码调试代码案例1代码案例2 TIM介绍 定时器&#xff08;Timer&#xff09;是微控制器中的一个重要模块&#xff0c;用于生成定时和延时信号…

mybatis源码阅读系列(一)

源码下载 mybatis 初识mybatis MyBatis 是一个优秀的持久层框架&#xff0c;它支持定制化 SQL、存储过程以及高级映射。MyBatis 避免了几乎所有的 JDBC 代码和手动设置参数以及获取结果集。MyBatis 可以使用简单的 XML 或注解用于配置和原始映射&#xff0c;将接口和 Java 的…

什么是软件开发?软件开发阶段划分是什么?并以LabVIEW为例进行说明

软件开发是一种创建、设计、编码、测试和维护应用程序、框架或其他软件组件的过程。它涉及从理解需求到设计、实现、测试、部署和最终维护的全过程。软件开发可以用来创建新的软件应用、系统软件、游戏、或开发网络应用等。 软件开发过程通常可以分为以下几个阶段&#xff1a;…

[蓝桥杯 2021 省 AB2] 完全平方数

题目链接 [蓝桥杯 2021 省 AB2] 完全平方数 题目描述 一个整数 a a a 是一个完全平方数&#xff0c;是指它是某一个整数的平方&#xff0c;即存在一个 整数 b b b&#xff0c;使得 a b 2 a b^2 ab2。 给定一个正整数 n n n&#xff0c;请找到最小的正整数 x x x&#…

基于YOLOv8/YOLOv7/YOLOv6/YOLOv5的自动驾驶目标检测系统详解(深度学习+Python代码+PySide6界面+训练数据集)

摘要&#xff1a;开发自动驾驶目标检测系统对于提高车辆的安全性和智能化水平具有至关重要的作用。本篇博客详细介绍了如何运用深度学习构建一个自动驾驶目标检测系统&#xff0c;并提供了完整的实现代码。该系统基于强大的YOLOv8算法&#xff0c;并对比了YOLOv7、YOLOv6、YOLO…

相机与相机模型(针孔/鱼眼/全景相机)

本文旨在较为直观地介绍相机成像背后的数学模型&#xff0c;主要的章节组织如下&#xff1a; 第1章用最简单的针孔投影模型为例讲解一个三维点是如何映射到图像中的一个像素 第2章介绍除了针孔投影模型外其他一些经典投影模型&#xff0c;旨在让读者建立不同投影模型之间的建模…

RabbitMQ高级-高级特性

1.消息可靠性传递 在使用RabbitMQ的时候&#xff0c;作为消息发送方希望杜绝任何消息丢失或者投递失败场景。RabbitMQ为我们提供了两种方式来控制消息的投递可靠性模式 1.confirm 确认模式 确认模式是由exchange决定的 2.return 退回模式 回退模式是由routing…

LRC转SRT

最近看到一首很好的英文MTV原版&#xff0c;没又字幕&#xff0c;自己找字幕&#xff0c;只找到LRC&#xff0c;ffmpeg不支持LRC&#xff0c;网上在线转了SRT。 Subtitle Converter | Free tool | GoTranscript 然后用 ffmpeg 加字幕 ffmpeg -i LoveMeLikeYouDo.mp4 -vf sub…

nginx配置websocket

非加密的WebSocket连接。 #ws# 这是一个ws配置示例&#xff0c;表示使用非加密的WebSocket连接。 server { listen 8080; server_name example.com; location /websocket { proxy_pass http://backend-server; proxy_http_version 1.1; proxy_set_header Upgrade $http…

PyTorch学习笔记之基础函数篇(四)

文章目录 2.8 torch.logspace函数讲解2.9 torch.ones函数2.10 torch.rand函数2.11 torch.randn函数2.12 torch.zeros函数 2.8 torch.logspace函数讲解 torch.logspace 函数在 PyTorch 中用于生成一个在对数尺度上均匀分布的张量&#xff08;tensor&#xff09;。这意味着张量中…

【vue2源码】模版编译

文章目录 一、mount 基本流程二、执行 $mount 方法三、模版编译1、入口代码2、parse2.1 parseHTML2.2 parseText 3、generategenElement 函数 4、createCompileToFunctionFn 4、mountComponent 一、mount 基本流程 在执行 _init (new Vue时) 的方法中&#xff0c;调用了 vm.$m…