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
相关推荐
无限码农44 分钟前
2.1 网络编程 异步网络库zvnet
服务器·网络·php
宇灬宇1 小时前
Oracle 到 PostgreSQL迁移(ora2pg)
数据库·postgresql·oracle
高铭杰1 小时前
Postgresql源码(155)Redo系列CLOG Redo (RM_CLOG_ID = 3)
数据库·postgresql·redo·clog
小尔¥2 小时前
LNMP环境部署
运维·数据库·nginx·php
执笔画情ora3 小时前
pg数据库管理-PostgreSQL 的 COPY TO 和 COPY FROM 命令
数据库·postgresql
爱吃牛肉的大老虎3 小时前
PostgreSQL基础之安装
数据库·postgresql
CRMEB4 小时前
电商项目中订单流程可以使用哪些设计模式?如何开发?
java·设计模式·gitee·开源·php·crmeb
MrMua4 小时前
mysql与postgresql对比
数据库·mysql·postgresql
代龙涛4 小时前
wordpress块主题之创建主题
php·wordpress
2401_873587825 小时前
Linux——高级IO
服务器·数据库·php