Postgresql部署

  • 软件包下载
bash 复制代码
wget https://ftp.postgresql.org/pub/source/v14.5/postgresql-14.5.tar.gz
  • 依赖安装
bash 复制代码
yum install -y perl-ExtUtils-Embed readline-devel zlib-devel pam-devel libxml2-devel libxslt-devel openldap-devel python-devel gcc-c++ openssl-devel cmake
  • 解压安装
bash 复制代码
tar -zxf postgresql-14.5.tar.gz
./configure --prefix=/usr/pgsql-14
make world -j 16 && make install-world
  • 配置用户
bash 复制代码
groupadd postgres
useradd -g postgres postgres
mkdir /pg_data
chown postgres:postgres /pg_data
  • 配置环境变量
bash 复制代码
cat >>  ~/.bash_profile <<"EOF"
export PGDATA=/pg_data
export PGHOME=/usr/pgsql-14
export LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATH
export PATH=$PGHOME/bin:$PATH:.
export PGHOST=$PGDATA
export PGUSER=postgres
export PGDATABASE=postgres
EOF
source  ~/.bash_profile
  • 初始化
bash 复制代码
su - postgres
/usr/pgsql-14/bin/initdb -D /pg_data -E UTF8 --locale=en_US.utf8 -U postgres
  • 配置
bash 复制代码
cat >> /pg_data/postgresql.conf <<"EOF"
listen_addresses = '*'
log_truncate_on_rotation = on
unix_socket_directories = '/pg_data'
EOF

cat   >> /pg_data/pg_hba.conf << EOF
# TYPE  DATABASE    USER    ADDRESS       METHOD
host      all       all    0.0.0.0/0        md5
EOF
  • 添加服务
bash 复制代码
cp postgresql-14.5/contrib/start-scripts/linux /etc/init.d/postgresql
chmod +x /etc/init.d/postgresql
  • 修改配置
bash 复制代码
prefix=/usr/pgsql-14
PGDATA="/pg_data"
bash 复制代码
chkconfig --add postgresql
  • 启动服务
bash 复制代码
systemctl start postgresql.service
相关推荐
foolishlee1 分钟前
Neon proxy云端控制面
数据库
老当益壮梁奶奶12 分钟前
Linux软件编程学习笔记(十一):深入浅出 TCP 协议与 Socket 编程实践
linux·c语言·笔记·学习·tcp/ip
speop24 分钟前
hell-gpu| TASK01-2
linux·运维·算法
小蒜学长25 分钟前
借助于大模型工具Cursor的中药材交易系统的设计与实现(代码+数据库+LW)
java·数据库·spring boot·后端
byte轻骑兵37 分钟前
【BlueZ 】用户态入口:main.c 核心函数与程序启动流程
linux·人工智能·bluez·电脑蓝牙·嵌入式蓝牙
底层玩家老张1 小时前
数据库上K8s,运维为什么反而更累了?从StatefulSet到Operator的复盘
数据库·kubernetes·operator·数据库运维·架构选型
我科绝伦(Huanhuan Zhou)1 小时前
Linux rpm包损坏解决方案
运维
Tisfy1 小时前
LeetCode 2058.找出临界点之间的最小和最大距离:遍历+遇到极值则更新(这种题谁空间复杂度不是O(1)啊)
linux·数据库·leetcode·链表·题解·模拟·遍历
数据库小学妹1 小时前
MySQL死锁排查:锁机制原理、死锁日志与information_schema定位
运维·数据库·mysql
liulilittle1 小时前
REALITY 代理隧道的有效检测方法: 被动、主动与确定性三层实证研究
linux·服务器·网络·网络协议·安全·网络安全·通信