Linux上安装oracle的注意点
今天看了《tuning and optimizing rhel for oracle 9i and 10g databases》这篇文的,感觉讲得不错,对linux下的管理有了一定的认识,这里记录下一些内容(主要是一些安装时需要调整的内核参数,其它还有一些技术细节可查看这份文档,是个不错的参考)
1、swap的设置
RAMSwap Space
--------------------------------------------
1 GB - 2 GB1.5 times the size of RAM
2 GB - 8 GBEqual to the size of RAM
more than 8GB0.75 times the size of RAM
一些实时的内存变化,可查看/proc/meminfo,这里包括内存的所有内容(swap,ram,hugepage ……)
2、Setting SHMMAX Parameter
Shmmax表示一个共享内存段的最大值,由于sga都是在共享内存段中,所以,这个值的建议是等于sga的大小。另外,查看oracle使用的共享内存段的大小,可通过
Ipcs –m
如果共享内存段不足,有可能会报:
ORA-27123: unable to attach to shared memory segment
修改共享内存段可通过如下途径:
To determine the maximum size of a shared memory segment, run:
# cat /proc/sys/kernel/shmmax
2147483648
The default shared memory limit for SHMMAX can be changed in the proc file system without reboot:
# echo 2147483648 > /proc/sys/kernel/shmmax
Alternatively, you can use sysctl(8) to change it:
# sysctl -w kernel.shmmax=2147483648
To make a change permanent, add the following line to the file /etc/sysctl.conf (your setting may vary). This file is used during the boot process.
# echo "kernel.shmmax=2147483648" >> /etc/sysctl.conf
3、Setting SHMMNI Parameter
Shmmni表示最大的共享内存段的数量,这个值对于oracle 9i和10g基本都是4096(默认值)。
查看和设置shmmni的值:
To determine the system wide maximum number of shared memory segments, run:
# cat /proc/sys/kernel/shmmni
4096
The default shared memory limit for SHMMNI can be changed in the proc file system without reboot:
# echo 4096 > /proc/sys/kernel/shmmni
Alternatively, you can use sysctl(8) to change it:
# sysctl -w kernel.shmmni=4096
To make a change permanent, add the following line to the file /etc/sysctl.conf. This file is used during the boot process.
# echo "kernel.shmmni=4096" >> /etc/sysctl.conf
4、Setting SHMALL Parameter
Shmall表示所有的共享页(shared segment pages)的数量,这个值通常为shmmax/PAGE_SIZE
而一般情况下,page_size=4096(4K),如何获得os的page_size呢
$ getconf PAGE_SIZE
4096
查看和设置该值:
To determine the system wide maximum number of shared memory pages, run:
# cat /proc/sys/kernel/shmall
2097152
The default shared memory limit for SHMALL can be changed in the proc file system without reboot:
# echo 2097152 > /proc/sys/kernel/shmall
Alternatively, you can use sysctl(8) to change it:
# sysctl -w kernel.shmall=2097152
To make a change permanent, add the following line to the file /etc/sysctl.conf. This file is used during the boot process.
# echo "kernel.shmall=2097152" >> /etc/sysctl.conf
5、Removing Shared Memory
有的时候,我们通过ipcs –m观察共享内存段时,会发现如下情况:
$ ipcs -m
------ Shared Memory Segments --------
keyshmidownerpermsbytesnattchstatus
0x8f6e2129 98305oracle600776945230
0x2f629238 65536oracle6402736783360 35
0x00000000 32768oracle6402736783360 0dest
Status为dest表示该共享内存段是没用的,但是又不能释放掉,所以,我们需要手工把它给删除掉。
我们可以通过如下命令查看status为dest的更为细致的信息:
$ ipcs -m -i 32768
Shared memory Segment shmid=32768
uid=500 gid=501 cuid=500 cgid=501
mode=0640 access_perms=0640
bytes=2736783360 lpid=3688 cpid=3652 nattch=0
att_time=Sat Oct 29 13:36:52 2005
det_time=Sat Oct 29 13:36:52 2005
change_time=Sat Oct 29 11:21:06 2005
删除该共享内存段,需要执行以下命令:
$ ipcrm shm 32768
还有一种办法是使用oracle的sysresv命令,具体参考该文档内容
6、hugepage
如果os的系统内存超过了64g,那么就可以使用hugepage了,这样,就能更高效得使用共享内存,因为hugepage不会被swap out,而且,在寻址方面,有更高的性能。
下面可查看hugepage的一些基本设置
$ grep Huge /proc/meminfo
HugePages_Total:
HugePages_Free:
Hugepagesize:2048 kB
默认情况下,Hugepagesize都是2M,那么如果我们有充足的RAM,我们需要怎么配置Hugepage呢,一般情况下,让它等于oracle的sga大小就可以了。
设置vm.nr_hugepages =4096就可以了,具体,可参考metalink ID 744769.1
^_^,就到这里了,其它的也不作详细记录了。