前面介绍了 PostgreSQL 基础概念及安装部署 相关的知识点,今天我将详细的为大家介绍 PostgreSQL 目录结构与配置文件 postgresql.conf 介绍 相关知识,希望大家能够从中收获多多!如有帮助,请点在看、转发支持一波!!!
环境搭建完成后,从环境变量里看它涉及的目录
export PGHOME=/usr/local/pgsql/
export PGUSER=postgres
export PGPORT=5432
export PGDATA=/app/pgsql/data
export PGLOG=/app/pgsql/log/postgres.log
export PATH=$PGHOME/bin:$PATH:$HOME/bin
export LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATH
PATH=/usr/local/pgsql/bin:$PATH
export PATH
目录结构及作用
软件安装目录
/usr/local/pgsql/
相当于oracle的 /app/oracle 软件安装目录,psql、pg_ctl等软件可执行的一些命令都在这下面。
[postgres@yuan ~]$ cd /usr/local/pgsql/
[postgres@yuan pgsql]$ ll
total 16
drwxr-xr-x 2 root root 4096 Jul 9 17:54 bin
drwxr-xr-x 6 root root 4096 Jul 9 17:54 include
drwxr-xr-x 4 root root 4096 Jul 9 17:54 lib
lrwxrwxrwx 1 root root 26 Jul 9 17:56 postgresql-12.4 -> /usr/local/postgresql-12.4
drwxr-xr-x 6 root root 4096 Jul 9 17:54 share
[postgres@yuan pgsql]$ cd bin
[postgres@yuan bin]$ ll
total 12348
-rwxr-xr-x 1 root root 73808 Jul 9 17:54 clusterdb
-rwxr-xr-x 1 root root 73552 Jul 9 17:54 createdb
-rwxr-xr-x 1 root root 78416 Jul 9 17:54 createuser
-rwxr-xr-x 1 root root 68944 Jul 9 17:54 dropdb
-rwxr-xr-x 1 root root 68920 Jul 9 17:54 dropuser
-rwxr-xr-x 1 root root 975928 Jul 9 17:54 ecpg
-rwxr-xr-x 1 root root 142520 Jul 9 17:54 initdb
-rwxr-xr-x 1 root root 44344 Jul 9 17:54 pg_archivecleanup
-rwxr-xr-x 1 root root 130528 Jul 9 17:54 pg_basebackup
-rwxr-xr-x 1 root root 172512 Jul 9 17:54 pgbench
-rwxr-xr-x 1 root root 66984 Jul 9 17:54 pg_checksums
-rwxr-xr-x 1 root root 42880 Jul 9 17:54 pg_config
-rwxr-xr-x 1 root root 61376 Jul 9 17:54 pg_controldata
-rwxr-xr-x 1 root root 76888 Jul 9 17:54 pg_ctl
-rwxr-xr-x 1 root root 422888 Jul 9 17:54 pg_dump
-rwxr-xr-x 1 root root 109376 Jul 9 17:54 pg_dumpall
-rwxr-xr-x 1 root root 73064 Jul 9 17:54 pg_isready
-rwxr-xr-x 1 root root 93208 Jul 9 17:54 pg_receivewal
-rwxr-xr-x 1 root root 93832 Jul 9 17:54 pg_recvlogical
-rwxr-xr-x 1 root root 71256 Jul 9 17:54 pg_resetwal
-rwxr-xr-x 1 root root 187840 Jul 9 17:54 pg_restore
-rwxr-xr-x 1 root root 109784 Jul 9 17:54 pg_rewind
-rwxr-xr-x 1 root root 49216 Jul 9 17:54 pg_test_fsync
-rwxr-xr-x 1 root root 39152 Jul 9 17:54 pg_test_timing
-rwxr-xr-x 1 root root 148952 Jul 9 17:54 pg_upgrade
-rwxr-xr-x 1 root root 103904 Jul 9 17:54 pg_waldump
-rwxr-xr-x 1 root root 8227064 Jul 9 17:53 postgres
lrwxrwxrwx 1 root root 8 Jul 9 17:53 postmaster -> postgres
-rwxr-xr-x 1 root root 615376 Jul 9 17:54 psql
-rwxr-xr-x 1 root root 78032 Jul 9 17:54 reindexdb
-rwxr-xr-x 1 root root 86968 Jul 9 17:54 vacuumdb
数据目录
/app/pgsql/data
相当于oracle建库时指定的数据目录,数据库所需的参数文件,数据文件等均在这下面。
[postgres@yuan include]$ cd /app/pgsql/data
[postgres@yuan data]$ ll
total 60
drwx------ 5 postgres postgres 41 Jul 9 18:02 base
drwx------ 2 postgres postgres 4096 Jul 9 18:06 global
drwx------ 2 postgres postgres 6 Jul 9 18:02 pg_commit_ts
drwx------ 2 postgres postgres 6 Jul 9 18:02 pg_dynshmem
-rw------- 1 postgres postgres 4789 Jul 9 18:03 pg_hba.conf
-rw------- 1 postgres postgres 1636 Jul 9 18:02 pg_ident.conf
drwx------ 4 postgres postgres 68 Jul 9 18:10 pg_logical
drwx------ 4 postgres postgres 36 Jul 9 18:02 pg_multixact
drwx------ 2 postgres postgres 18 Jul 9 18:05 pg_notify
drwx------ 2 postgres postgres 6 Jul 9 18:02 pg_replslot
drwx------ 2 postgres postgres 6 Jul 9 18:02 pg_serial
drwx------ 2 postgres postgres 6 Jul 9 18:02 pg_snapshots
drwx------ 2 postgres postgres 6 Jul 9 18:02 pg_stat
drwx------ 2 postgres postgres 63 Jul 9 20:50 pg_stat_tmp
drwx------ 2 postgres postgres 18 Jul 9 18:02 pg_subtrans
drwx------ 2 postgres postgres 6 Jul 9 18:02 pg_tblspc
drwx------ 2 postgres postgres 6 Jul 9 18:02 pg_twophase
-rw------- 1 postgres postgres 3 Jul 9 18:02 PG_VERSION
drwx------ 3 postgres postgres 60 Jul 9 18:02 pg_wal
drwx------ 2 postgres postgres 18 Jul 9 18:02 pg_xact
-rw------- 1 postgres postgres 88 Jul 9 18:02 postgresql.auto.conf
-rw------- 1 postgres postgres 26659 Jul 9 18:03 postgresql.conf
-rw------- 1 postgres postgres 53 Jul 9 18:05 postmaster.opts
-rw------- 1 postgres postgres 74 Jul 9 18:05 postmaster.pid
文件及目录说明:
pg_hba.conf:#认证配置文件,配置了允许哪些IP访问数据库,及认证方式等信息。
pg_ident.conf:#"ident"认证方式的用户映射文件。
PG_VERSION:#记录了数据库版本号信息。
postgresql.auto.conf:#作用同 postgresql.conf ,优先级高于 postgresql.conf,在数据库中通过alter命令更改的参数记录在此文件中。
postgresql.conf:#数据库实例主配置文件,基本上所有的数据库参数配置都在此文件中。