ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

【postgreSQL】源码安装postgresql-14.0

2021-11-07 23:01:24  阅读:200  来源: 互联网

标签:bin postgresql postgres make 源码 postgreSQL data


软件包及要求

#下载地址和选定的源码包
https://www.postgresql.org/download/
postgresql-14.0.tar.gz
# 安装GCC编译器,需要GNU make 3.80 或更新版本
yum -y install gcc
make --version

创建postgres的系统用户和用户组

useradd -r postgres

解压软件到指定的目录下

tar -zxvf postgresql-14.0.tar.gz -C /data

配置数据库安装目录

cd /data/postgresql-14.0/
./configure --prefix=/data/postgreSQL

# 错误1-实际上是缺少readline-devel
configure: error: readline library not found
If you have readline already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-readline to disable readline support.
#错误2-查看依赖 yum search zlib
configure: error: zlib library not found
If you have zlib already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper directory.
Use --without-zlib to disable zlib support.

# 解决-安装依赖
yum -y install -y readline-devel
yum -y install -y zlib-devel

构建

make
# make all
# make world
# make make world-bin

安装文件

make install
# make install-docs
# make install-world
# make install-world-bin

创建数据目录

mkdir -p /data/postgreSQL/pgsqlData
chown postgres.postgres /data/postgreSQL/pgsqlData

切换到postgres用户操作

su postgres
# 初始化数据库
/data/postgreSQL/bin/initdb -D /data/postgreSQL/pgsqlData
# 启动实例
/data/postgreSQL/bin/pg_ctl -D /data/postgreSQL/pgsqlData -l logfile start
# 创建测试数据库
/data/postgreSQL/bin/createdb test
# 登录
/data/postgreSQL/bin/psql test

修改管理员用户密码

ALTER USER postgres WITH PASSWORD '123456';

授权远程登录

修改两个配置文件

# vi /data/postgreSQL/pgsqlData/pg_hba.conf
host    all             all             0.0.0.0/0            md5
# vi /data/postgreSQL/pgsqlData/postgresql.conf
listen_addresses = '*'
# /data/postgreSQL/bin/pg_ctl -D /data/postgreSQL/pgsqlData reload

配置防火墙端口

firewall-cmd --add-port=5432/tcp --permanent
firewall-cmd --reload

配置postgreSQL开机启动服务

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

[Unit]
Description=postgreSQL Server

[Service]
User=postgres
Group=postgres
Type=forking
TimeoutSec=0
PermissionsStartOnly=true
ExecStart=/data/postgreSQL/bin/pg_ctl -D /data/postgreSQL/pgsqlData start
LimitNOFILE = 65535
Restart=on-failure
RestartSec=3
RestartPreventExitStatus=1
PrivateTmp=false

[Install]
WantedBy=multi-user.target

加载配置和启动

systemctl daemon-reload
systemctl start postgresql
systemctl enable postgresql

备份还原

pg_dump -h localhost -U postgres -p 5432 -d mydb -s -f /data/postgresql.backup

/data/postgreSQL/bin/psql -h localhost -p 5432 -U mydb -W -d hl_pre < /data/tools/postgresql.backup

标签:bin,postgresql,postgres,make,源码,postgreSQL,data
来源: https://www.cnblogs.com/wsum/p/15522211.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有