Chinaunix首页 | 论坛 | 博客
  • 博客访问: 360318
  • 博文数量: 80
  • 博客积分: 2056
  • 博客等级: 大尉
  • 技术积分: 961
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-19 12:17
文章分类

全部博文(80)

文章存档

2011年(9)

2010年(13)

2009年(41)

2008年(17)

我的朋友

分类: Oracle

2010-01-18 11:41:22

 
  MEMORY_TARGET not supported on this system
Oracle9i引入pga_aggregate_target,可以自动对PGA进行调整;Oracle10引入sga_target,可以自动对 SGA进行调整。Oracle11g则对这两部分进行综合,引入memory_target,可以自动调整所有的内存,这就是新引入的自动内存管理特性。
SQL> alter system set memory_target=200m scope=spfile;

System altered.

SQL> alter system set memory_target=200m scope=spfile;

System altered.

SQL> alter system set sga_target=0 scope=spfile;

System altered.

SQL> alter system set pga_aggregate_target=0 scope=spfile;

System altered.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup
ORACLE instance started.

Total System Global Area  209235968 bytes
Fixed Size                  1298920 bytes
Variable Size             150998552 bytes
Database Buffers           54525952 bytes
Redo Buffers                2412544 bytes
Database mounted.
Database opened.

设 置memory_target参数后,实际上Oracle会自动设置并调整两个以双下划线开头的隐含参数来分配SGA和PGA的内存,这和 Oracle10g自动设置sga_target后分配db_cache_size和shared_pool_size的机制是一样的
SQL> select a.ksppinm name,b.ksppstvl value
  2  from x$ksppi a,x$ksppcv b
  3  where a.indx=b.indx
  4  and (a.ksppinm like '%sga_target%'
  5   or a.ksppinm like '%pga_aggregate_target%');

NAME                                     VALUE
---------------------------------------- ------------------------------
sga_target                               0
__sga_target                             125829120
pga_aggregate_target                     0
__pga_aggregate_target                   79691776

如果memory_max_target/memory_target设置过大,可能导致instance无法启动,报ORA-00845错误
SQL> alter system set memory_max_target=300m scope=spfile;

System altered.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORA-00845: MEMORY_TARGET not supported on this system

这 个错误有点误导,实际上这并不是说该平台版本上不支持AMM特性,只是设置的memory_max_target超过了系统中设置的share memory(/dev/shm)而已。在Oracle11g for linux中似乎使用了一种新的机制来管理共享内存段,而不是传统的sys v shm了。在alert.ora中可以找到更准确的错误描述

    Starting ORACLE instance (normal)
    WARNING: You are trying to use the MEMORY_TARGET feature. This feature requires the /dev/shm file system to be mounted for at least 314572800 bytes. /dev/shm is either not mounted or is mounted with available space less than this size. Please fix this so that MEMORY_TARGET can work as expected. Current available is 209715200 and used is 0 bytes.
    memory_target needs larger /dev/shm

所以,这个错误有两种解决方法。第一种自然是减少memory_max_target/memory_target。第二种则是增加/dev/shm
[root@localhost ~]# df -k /dev/shm
Filesystem           1K-blocks      Used Available Use% Mounted on
shmfs                   204800         0    204800   0% /dev/shm

[root@localhost ~]# umount /dev/shm
[root@localhost ~]# mount -t tmpfs shmfs -o size=300m /dev/shm

[root@localhost ~]# df -k /dev/shm
Filesystem           1K-blocks      Used Available Use% Mounted on
shmfs                   358400         0    358400   0% /dev/shm

[root@localhost trace]# ls -l /dev/shm
total 0

增加/dev/shm后再次启动instance
SQL> startup
ORACLE instance started.

Total System Global Area  313860096 bytes
Fixed Size                  1299624 bytes
Variable Size             255855448 bytes
Database Buffers           50331648 bytes
Redo Buffers                6373376 bytes
Database mounted.
Database opened.

再来看/dev/shm中的内容
[root@localhost trace]# df -k /dev/shm
Filesystem           1K-blocks      Used Available Use% Mounted on
shmfs                   307200    122792    184408  40% /dev/shm
[root@localhost trace]# ls -l /dev/shm
total 122792
-rw-r----- 1 oracle oinstall 4194304 Sep 10 21:15 ora_ning_1179659_0
-rw-r----- 1 oracle oinstall 4194304 Sep 10 21:15 ora_ning_1179659_1
-rw-r----- 1 oracle oinstall       0 Sep 10 21:15 ora_ning_1179659_10
-rw-r----- 1 oracle oinstall       0 Sep 10 21:15 ora_ning_1179659_11
-rw-r----- 1 oracle oinstall       0 Sep 10 21:15 ora_ning_1179659_12
-rw-r----- 1 oracle oinstall       0 Sep 10 21:15 ora_ning_1179659_13
......


附: /dev/shm 使用:

巧用tmpfs加速你的linux服务器
使用虚拟磁盘来存放squid的缓存文件和php的seesion。速度快不少哦!

默认系统就会加载/dev/shm ,它就是所谓的tmpfs,有人说跟ramdisk(虚拟磁盘),但不一样。象虚拟磁盘一样,tmpfs 可 以使用您的 RAM,但它也可以使用您的交换分区来存储。而且传统的虚拟磁盘是个块设备,并需要一个 mkfs 之类的命令才能真正地使用 它,tmpfs 是一个文件系统,而不是块设备;您只是安装它,它就可以使用了。

tmpfs有以下优势:
1。动态文件系统的大小,
2。tmpfs 的另一个主要的好处是它闪电般的速度。因为典型的 tmpfs 文件系统会完全驻留在 RAM 中,读写几乎可以是瞬间的。
3。tmpfs 数据在重新启动之后不会保留,因为虚拟内存本质上就是易失的。所以有必要做一些脚本做诸如加载,绑定的操作。

好了讲了一些大道理,大家看的烦了吧,还是讲讲我的应用吧:)

首先在/dev/shm建个tmp文件夹,然后与实际/tmp绑定

mkdir /dev/shm/tmp
chmod 1777 /dev/shm/tmp
mount --bind /dev/shm/tmp /tmp


1. squid的缓存目录设置

vi /etc/squid/squid.conf

修改成
cache_dir ufs /tmp 256 16 256
这里的第一个256表示使用256M内存,我觉得 /441672019.shtml里使用ramdisk的方法还不如直接使用tmpfs,至少每次启动不用mkfs,还可以动态改变大小。这时的/tmp 实际就是/dev/shm/tmp

然后重启一下服务,ok,现在所有的squid缓存文件都保存倒tmpfs文件系统里了,很快哦。


2. 对php性能的优化

对于一个访问量大的以apache+php的网站,可能tmp下的临时文件都会很多,比如seesion或者一些缓存文件,那么你可以把它保存到tmpfs文件。

保存seesion的方法很简单了只要修改php.ini就行了,由于我已经把/dev/stm/tmp与/tmp绑定,所以不改写也行,至于php程序产生的缓存文件那只能改自己的php程序了:)

至于tmpfs的其他应用,我想大家可能通过这篇文章会有所启发。

阅读(2137) | 评论(0) | 转发(0) |
0

上一篇:oracle 常用函数

下一篇:Oracle常见等待事件

给主人留下些什么吧!~~