栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

postgresql-14.2-源码编译安装

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

postgresql-14.2-源码编译安装

一、postgresql-14.2-源码包下载链接
https://ftp.postgresql.org/pub/source/v14.2/postgresql-14.2.tar.gz

二、环境简介

名称
cpuIntel® Core™ i7-7700HQ CPU @ 2.80GHz
操作系统Red Hat Enterprise Linux Server release 7.9 (Maipo)
pg数据目录/opt/pg14-2
pg安装目录/opt/pg14-2/data

三、安装

1、关闭 SELinux
编辑/etc/selinux/config,修改参数SELINUX=disabled。

2、创建用户和组
(1)groupadd postgres -g 2000
(2)useradd postgres -g 2000 -u 2000
(3)echo “postgres”|passwd --stdin postgres

3、修改操作系统limits
编辑/etc/security/limits.conf添加如下参数:
postgres soft nofile 1048576
postgres hard nofile 1048576
postgres soft nproc 131072
postgres hard nproc 131072
postgres soft stack 10240
postgres hard stack 32768
postgres soft core 6291456
postgres hard core 6291456

4、编译安装
(0)yum -y install readline readline-devel zlib zlib-devel gettext gettext-devel openssl openssl-devel pam pam-devel libxml2 libxml2-devel libxslt libxslt-devel perl perl-devel tcl-devel uuid-devel gcc gcc-c++ make flex bison perl-ExtUtils*
(1)cd /opt/postgresql-14.2
(2)./configure --prefix=/opt/pg14-2 --enable-debug --enable-dtrace
(3)gmake world
(4)gmake install-world
注: --enable-debug --enable-dtrace,不调试可以不加。

5、修改用户组
chown -R postgres:postgres /opt/pg14-2

6、初始化库
(1)su - postgres
(2)cd /opt/pg14-2/bin
(3)./initdb -D/opt/pg14-2/data -X/opt/pg14-2/pgwal

7、修改配置文件
(1)编辑pg_hba.conf,添加如下内容:
host all all 0.0.0.0/0 md5
(2)编辑postgresql.conf,修改如下参数:
listen_addresses = ‘*’

8、启动数据库
(1)su - postgres
(2)cd /opt/pg14-2/bin
(3)./pg_ctl -D /opt/pg14-2/data -l /opt/pg14-2/data/logfile restart

9、psql连接数据库
(1)su - postgres
(2)cd /opt/pg14-2/bin
(3)./psql
(4)select version();

10、数据库环境变量
编辑/home/postgres/.bashrc,添加如下内容:
export PGPORT=5432
export PGUSER=postgres
export PGHOME=/opt/pg14-2
export PGDATA=/opt/pg14-2/data
export PATH= P G H O M E / b i n : PGHOME/bin: PGHOME/bin:PATH

11、配置数据库自启
(1)cp /opt/postgresql-14.2/contrib/start-scripts/linux /etc/init.d/pg14-2
(2)vim /etc/init.d/pg14-2
修改如下内容:

(3) chmod 755 /etc/init.d/pg14-2
(4)chkconfig --add pg14-2
(5)chkconfig --list

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/734516.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号