我使用了PostgreSQL的文档来设置它,例如以下配置:
>>> cat /proc/meminfo
MemTotal: 16345480 kB
MemFree: 1770128 kB
Buffers: 382184 kB
Cached: 10432632 kB
SwapCached: 0 kB
Active: 9228324 kB
Inactive: 4621264 kB
Active(anon): 7019996 kB
Inactive(anon): 548528 kB
Active(file): 2208328 kB
Inactive(file): 4072736 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 3432 kB
Writeback: 0 kB
AnonPages: 3034588 kB
Mapped: 4243720 kB
Shmem: 4533752 kB
Slab: 481728 kB
SReclaimable: 440712 kB
SUnreclaim: 41016 kB
KernelStack: 1776 kB
PageTables: 39208 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 8172740 kB
Committed_AS: 14935216 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 399340 kB
VmallocChunk: 34359334908 kB
HardwareCorrupted: 0 kB
AnonHugePages: 456704 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 12288 kB
DirectMap2M: 16680960 kB
>>> ipcs -l
------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 4316816
max total shared memory (kbytes) = 4316816
min seg size (bytes) = 1
------ Semaphore Limits --------
max number of arrays = 128
max semaphores per array = 250
max semaphores system wide = 32000
max ops per semop call = 32
semaphore max value = 32767
------ Messages Limits --------
max queues system wide = 31918
max size of message (bytes) = 8192
default max size of queue (bytes) = 16384
sysctl.conf提取,由我计算:
kernel.shmall = 1079204
kernel.shmmax = 4420419584
postgresql.conf非默认值,由我计算:
max_connections = 60 # (change requires restart)
shared_buffers = 4GB # min 128kB
work_mem = 4MB # min 64kB
wal_sync_method = open_sync # the default is the first option
checkpoint_segments = 16 # in logfile segments, min 1, 16MB each
checkpoint_completion_target = 0.9 # checkpoint target duration, 0.0 - 1.0
effective_cache_size = 6GB
这样合适吗?如果不是(或不一定),在哪种情况下合适?
我们确实注意到此配置的性能有了很好的改进,您将如何改进呢?
如何计算内核内存管理参数?
谁能解释一下如何从头开始真正设置它们?