进阶数据库系列(二):PostgreSQL 目录结构与配置文件 postgresql.conf 详解

本文详细介绍了PostgreSQL的目录结构,包括软件安装目录、数据目录及日志目录,以及核心配置文件postgresql.conf的解析,涵盖了连接设置、内存设置、IO设置、日志设置和autovacuum设置等多个方面,旨在帮助读者深入理解PostgreSQL的运行机制和优化配置。
摘要由CSDN通过智能技术生成

前面介绍了 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 软件安装目录,psqlpg_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:#数据库实例主配置文件,基本上所有的数据库参数配置都在此文件中。
  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
PostgreSQL 10 中,`postgresql.conf` 文件用于指定 PostgreSQL 数据库服务器的全局配置选项。以下是一些常见的配置选项: 1. `listen_addresses`:指定数据库服务器要监听的 IP 地址或主机名。如果要允许来自所有 IP 地址的连接,则可以将其设置为 `*`。 ``` listen_addresses = '*' ``` 2. `port`:指定数据库服务器要监听的端口号。 ``` port = 5432 ``` 3. `max_connections`:指定数据库服务器同时处理的最大客户端连接数。 ``` max_connections = 100 ``` 4. `shared_buffers`:指定 PostgreSQL 要使用的共享内存缓冲区大小。该值应该足够大,以便在内存中缓存常用的数据。 ``` shared_buffers = 1GB ``` 5. `work_mem`:指定 PostgreSQL 中每个排序和哈希操作使用的内存缓冲区大小。该值应该足够大,以便在内存中缓存排序和哈希操作所需的数据。 ``` work_mem = 64MB ``` 6. `maintenance_work_mem`:指定 PostgreSQL 执行维护操作时使用的内存缓冲区大小。例如,当执行 VACUUM 操作时,该值应该足够大,以便在内存中缓存需要清理的数据。 ``` maintenance_work_mem = 256MB ``` 7. `effective_cache_size`:指定 PostgreSQL 估计的系统缓存大小。该值应该足够大,以便 PostgreSQL 可以利用系统缓存中的数据。 ``` effective_cache_size = 4GB ``` 8. `wal_level`:指定 WAL 日志的详细程度。可以设置为 `minimal`、`replica` 或 `logical`。 ``` wal_level = replica ``` 9. `max_wal_senders`:指定主服务器能够向从服务器发送 WAL 日志的最大数量。 ``` max_wal_senders = 10 ``` 以上是 PostgreSQL 10 中 `postgresql.conf` 文件的一些常见配置选项。这些选项可以根据具体的需求进行修改。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值