postgresql14编译安装参考手册(centos)

Linux平台编译安装的快捷参考(Centos7.X平台/Pg14beta3为例):

说明:postgres官网源码编译安装操作步骤有一些小坑没更新过来,所以参考官网的安装步骤重新整理了一下,PG12,13部署均可以参考该文档。参考链接:下载页面/Download: 世界上功能最强大的开源数据库...icon-default.png?t=L892http://www.postgres.cn/v2/download

PG官网软件包下载地址:https://www.postgresql.org/ftp/source/v14beta3/

1.上传postgresql14beta3软件包至服务器指定路径下(1~9 root用户执行)

2.tar -xjvf postgresql-14beta3.tar.bz2

3.cd postgresql-14beta3

4../configure --prefix=/home/postgres/pgsql14.3 --with-perl --with-python #拟安装至/home/postgres/pgsql14.3路径下

说明:pg官网没有--with-perl --with-python 这两个,加上改选项才能使用Perl和Python语法的过程语言来编写自定义函数。

5.make world

6.make install-world

7.useradd postgres #创建postgres用户,并修改postgres用户密码

8.mkdir /home/postgres/pgsql14.3/data #创建数据库data目录

9.chown -R postgres:postgres /home/postgres

10.su - postgres #使用postgres帐号操作

11./home/postgres/pgsql14.3/bin/initdb -D /home/postgres/pgsql14.3/data #初始化数据库

12./home/postgres/pgsql14.3/bin/pg_ctl -D /home/postgres/pgsql14.3/data -l logfile start #启动数据库

13./home/postgres/pgsql14.3/bin/psql #连接数据库,默认psql连接postgres库。

至此,数据库部署完成,可以开始学习啦~

补充内容:

一、环境变量配置:

postgres 安装完成后,配置PG环境变量,在.bashrc中我添加如下3个参数(非必要项)

export PATH=/home/postgres/pgsql14.3/bin:$PATH

export LD_LIBRARY_PATH=/home/postgres/pgsql14.3/lib:$LD_LIBRARY_PATH

export PGDATA=/home/postgres/pgsql14.3/data

 

export PATH=/data/pg/bin:$PATH

export LD_LIBRARY_PATH=/data/pg/lib:$LD_LIBRARY_PATH

export PGDATA=/data/pg/pgdata

保存后source .bashrc 生效

二、postgresql数据库参数简单配置

修改pg_hba.conf

host alll all 0/0 md5

--该命令允许任何用户远程连接本数据库,连接是需要密码,走MD5认证。

2. 修改postgresql.conf

listen_addresses = ‘*’ #“*”表示在本地的所有地址上监听

logging_collector = on #打开日志收集

log_directory = ‘pg_log’

只保留最近7天的日志,进行循环覆盖。配置方法如下:

log_filename = ‘postgresql-%a.log’

log_truncate_on_rotation = on

log_rotation_age =1d

log_rotation_size = 0

3.安装contrib目录下的工具

contrib 下有一些工具比较实用,安装步骤如下

cd postgresql-14beta3/contrib/

make

make install

三、编译安装遇到报错:

报错一:

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.

解决方法:

yum install readline readline-devel -y

报错二:

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 install zlib zlib-devel -y

报错三:

configure: error: could not determine flags for linking embedded Perl.

This probably means that ExtUtils::Embed or ExtUtils::MakeMaker is not

installed.

解决方法:

yum install perl-ExtUtils-Embed -y

报错四:

configure: error: header file <Python.h> is required for Python

解决方法:

yum install python python-devel -y

-bash-4.2$问题解决:

原因是在用useradd添加普通用户时,有时会丢失家目录下的环境变量文件,丢失文件如下:
1、.bash_profile
2、.bashrc
以上这些文件是每个用户都必备的文件。
此时可以使用以下命令从主默认文件/etc/skel/下重新拷贝一份配置信息到此用户家目录下

-bash-4.2$ cp /etc/skel/.bashrc .

-bash-4.2$ cp /etc/skel/.bash_profile .
————————————————
版权声明:本文为CSDN博主「杨小龙0110」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/XL_711/article/details/120386088

posted @ 2023-05-13 22:27  binbinx  阅读(317)  评论(0编辑  收藏  举报