有意思的问题,12G内存的服务器,该如何配置?

14 views
Skip to first unread message

刘鑫

unread,
Jan 11, 2010, 8:18:02 PM1/11/10
to edb-china
早上看到有人在问,觉得很有意思,我转过来,看看各位专家的意见:)。

问个postgresql内存设定的问题。在32位的linux中,postgresql8.1.11如何合理的设定内存?系统有12G的内存。机器除了postgresql不跑别的东西。有做过类似的给点意见吧

--
每一行代码都应该出自我手,工具可以帮我写,但不能替我写,更不能替我思考。
……

劉鑫
March.Liu

Zoom.Quiet

unread,
Jan 11, 2010, 8:20:20 PM1/11/10
to marc...@gmail.com, edb-china
2010/1/12 刘鑫 <marc...@gmail.com>:

> 早上看到有人在问,觉得很有意思,我转过来,看看各位专家的意见:)。
>
> 问个postgresql内存设定的问题。在32位的linux中,postgresql8.1.11如何合理的设定内存?系统有12G的内存。机器除了postgresql不跑别的东西。有做过类似的给点意见吧
>
32位的系统,最多可以使用 8G 内存吧,多了没有用的...

> --
> 每一行代码都应该出自我手,工具可以帮我写,但不能替我写,更不能替我思考。
> ……
>
> 劉鑫
> March.Liu
>


--
http://zoomquiet.org 人生苦短? Pythonic!
Free as in Freedom! 哲思社区:http://zeuux.com

Xia Qingran

unread,
Jan 12, 2010, 12:10:13 AM1/12/10
to zoom....@gmail.com, marc...@gmail.com, edb-china
Zoom.Quiet wrote:
> 32位的系统,最多可以使用 8G 内存吧,多了没有用的...
>
>
32bit系统不用的话只能认出来3GB多一点内存。且据称PAE不太靠谱。

所以要用12GB的话,首先要用64bit系统,而且系统内核参数需要调整。
给一个我的一个8GB内存的FreeBSD 7.2 amd64版的内核调整,并且这台机器不仅仅
跑DB还跑web,所以把这些参数适当加大吧(例如 *2):

/boot/loader.conf

kern.ipc.semmni=256
kern.ipc.semmns=512
kern.ipc.semmnu=256
kern.ipc.shmmni=8192
kern.maxproc=6000
kern.maxusers=384
kern.ipc.nmbclusters=65536

================================

/etc/sysctl.conf

#4096MB
kern.ipc.shmmax=4294967296
#1024MB/4096(page size)
kern.ipc.shmall=1048576
kern.ipc.shm_allow_removed=1
kern.ipc.shm_use_phys=1

kern.ipc.semmap=256
kern.ipc.maxsockets=131072
kern.ipc.somaxconn=16384
kern.threads.max_threads_per_proc=4096

kern.maxfiles=163840
kern.maxfilesperproc=32768

vfs.ufs.dirhash_maxmem=8388608
vfs.ufs.dirhash_minsize=1048576

net.inet.tcp.sendspace=65535
net.inet.tcp.recvspace=65535
net.inet.udp.maxdgram=65535

# release the connection faster
net.inet.tcp.keepinit=7500
net.inet.tcp.keepidle=7500
net.inet.tcp.keepintvl=5000

net.local.stream.sendspace=65535
net.local.stream.recvspace=65535

net.inet.tcp.msl=2500
net.inet.icmp.icmplim=8
net.inet.icmp.icmplim_output=1

# shutdown the coredump
kern.corefile=/tmp/%N.core
kern.nodump_coredump=1
kern.coredump=0

=========================================
PostgreSQL的参数,PostgreSQL 8.4:

shared_buffers = 2048MB # min 128kB or max_connections*16kB
# (change requires restart)
temp_buffers = 32MB # min 800kB
max_prepared_transactions = 200 # can be 0 or more, 0 to shutdown
the prepared transactions.
# (change requires restart)
# Note: Increasing max_prepared_transactions costs ~600 bytes of shared
memory
# per transaction slot, plus lock space (see max_locks_per_transaction).
work_mem = 8MB # min 64kB
maintenance_work_mem = 1024MB # min 1MB
max_stack_depth = 8MB # min 100kB


>> --
>> 每一行代码都应该出自我手,工具可以帮我写,但不能替我写,更不能替我思考。
>> ……
>>
>> 劉鑫
>> March.Liu
>>
>>
>
>
>
>
>


--
夏清然
Xia Qingran
E-mail: qin...@zeuux.org
Gtalk: qingr...@gmail.com
MSN: super...@msn.com

Reply all
Reply to author
Forward
0 new messages