PostgreSQL DBA(1) - 資料庫引數設定#1
本節簡單介紹了可用於診斷PostgreSQL資料庫引數設定的工具:postgresqltuner,包括該工具的安裝和基本使用。
一、安裝
在REHL系列下安裝:
#該工具基於Perl語言開發,首先安裝Perl相關的開發包
#yum -y install perl-DBD-Pg
#獲取工具包
#cd /tmp
#wget -O postgresqltuner.pl
#chmod +x postgresqltuner.pl
二、基本使用
在資料庫主機上執行:
[xdb@localhost bin]$ /tmp/postgresqltuner.pl --host=localhost --user xdb --database testdb
postgresqltuner.pl version 1.0.0
Connecting to localhost:5432 database testdb with user xdb...
Argument "11beta2" isn't numeric in numeric gt (>) at /tmp/postgresqltuner.pl line 818.
[OK] User used for report have super rights
===== OS information =====
[INFO] OS: linux Version: 3.10.0-514.16.1.el7.x86_64 Arch: x86_64-linux-thread-multi
[INFO] OS total memory: 732.52 MB
[BAD] Memory overcommitment is allowed on the system. This can lead to OOM Killer killing some PostgreSQL process, which will cause a PostgreSQL server restart (crash recovery)
[INFO] sysctl vm.overcommit_ratio=50
[BAD] vm.overcommit_ratio is too small, you will not be able to use more than 50*RAM+SWAP for applications
[INFO] Currently used I/O scheduler(s) : deadline
===== General instance informations =====
----- Version -----
Argument "11beta2" isn't numeric in numeric gt (>) at /tmp/postgresqltuner.pl line 818.
[OK] You are using last 11beta2
----- Uptime -----
[INFO] Service uptime : 09m 53s
[WARN] Uptime is less than 1 day. postgresqltuner.pl result may not be accurate
----- Databases -----
[INFO] Database count (except templates): 2
[INFO] Database list (except templates): postgres testdb
----- Extensions -----
[INFO] Number of activated extensions : 1
[INFO] Activated extensions : plpgsql
[WARN] Extensions pg_stat_statements is disabled
----- Users -----
[OK] No user account will expire in less than 7 days
[OK] No user with password=username
[OK] Password encryption is enabled
----- Connection information -----
[INFO] max_connections: 100
[INFO] current used connections: 6 (6.00%)
[INFO] 3 are reserved for super user (3.00%)
[INFO] Average connection age : 08m 14s
[WARN] Average connection age is less than 10 minutes. Use a connection pooler to limit new connection/seconds
----- Memory usage -----
[INFO] configured work_mem: 4.00 MB
[INFO] Using an average ratio of work_mem buffers by connection of 150% (use --wmp to change it)
[INFO] total work_mem (per connection): 6.00 MB
[INFO] shared_buffers: 128.00 MB
Argument "11beta2" isn't numeric in numeric gt (>) at /tmp/postgresqltuner.pl line 818.
[INFO] Track activity reserved size : 0.00 B
[WARN] maintenance_work_mem is less or equal default value. Increase it to reduce maintenance tasks time
[INFO] Max memory usage :
shared_buffers (128.00 MB)
+ max_connections * work_mem * average_work_mem_buffers_per_connection (100 * 4.00 MB * 150 / 100 = 600.00 MB)
+ autovacuum_max_workers * maintenance_work_mem (3 * 64.00 MB = 192.00 MB)
+ track activity size (0.00 B)
= 920.00 MB
[INFO] effective_cache_size: 4.00 GB
[INFO] Size of all databases : 33.19 MB
[WARN] shared_buffer is too big for the total databases size, memory is lost
[INFO] PostgreSQL maximum memory usage: 125.59% of system RAM
[BAD] Max possible memory usage for PostgreSQL is more than system total RAM. Add more RAM or reduce PostgreSQL memory
[INFO] max memory+effective_cache_size is 684.76% of total RAM
[WARN] the sum of max_memory and effective_cache_size is too high, the planer can find bad plans if system cache is smaller than expected
----- Logs -----
[OK] log_hostname is off : no reverse DNS lookup latency
[WARN] log of long queries is desactivated. It will be more difficult to optimize query performances
[OK] log_statement=none
----- Two phase commit -----
Argument "11beta2" isn't numeric in numeric gt (>) at /tmp/postgresqltuner.pl line 818.
[OK] Currently no two phase commit transactions
----- Autovacuum -----
[OK] autovacuum is activated.
[INFO] autovacuum_max_workers: 3
----- Checkpoint -----
[WARN] checkpoint_completion_target(0.5) is low
----- Disk access -----
[OK] fsync is on
[OK] synchronize_seqscans is on
----- WAL -----
Argument "11beta2" isn't numeric in numeric gt (>) at /tmp/postgresqltuner.pl line 818.
----- Planner -----
[OK] costs settings are defaults
[BAD] some plan features are disabled : enable_partitionwise_aggregate,enable_partitionwise_join
===== Database information for database testdb =====
----- Database size -----
[INFO] Database testdb total size : 11.44 MB
Argument "11beta2" isn't numeric in numeric gt (>) at /tmp/postgresqltuner.pl line 818.
[INFO] Database testdb tables size : 8.38 MB (73.22%)
[INFO] Database testdb indexes size : 3.06 MB (26.78%)
----- Tablespace location -----
Argument "11beta2" isn't numeric in numeric gt (>) at /tmp/postgresqltuner.pl line 818.
[OK] No tablespace in PGDATA
----- Shared buffer hit rate -----
[INFO] shared_buffer_heap_hit_rate: 99.03%
[INFO] shared_buffer_toast_hit_rate: 0.00%
[INFO] shared_buffer_tidx_hit_rate: 28.57%
[INFO] shared_buffer_idx_hit_rate: 98.43%
[OK] Shared buffer idx hit rate is very good
----- Indexes -----
[OK] No invalid indexes
Argument "11beta2" isn't numeric in numeric gt (>) at /tmp/postgresqltuner.pl line 818.
[OK] No unused indexes
----- Procedures -----
[OK] No procedures with default costs
===== Configuration advices =====
----- checkpoint -----
[MEDIUM] Your checkpoint completion target is too low. Put something nearest from 0.8/0.9 to balance your writes better during the checkpoint interval
----- extension -----
[LOW] Enable pg_stat_statements to collect statistics on all queries (not only queries longer than log_min_duration_statement in logs)
----- sysctl -----
[URGENT] set vm.overcommit_memory=2 in /etc/sysctl.conf and run sysctl -p to reload it. This will disable memory overcommitment and avoid postgresql killed by OOM killer.
執行完畢,該工具會輸出一系列的引數調整建議.這些引數的含義和為何如此調整,下節討論.
三、小結
本節簡單介紹了postgresqltuner.pl工具的安裝和基本使用,有興趣的可以檢視該工具postgresqltuner的原始碼並進行改進.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/6906/viewspace-2374887/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- PostgreSQL DBA(2) - 資料庫引數設定#2SQL資料庫
- Mysql 5.5 設定資料庫引數MySql資料庫
- 1. PostgreSQL 資料庫安裝SQL資料庫
- postgresql資料庫重要引數說明SQL資料庫
- Oracle DBA1 ---- 資料庫恢復Oracle資料庫
- mysql的"雙1設定"-資料安全的關鍵引數(案例分享)MySql
- PostgreSQL資料庫連線保持設定SQL資料庫
- 資料庫設計(1)資料庫
- PostgreSQL 原始碼解讀(1)- 插入資料#1SQL原始碼
- PostgreSQL DBA(66) - 配置引數(checkpoint_flush_after)SQL
- PostgreSQL DBA(28) - Backup&Recovery#1(基本操作)SQL
- PostgreSQL資料庫擴充套件語言程式設計之plpgsql-1SQL資料庫套件程式設計
- 設定DB_ULTRA_SAFE引數保障物理備用資料庫資料庫
- ORACLE RAC資料庫中的初始化引數的設定Oracle資料庫
- PostgreSQL DBA(145) - pgAdmin(AUTOVACUUM:引數解析#3)SQL
- PostgreSQL DBA(144) - pgAdmin(AUTOVACUUM:引數解析#2)SQL
- PostgreSQL DBA(64) - checkpoint_completion_target引數解析SQL
- 【引數】DB_nK_CACHE_SIZE引數設定與資料庫預設塊大小之間的限制資料庫
- PostgreSQL DBA(21) - MVCC#1(Multi Version Heap Tuple)SQLMVCC#
- PostgreSQL DBA(4) - PG 11 New Features#1SQL
- Oracle 11G 資料庫重要的初始化引數設定Oracle資料庫
- 關於 oracle 設定引數時,scope型別為memory,重啟資料庫後引數失效Oracle型別資料庫
- LightBD/PostgreSQL資料庫設定歸檔保留時間SQL資料庫
- PostgreSQL DBA(32) - HA#1(pg_rewind切換)SQL
- MySQL資料庫引數MySql資料庫
- PostgreSQL 資料庫學習 - 1.資料庫體系結構之儲存結構SQL資料庫
- PostgreSQL 資料頁Page解析(1)- 基礎SQL
- 安裝oracle資料庫時,設定linux核心引數的意義Oracle資料庫Linux
- 【讀書筆記】《PostgreSQL指南-內幕探索》-1.資料庫集簇、資料庫和資料表筆記SQL資料庫
- Oracle資料庫記憶體引數調優技術的個人總結 (1)Oracle資料庫記憶體
- 1、引數的接受
- PostgreSQL技術大講堂 - 第32講:資料庫引數調整SQL資料庫
- 軟體測試學習資料——Jmeter引數化1JMeter
- PostgreSQL DBA(139) - PG 12(B-tree index improvement 1#)SQLIndex
- SQL引數資料型別text對於replace函式的引數1無效SQL資料型別函式
- 調整資料庫引數資料庫
- shmall引數設定不當引起資料庫啟動時報out of memory報錯資料庫
- 1、資料庫基礎資料庫