美文网首页
源码安装-基于调试版本

源码安装-基于调试版本

作者: walleipt | 来源:发表于2018-03-20 11:14 被阅读0次

1.解压缩文件

tar -xzvf postgresql-9.6.2.tar.gz

2.配置源码并生成Makefile

#切换到PostgreSQL源代码目录:

cd postgresql-9.6.2

#本配置命令,会生成一个Makefile文件,文件中打开调试功能,依赖检测,启用ASSERT宏检测,并且制定了PostgreSQL的安装目录为/usr/local/postgresql-9.6.2-debug:

./configure --enable-debug CFLAGS='-g -O0' --prefix=/usr/local/postgresql-9.6.2-debug

3.编译源代码

make

make install

4.配置用户权限和环境变量

#添加用户(postgreSQL不允许使用root身份操作):

useradd postgres

#配置目录访问权限:

chmod 777 /usr/local/postgresql-9.6.2-debug/ -R

#环境变量(主要为了方便操作postgreSQL命令):

vi ~/ .bash_profile

#添加相关内容

PGHOME=/usr/local/postgresql-9.6.2-debug

export PGHOME

PGDATA=/usr/local/postgresql-9.6.2-debug/data

export PGDATA

PATH=$PATH:$HOME/bin:$HOME/.local/bin:$PGHOME/bin

export PATH

#刷新缓存,让后重新登陆

source ~/.bash_profile

#测试环境变量:

which psql

psql -V

5.初始化数据库

#初始化数据库:

initdb -D /usr/local/postgresql-9.6.2-debug/data

-----------------------------------------客户端访问配置begin--------------------------------------------

#配置信任的ip:

vi /usr/local/postgresql/data/pg_hba.conf

#修改IP4信任地址:

127.0.0.1/32修改为:0.0.0.0/0

#修改postgresql.conf文件

listen_addresses='*'

port = 5432

data目录介绍:

base:目录是表空间目录

    global:目录是相关全局变量的目录

    pg_hba.conf:访问控制配置(127.0.0.1改为信任的客户端ip网段使其可以远程访问)

    postgresql.conf:一个是postgresql主配置文件(listen_address=localhost改为星号使其监听整个网络)

-----------------------------------------客户端访问配置end--------------------------------------------

6. 启动、连接和关闭

#创建日志目录:

mkdir -v /usr/local/postgresql/log

#启动数据:

pg_ctl start -l /usr/local/postgresql-9.6.2-debug/log/pg_server.log

#连接数据库:

psql

-------------------------------------------------------------------------------------------------------

如果启动成功可能是权限错误参考如下:

• chown -R postgres:postgres /home/postgres/data

• chmod 0700 /home/postgres/data

-------------------------------------------------------------------------------------------------------

#设置postgres的密码:

\password

#查看数据列表:

\l

#关闭数据

pg_ctl stop

相关文章

网友评论

      本文标题:源码安装-基于调试版本

      本文链接:https://www.haomeiwen.com/subject/yumvqftx.html