PostgreSQLt二进制安装-contos7

1、安装依赖

复制代码
yum install -y gcc readline readline-devel zlib-devel net-tools perl wget numactl libicu-devel bison flex openssl-devel pam pam-devel libxml2 libxml2-devel libxslt libxslt-devel openldap openldap-devel

2、创建目录

复制代码
mkdir -p /data/postgresql/{data,logs} #创建postgresql数据及日志目录

3、添加用户postgres

复制代码
useradd postgres

4、解压二进制包

复制代码
tar -zxf postgresql-17.2.tar.gz

5、进入解压出来的文件postgresql-17.2

复制代码
cd postgresql-17.2

6、编译扩展路径

复制代码
./configure --prefix=/usr/local/postgresql --with-pgport=5432  --with-openssl --with-pam --with-ldap --with-libxml --with-libxslt --with-blocksize=16 --with-wal-blocksize=16

7、编译及安装

复制代码
make && make install

8、配置环境变量

复制代码
vi /etc/profile
export PGHOME=/usr/local/postgresql
export PGDATA=/data/postgresql/data
export PATH=$PATH:$JAVA_HOME/bin:$PGHOME/bin
source /etc/profile

9、授权访问权限

复制代码
chown -R postgres:root /usr/local/postgresql
chown -R postgres:root /data/postgresql

10、切换用户

复制代码
su postgres

11、初始化数据库

复制代码
/usr/local/postgresql/bin/initdb -D $PGDATA -E UTF8

12、编辑postgresql.conf配置文件

复制代码
vi /data/postgresql/data/postgresql.conf
# 设置所有ip可连接
listen_addresses = '*' 

# 设置监听端口
port = 5432 

13、编辑pg_hba.conf配置文件

复制代码
vi /data/postgresql/data/pg_hba.conf
# 所有数据库(all)、所有用户(all)、从本机(127.0.0.1/32)均可免密访问(trust)但是这样做不安全哈
host    all             all             0.0.0.0/0               trust

14、启动停止服务

复制代码
pg_ctl start -l /data/postgresql/logs/pg_server.log #启动服务
pg_ctl stop -l /data/postgresql/logs/pg_server.log #停止服务

15、查看版本

复制代码
psql -V

16、登录数据库

复制代码
psql -U postgres -d postgres

17、添加防火墙

复制代码
查看防火墙状态:firewall-cmd --state
开放5432端口:firewall-cmd --zone=public --add-port=5432/tcp --permanent
关闭5432端口:firewall-cmd --zone=public --remove-port=5432/tcp --permanent
重新加载配置:firewall-cmd --reload
相关推荐
Shartin2 小时前
Can201-Introduction to Networking: Application Layer应用层
服务器·开发语言·php
乌云暮年3 小时前
Linux常用命令
linux·服务器·ssh·php
apihz5 小时前
通用图片搜索-搜狗源免费API接口使用指南
android·java·python·php·音视频
博睿谷IT99_5 小时前
华为数据通信网络基础
开发语言·华为·php·华为认证
OK_boom7 小时前
npgsql/dapper/postgresql的时区问题
数据库·postgresql
ladymorgana12 小时前
【数据库】PostgreSQL 与 MySQL 全方位对比
数据库·mysql·postgresql
阿俊-全栈开发17 小时前
crmeb多门店对接拉卡拉支付小程序聚合收银台集成全流程详解
小程序·php·拉卡拉聚合收银台·拉卡拉三方支付
IT小辉同学20 小时前
PostgreSQL 与 MySQL 获取字段注释并转换为驼峰命名教程
数据库·mysql·postgresql
有想法的py工程师1 天前
PostgreSQL 查询库中所有表占用磁盘大小、表大小
数据库·postgresql