## 查看磁盘大小,按目录输出
du -sh *
最终发现是postgres的目录下的pg_wal,一个文件256M,有600+个
接下来,我们来零基础入门postgres,粗略了解这台服务器上的数据库基本情况
1. 确定postgres部署的目录
[postgres@test01 pg_data]$ whereis psql
psql: /var/postgresql/soft/pg12.8/bin/psql
2. 连接及查看帮助
[postgres@test01 ~]$ psql
psql (12.8)
Type "help" for help.
postgres=# help
You are using psql, the command-line interface to PostgreSQL.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
postgres=# \h
3. 查看pg的状态,为 active(running)
[postgre@test01 ~]$ sudo systemctl status postgresql
● postgresql.service - PostgreSQL 12 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2023-12-16 17:02:36 CST; 2 months 7 days ago
Main PID: 1143 (postgres)
Tasks: 9
Memory: 512.8M
CGroup: /system.slice/postgresql.service
├─1143 /var/postgresql/soft/pg12.8/bin/postgres -D /mnt/data/postgres/pg_data
├─1848 postgres: logger
├─3099 postgres: checkpointer
├─3100 postgres: background writer
├─3101 postgres: walwriter
├─3102 postgres: autovacuum launcher
├─3103 postgres: archiver failed on 000000010000000000000001
├─3104 postgres: stats collector
└─3105 postgres: logical replication launcher
Dec 16 17:02:21 test01 systemd[1]: Starting PostgreSQL 12 database server...
Dec 16 17:02:21 test01 pg_ctl[1098]: pg_ctl: another server might be running; trying to start server anyway
Dec 16 17:02:21 test01 pg_ctl[1098]: waiting for server to start....2023-12-16 17:02:21.642 CST [1143] LOG: starting PostgreSQL 12.8 on x86_64-pc-linux-gnu, compiled by g...-44), 64-bit
Dec 16 17:02:21 test01 pg_ctl[1098]: 2023-12-16 17:02:21.642 CST [1143] LOG: listening on IPv4 address "0.0.0.0", port 5432
Dec 16 17:02:21 test01 pg_ctl[1098]: 2023-12-16 17:02:21.646 CST [1143] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
Dec 16 17:02:22 test01 pg_ctl[1098]: 2023-12-16 17:02:22.140 CST [1143] LOG: redirecting log output to logging collector process
Dec 16 17:02:22 test01 pg_ctl[1098]: 2023-12-16 17:02:22.140 CST [1143] HINT: Future log output will appear in directory "log".
Dec 16 17:02:36 test01 systemd[1]: Started PostgreSQL 12 database server.
Hint: Some lines were ellipsized, use -l to show in full.
4. 查询数据库的版本
postgres=# select version();
version
---------------------------------------------------------------------------------------------------------
PostgreSQL 12.8 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit
(1 row)
5. 查询配置参数,若是有备份会提示备份目录
[postgres@test01 pg_data]$ pg_config --configure
'--prefix=/var/postgresql/soft/pg12.8_8k_16g_openssl' '--with-libxml' '--with-libxslt' '--with-uuid=ossp' '--with-segsize=16' '--with-openssl'
由此可见,此处为涉及