1.postgresql安装配置

1.源码编译安装

下载地址:https://www.postgresql.org/ftp/source/v10.0/解压

tar -zxvf postgresql-10.0.tar.gz

2.准备好编译环境和安装包

yum groupinstall "Development tools"

yum install -y bison flex readline-devel zlib-devel

3.在源代码中运行configure --help查看配置的编译选项

cd postgresql-10.0

./configure --help

4.编译安装

./configure --prefix=/opt/pg10/ --with-pgport=1921

gmake  #出现successfully成功
gmake install  #PostgreSQL installation complete.安装成功

查看版本

[root@localhost postgresql-10.0]# /opt/pg10/bin/postgres --version
postgres (PostgreSQL) 10.0

 

5.设置/opt/pgsql的软连接指向当前版本,当变更版本的时候修改软连接即可

ln -s /opt/pg10/ /opt/pgsql
[root@localhost opt]# ll
total 0
drwxr-xr-x. 6 root root 56 Oct 12 23:06 pg10
[root@localhost opt]# ln -s /opt/pg10/ /opt/pgsql  #设置软链接,指向,谁指向谁,A连接到b,ln -s a b
[root@localhost opt]# ll
total 0
drwxr-xr-x. 6 root root 56 Oct 12 23:06 pg10
lrwxrwxrwx. 1 root root 10 Oct 12 23:11 pgsql -> /opt/pg10/

查看postgresql结构

 

 6.创建用户组和用户命令

[root@localhost opt]# groupadd -g 1001 postgres
[root@localhost opt]# useradd -g 1001 -u 1001 postgres
[root@localhost opt]# id postgres
uid=1001(postgres) gid=1001(postgres) groups=1001(postgres)

7.创建数据目录(存放数据文件和数据库配置文件)

为区分不同版本数据,不同业务数据采取以下命名  /pgdata/9.x/xxx_data,版本区分,和业务区分

[root@localhost opt]#  mkdir -p /pgdata/10/{data,backups,scripts,archvie_wals}

保护目录不受限制访问,修改权限命令

[root@localhost opt]# chown -R postgres.postgres /pgdata/10
[root@localhost opt]# chmod 0700 /pgdata/10/data

8.初始化数据目录,记得先切换用户

/opt/pgsql/bin/initdb --help可查看命令详解

/opt/pgsql/bin/initdb -D /pgdata/10/data/ -W

初始化成功,注意:不要在初始化数据目录中手动创建任何文件

 

posted @ 2021-10-13 11:40  罗论明  阅读(99)  评论(0编辑  收藏  举报