怎么在CentOS 7.4环境下源码编译安装postgreSQL 11.4

数据库   2024年05月04日 22:14  

本篇内容介绍了“怎么在CentOS 7.4环境下源码编译安装postgreSQL 11.4”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

1. 安装依赖包

yuminstall-yreadlinereadline-developensslopenssl-develzlibzlib-devel

2. 下载软件

wgethttps://ftp..org/pub/source/v11.4/-11.4.tar.gz

3. 解压并安装

tar-zvvfpostgresql-11.4.tar.gz#进入解压后的文件夹cdpostgresql-11.4./configure--prefix=/usr/local/pgsql#指定默认安装路径make#编译makeinstall#安装

4. 添加用户并更改权限

useraddpostgres#添加用户passwdpostgres#设置密码mkdir-p/data/pgsql/datamkdir-p/data/pgsql/logcd/data/pgsql/logtouchpgsql.logchown-Rpostgres:postgres/data/pgsql

5. 添加环境变量

vim/etc/profile

内容如下:

#postgresqlexportPGHOME=/data/pgsqlexportPGBASE=/usr/local/pgsqlexportPATH=$PATH:$PGBASE/bin

使之生效

source/etc/profile

6. 初始化数据

切换到postgres用户下 su - postgres

[postgres@localhost~]$cd/usr/local/pgsql/bin/[postgres@localhostbin]$lsclusterdbecpgpg_configpg_isreadypg_rewindpg_waldumpvacuumdbcreatedbinitdbpg_controldatapg_receivewalpg_test_fsyncpostgrescreateuserpg_archivecleanuppg_ctlpg_recvlogicalpg_test_timingpostmasterdropdbpg_basebackuppg_dumppg_resetwalpg_upgradepsqldropuserpgbenchpg_dumpallpg_restorepg_verify_checksumsreindexdb[postgres@localhostbin]$./initdb-D/data/pgsql/dataThefilesbelongingtothisdatabasesystemwillbeownedbyuser"postgres".Thisusermustalsoowntheserverprocess.Thedatabaseclusterwillbeinitializedwithlocale"en_US.UTF-8".Thedefaultdatabaseencodinghasaccordinglybeensetto"UTF8".Thedefaulttextsearchconfigurationwillbesetto"english".Datapagechecksumsaredisabled.fixingpermissionsonexistingdirectory/data/pgsql/data...okcreatingsubdirectories...okselectingdefaultmax_connections...100selectingdefaultshared_buffers...128MBselectingdefaulttimezone...PRCselectingdynamicsharedmemoryimplementation...posixcreatingconfigurationfiles...okrunningbootstrapscript...okperformingpost-bootstrapinitialization...oksyncingdatatodisk...okWARNING:enabling"trust"authenticationforlocalconnectionsYoucanchangethisbyeditingpg_hba.conforusingtheoption-A,or--auth-localand--auth-host,thenexttimeyouruninitdb.Success.Youcannowstartthedatabaseserverusing:./pg_ctl-D/data/pgsql/data-llogfilestart

7. 检查数据目录:

[root@localhostdata]#lsbasepg_hba.confpg_notifypg_statpg_twophasepostgresql.auto.confglobalpg_ident.confpg_replslotpg_stat_tmpPG_VERSIONpostgresql.confpg_commit_tspg_logicalpg_serialpg_subtranspg_walpg_dynshmempg_multixactpg_snapshotspg_tblspcpg_xact

其中

base目录是表空间目录;

global目录是相关全局变量目录;

pg_hba.conf是访问控制配置文件;

postgresql.conf是postgresql的主配置文件。

8. 修改pg_hba.conf文件

将该文件中的IPV4的连接修改为0.0.0.0/0,表示信任来自所有id连接的客户端,加密方式改为md5,如下图所示:

9.修改postgresql.conf配置文件

将localhost改为*,表示监听所有的网络连接。其他的参数保持默认即可。

10. 关闭防火墙

systemctlstopfirewalld

11. 启动数据库

[postgres@localhostbin]$./pg_ctl-D/data/pgsql/data-l/data/pgsql/log/pgsql.logstartwaitingforservertostart....doneserverstarted

12. 登录数据库并设置密码

[postgres@localhostbin]$./psqlpsql(11.4)Type"help"forhelp.postgres=#\passwordEnternewpassword:Enteritagain:postgres=#\lListofdatabasesName|Owner|Encoding|Collate|Ctype|Accessprivileges-----------+----------+----------+-------------+-------------+-----------------------postgres|postgres|UTF8|en_US.UTF-8|en_US.UTF-8|template0|postgres|UTF8|en_US.UTF-8|en_US.UTF-8|=c/postgres+|||||postgres=CTc/postgrestemplate1|postgres|UTF8|en_US.UTF-8|en_US.UTF-8|=c/postgres+|||||postgres=CTc/postgres(3rows)

13. navicat 登录

“怎么在CentOS 7.4环境下源码编译安装postgreSQL 11.4”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注网站,小编将为大家输出更多高质量的实用文章!

域名注册
购买VPS主机

您或许对下面这些文章有兴趣:                    本月吐槽辛苦排行榜

看贴要回贴有N种理由!看帖不回贴的后果你懂得的!


评论内容 (*必填):
(Ctrl + Enter提交)   

部落快速搜索栏

各类专题梳理

网站导航栏

X
返回顶部