进入postgresql安装文件rpm所在文件夹
需要安装centos-release-scl-rh包。
yum install centos-release-scl-rh
然而再执行yum提示
Cannot find a valid baseurl for repo: centos-sclo-rh/x86 64
原因为centos 7 仓库已经于2024/6/30终止支持,需要替换为如下目录:
解决办法
1、重命名原来的文件
cd /etc/yum.repos.d/
mv CentOS-SCLo-scl.repo CentOS-SCLo-scl.repo.bak
mv CentOS-SCLo-scl-rh.repo CentOS-SCLo-scl-rh.repo.bak
2、替换源
2.1替换为官方存档源
[centos-sclo-rh]
name=CentOS-7 - SCLo rh
baseurl=http://vault.centos.org/centos/7/sclo/$basearch/rh/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
2.2或者替换为阿里云源
vim CentOS-SCLo-scl-rh.repo
粘贴以下内容[centos-sclo-rh]
name=CentOS-7 - SCLo rh
baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/rh/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
3.更新yum缓存
1. yum clean all ##清除
2. yum makecache ##生成缓存
安装pg11
yum localinstall *.rpm
pg数据库安装成功。
安装扩展
安装uuid rpm包
yum -y install e2fsprogs-devel uuid-devel libuuid-devel
yum -y install libossp*
安装pg_pathman_11
进入pg_pathman安装rpm目录
cd /data460/pg_pathman_11
ll -h
yum -y localinstall *.rpm
查看插件目录
cd /usr/pgsql-11/lib
要的插件都在
其中pg_stat_statements插件为自带。为了方便维护,编辑环境脚本pg1117.sh
Postgres用户操作
su - postgres
环境切换脚本pg1117.sh
为以下内容
#!/bin/bash
# User specific environment and startup programs
export PGPORT=5018
export PGDATA=/data460/pgsql/data
export LANG=en_US.utf8
export PGHOME=/usr/pgsql-11
export LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH
export PATH=$PGHOME/bin:/usr/bin:/usr/local/sbin:
export MANPATH=$PGHOME/share/man:$MANPATH
执行
source pg1117.sh
日常维护
切换用户 su - postgres
执行环境变量 source pg1117.sh
启动 pg_ctl start
停止 pg_ctl stop
查看状态 pg_controldata