CentOS7安装PostgreSQL 14

news/2024/7/9 23:17:25 标签: postgresql, 数据库

文章目录

  • 1.下载离线安装包
  • 2. 依赖包
    • 判断有没有安装`libicu`依赖
  • 3.上传到服务器
  • 4.按顺序安装
  • 5.安装后操作
    • 5.1初始化数据库
    • 5.2修改配置文件
    • 5.3开放允许访问 ip
      • 5.3.1放行防火墙端口
    • 5.4重启服务
    • 5.5其他命令
    • 5.6 配置用户
      • 5.6.1创建 `test` 用户
      • 5.6.2赋予超管权限

1.下载离线安装包

下载链接 PostgreSQL PGDG 14 Updates RPMs
在这里插入图片描述
依次下载下面三种文件
在这里插入图片描述

2. 依赖包

判断有没有安装libicu依赖

rpm -qa | grep libicu
[root@localhost ~]# rpm -qa | grep libicu
libicu-50.2-4.el7_7.x86_64

没有的话下载安装
如果你想安装 libicu,可以使用以下命令:

yum install libicu

下载地址 RPM resource libicu
在这里插入图片描述

rpm -ivh libicu-50.2-4.el7_7.x86_64.rpm 

3.上传到服务器

scp -r C:\Users\xx.xx\Downloads\postgresql14-libs-14.10-1PGDG.rhel7.x86_64.rpm root@192.168.182.131:/usr/local/xx
scp -r C:\Users\xx.xx\Downloads\postgresql14-14.10-1PGDG.rhel7.x86_64.rpm root@192.168.182.131:/usr/local/xx
scp -r C:\Users\xx.xx\Downloads\postgresql14-server-14.10-1PGDG.rhel7.x86_64.rpm root@192.168.182.131:/usr/local/xx

4.按顺序安装

rpm -ivh postgresql14-libs-14.10-1PGDG.rhel7.x86_64.rpm
rpm -ivh postgresql14-14.10-1PGDG.rhel7.x86_64.rpm
rpm -ivh postgresql14-server-14.10-1PGDG.rhel7.x86_64.rpm
[root@localhost soft_resource]# rpm -ivh postgresql14-libs-14.10-1PGDG.rhel7.x86_64.rpm
警告:postgresql14-libs-14.10-1PGDG.rhel7.x86_64.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 442df0f8: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:postgresql14-libs-14.10-1PGDG.rhe################################# [100%]
[root@localhost soft_resource]# rpm -ivh postgresql14-14.10-1PGDG.rhel7.x86_64.rpm
警告:postgresql14-14.10-1PGDG.rhel7.x86_64.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 442df0f8: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:postgresql14-14.10-1PGDG.rhel7   ################################# [100%]
[root@localhost soft_resource]# rpm -ivh postgresql14-server-14.10-1PGDG.rhel7.x86_64.rpm
警告:postgresql14-server-14.10-1PGDG.rhel7.x86_64.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 442df0f8: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:postgresql14-server-14.10-1PGDG.r################################# [100%]

5.安装后操作

5.1初始化数据库

/usr/pgsql-14/bin/postgresql-14-setup initdb
[root@localhost usr]# /usr/pgsql-14/bin/postgresql-14-setup initdb
Initializing database ... OK

5.2修改配置文件

vim /var/lib/pgsql/14/data/postgresql.conf
listen_addresses = '*'  # 允许外部连接
port = 5432             # 端口号

5.3开放允许访问 ip

vim /var/lib/pgsql/14/data/pg_hba.conf
# replication privilege.
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            scram-sha-256
host    replication     all             ::1/128                 scram-sha-256
# 添加下面这行,允许所有 ip 访问
host    all             all             0.0.0.0/0               md5

5.3.1放行防火墙端口

firewall-cmd --zone=public --add-port=5432/tcp --permanent
firewall-cmd --reload #修改后需要重新加载防火墙生效

