PostgreSQL12安装

一、环境
系统:Centos7.9

镜像源:阿里云PostgreSQL

二、配置镜像源

创建repo镜像源文件

touch /etc/yum.repos.d/pgsql12.repo

编辑配置文件

vi /etc/yum.repos.d/pgsql12.repo

[pgdg12]
name=PostgreSQL 12 for RHEL/CentOS $releasever - $basearch
baseurl=https://mirrors.aliyun.com/postgresql/repos/yum/12/redhat/rhel-$releasever-$basearch
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/postgresql/repos/yum/RPM-GPG-KEY-PGDG
repo_gpgcheck = 1

更新yum缓存

yum makecache

有外网情况直接执行yum安装pg源
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

三、安装并配置PostgreSQL12

安装postgresql12-server

yum install postgresql12-server-12.9

检查:

[root@dev-k8s-01-6-68 ~]# rpm -qa|grep postgres
postgresql12-server-12.9-1PGDG.rhel7.x86_64
postgresql12-devel-12.9-1PGDG.rhel7.x86_64
postgresql12-12.9-1PGDG.rhel7.x86_64
postgresql12-libs-12.9-1PGDG.rhel7.x86_64

缺少postgresql12-devel安装提示 LLVM-toolset-7-clang >= 4.0.1

yum install centos-release-scl-rh
yum install llvm-toolset-7-clang

编辑服务配置 修改数据库目录位置

Environment=PGDATA=/opt/pgsql/12/data

vi /usr/lib/systemd/system/postgresql-12.service

备注:/opt根据实际情况来

初始化数据库

/usr/pgsql-12/bin/postgresql-12-setup initdb

修改配置文件 允许来自任何主机的连接

listen_addresses = '*'

vi /opt/pgsql/12/data/postgresql.conf

修改配置文件 授权主机密码连接

host all all 0.0.0.0/0 md5

vi /opt/pgsql/12/data/pg_hba.conf

启动服务

systemctl start postgresql-12.service

开机自动启动

systemctl enable postgresql-12.service

切换到postgres用户

su -l postgres

登录pg数据库

psql

无需重制密码

设置postgres密码

\password postgres

四、安装wal2json插件
yum install gcc -y

wal2json-wal2json_2_3.zip orafce-VERSION_3_8_0.zip

wal2json插件获取地址:https://github.com/eulerto/wal2json/releases/tag/wal2json_2_3

部署wal2json插件

配置变量

vim /etc/profile

export PG=/usr/pgsql-12
export PATH=$PATH:$PG/bin

unzip wal2json-wal2json_2_3.zip -d /usr/local/

cd /usr/local/

chown -R postgres.postgres wal2json-wal2json_2_3/

cd /usr/local/wal2json-wal2json_2_3/

编译

make

make install

配置postgresql.conf

vi /opt/pgsql/12/data/postgresql.conf

shared_preload_libraries = 'wal2json'
wal_level = logical
max_wal_senders = 10
max_replication_slots = 10

五、安装orafce插件
yum install openssl-devel

安装非常简单,下载源代码,进行编译
unzip orafce-VERSION_3_8_0 -d /usr/local/

cd /usr/local/orafce-VERSION_3_8_0
make all
make install

su - postgres

psql
[postgres@centos8 orafce]$ psql -c "CREATE EXTENSION orafce;"
CREATE EXTENSION

装完之后可以发现,我们就会发现有一些 Oracle软件包。

postgres=# \dn
List of schemas
Name | Owner
--------------+----------
cron | postgres
dbms_alert | postgres
dbms_assert | postgres
dbms_output | postgres
dbms_pipe | postgres
dbms_random | postgres
dbms_utility | postgres
oracle | postgres
plunit | postgres
plvchr | postgres
plvdate | postgres
plvlex | postgres
plvstr | postgres
plvsubst | postgres
public | postgres
utl_file | postgres
(16 rows)

posted @   weizongze  阅读(662)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示