# 显示success表示成功
# –zone=public表示作用域为公共的
# –add-port=3306/tcp添加tcp协议的端口端口号为3306
# –permanent永久生效,如果没有此参数,则只能维持当前 服 务生命周期内,重新启动后失效;

5.4重启服务

systemctl reload postgresql-14
systemctl restart postgresql-14

5.5其他命令

systemctl start postgresql-14
systemctl stop postgresql-14

5.6 配置用户

5.6.1创建 test 用户

[root@server149058 ~]# su postgres
bash-4.2$ psql
could not change directory to "/root": Permission denied
psql (14.5)
Type "help" for help.

postgres=# create user test password 'test';
CREATE ROLE

5.6.2赋予超管权限

postgres=# ALTER ROLE test SUPERUSER;
ALTER ROLE

http://www.niftyadmin.cn/n/5285055.html

相关文章

Kafka下沉到HDFS报错

错误信息 24 十二月 2023 12:38:25,127 INFO [SinkRunner-PollingRunner-DefaultSinkProcessor] (org.apache.flume.sink.hdfs.HDFSCompressedDataStream.configure:64) - Serializer TEXT, UseRawLocalFileSystem false 24 十二月 2023 12:38:25,129 ERROR [SinkRunner-Pol…

vue 父页面监听子页面值的变化

在Vue中&#xff0c;可以通过使用$emit()来触发事件并传递数据。 首先&#xff0c;需要在父组件中定义一个自定义事件名称&#xff0c;然后将该事件与相应的处理函数关联起来。当子组件改变了其值时&#xff0c;就会调用这个处理函数。 下面是一个示例代码&#xff1a; <…

二叉树的递归遍历|前中后序遍历、最大深度、最大直径

二叉树的递归遍历 前序遍历 public List<Integer> preorderTraversal(TreeNode root) {List<Integer> res new ArrayList<>();if (root null) {return res;}res.add(root.val);if (root.left ! null) {res.addAll(preorderTraversal(root.left));}if (roo…

新版IDEA中Git的使用(三)

说明&#xff1a;前面介绍了在新版IDEA中Git的基本操作、分支操作&#xff0c;本文介绍一下在新版IDEA中&#xff0c;如何回滚代码&#xff1b; 分以下三个阶段来介绍&#xff1a; 未Commit的文件&#xff1b; 已经Commit&#xff0c;但未Push的文件&#xff1b; 已经Push的…

关于Python里xlwings库对Excel表格的操作(十七)

这篇小笔记主要记录如何【获取和设置单元格行高、列宽】。 前面的小笔记已整理成目录&#xff0c;可点链接去目录寻找所需更方便。 【目录部分内容如下】【点击此处可进入目录】 &#xff08;1&#xff09;如何安装导入xlwings库&#xff1b; &#xff08;2&#xff09;如何在W…

Python画皮卡丘

代码&#xff1a; import turtledef getPosition(x, y):turtle.setx(x)turtle.sety(y)print(x, y)class Pikachu:def __init__(self):self.t turtle.Turtle()t self.tt.pensize(3)t.speed(9)t.ondrag(getPosition)def noTrace_goto(self, x, y):self.t.penup()self.t.goto(…

计算机组成原理第6章-(算术运算)【下】

移位运算 对于有符号数的移位称为算术移位,对于无符号数的移位称为逻辑移位。 算术移位规则【极其重要】 对于正数的算术移位,且不管是何种机器数【原码、反码、补码】,移位后出现的空位全部填0。 而对于负数的算术移位,机器数不同,移位后的规则也不同。 对于负数的原…

CentOS+ISCSI

九、配置iSCSI 添加1块大小为10G的虚拟硬盘; 安装iSCSI服务端targetcli; 使用新增加的硬盘创建卷组,名称为iscsivg,再创建iSCSI共享逻辑卷,逻辑 卷名称为iscsistore,大小为5G; 使用上述逻辑卷创建后端存储,名称为serverc.iscsistore; 定义iSCSI的IQN为iqn.2022-…