Tuesday, February 23, 2010

Oracle Database 11gr2 - MEMORY_TARGET e /dev/shm

Olá,

Continuando os testes com o Oracle Database 11gr2 conforme o tempo livre que tenho,fiz alguns testes diminuindo a quantidade de memória RAM da VM .Como estava com o Oracle Restart habilitado,após subir o servidor de banco de dados logo teria os serviços disponíveis para uso.

[oracle@marte ~]$
[oracle@marte ~]$ echo $ORACLE_HOME
/u01/app/oracle/product/11.2.0/dbhome_1
[oracle@marte ~]$ echo $ORACLE_SID
dbpost
[oracle@marte ~]$ ps -ef|grep pmon
oracle    2997     1  0 08:42 ?        00:00:00 asm_pmon_+ASM
oracle    3118     1  0 08:43 ?        00:00:00 ora_pmon_dbpost
oracle    4083  3444  0 09:58 pts/2    00:00:00 grep pmon
[oracle@marte ~]$ ps -ef|grep tns
oracle    2908     1  0 08:41 ?        00:00:00 /u01/app/oracle/product/11.2.0/grid/bin/tnslsnr LISTENER -inherit
oracle    4086  3444  0 09:59 pts/2    00:00:00 grep tns
[oracle@marte ~]$


Bom parece que o banco de dados está disponível

[oracle@marte ~]$
[oracle@marte ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Tue Feb 23 10:02:19 2010

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Connected to an idle instance.

idle on 23-FEB-10 >
idle on 23-FEB-10 >select * from v$instance;
select * from v$instance
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 0 Serial number: 0

Elapsed: 00:00:00.17
idle on 23-FEB-10 >


Há algo errado.

Vamos ao alert log

[oracle@marte /]$ cd /u01/app/oracle/diag/rdbms/dbpost/dbpost/alert/
[oracle@marte alert]$ ls -ltrh
total 6.6M
-rw-r----- 1 oracle dba 6.6M Feb 23 09:36 log.xml
[oracle@marte alert]$
[oracle@marte alert]$ tail -20f log.xml
</msg>
<msg time='2010-02-23T09:36:06.048-02:00' org_id='oracle' comp_id='rdbms'
 msg_id='opistr_real:935:3971575317' type='NOTIFICATION' group='startup'
 level='16' host_id='marte' host_addr='127.0.0.1'
 pid='3479'>
 <txt>Starting ORACLE instance (normal)
 </txt>
</msg>
<msg time='2010-02-23T09:36:06.075-02:00' org_id='oracle' comp_id='rdbms'
 type='UNKNOWN' level='16' host_id='marte'
 host_addr='127.0.0.1' pid='3479'>
 <txt>WARNING: You are trying to use the MEMORY_TARGET feature. This feature requires the /dev/shm file system to be mounted for at least 536870912 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 322220032 and used is 474198016 bytes. Ensure that the mount point is /dev/shm for this directory.
 </txt>
</msg>
<msg time='2010-02-23T09:36:06.092-02:00' org_id='oracle' comp_id='rdbms'
 type='UNKNOWN' level='16' host_id='marte'
 host_addr='127.0.0.1' pid='3479'>
 <txt>memory_target needs larger /dev/shm
 </txt>
</msg>


Analisando o erro acima vamos ver o filesystem /dev/shm

[root@marte /]# df -Ph
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              23G   15G  6.7G  70% /
tmpfs                 760M  453M  308M  60% /dev/shm

[root@marte /]# cat /proc/meminfo
MemTotal:      1555508 kB
MemFree:        315880 kB
Buffers:         64700 kB
Cached:         968316 kB
SwapCached:          0 kB
Active:         423800 kB
Inactive:       769132 kB
HighTotal:      655296 kB
HighFree:         1168 kB
LowTotal:       900212 kB
LowFree:        314712 kB
SwapTotal:     1574360 kB
SwapFree:      1574360 kB
Dirty:             468 kB
Writeback:           0 kB
AnonPages:      159928 kB
Mapped:          91568 kB
Slab:            29760 kB
PageTables:       9068 kB
NFS_Unstable:        0 kB
Bounce:              0 kB
CommitLimit:   2352112 kB
Committed_AS:  1866740 kB
VmallocTotal:   114680 kB
VmallocUsed:      3280 kB
VmallocChunk:   111252 kB
HugePages_Total:     0
HugePages_Free:      0
HugePages_Rsvd:      0
Hugepagesize:     4096 kB
[root@marte /]#


Vamos ver o tamanho alocado no paramtreo MEMORY_TARGET :

[oracle@marte /]$ cd $ORACLE_HOME/dbs
[oracle@marte dbs]$ vi initdbpost.ora
...

*.memory_target=512m
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'


Ok.

O erro está ocorrendo porque não temos 512MB disponíveis no /dev/shm .Isto ocorre porque como não configurei o /dev/shm e tenho somente 1536MB de RAM alocado para esta VM.

Vou retirar totalmente o banco de dados dbpost do Oracle Restart :

[oracle@marte dbs]$ cd /
[oracle@marte /]$ srvctl disable database -d dbpost
[oracle@marte /]$

[root@marte /]# ps -ef|grep pmon
oracle    2997     1  0 08:42 ?        00:00:00 asm_pmon_+ASM
root      4774  4362  0 11:39 pts/2    00:00:00 grep pmon
[root@marte /]#

Para efeito de testes não quero alterar o tamanho da memória RAM.Vamos alterar o /dev/shm  que ainda está com valores default no meu SO.

Pode-se fazer via comando direto no shell/terminal,mas no caso para ficar definitivo após o boot vou colocá-lo no /etc/fstab .

root@marte /]# cat /etc/fstab
LABEL=/                 /                       ext3    defaults        1 1
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-sda2         swap                    swap    defaults        0 0
[root@marte /]#

Fazendo o remount do /dev/shm

[root@marte /]# mount -o remount,size=1G /dev/shm
[root@marte /]#

Alocando o espaço para ficar disponível na inicialização do sistema :

[root@marte /]# vi /etc/fstab

[root@marte /]# cat /etc/fstab
LABEL=/                 /                       ext3    defaults        1 1
tmpfs                   /dev/shm                tmpfs   defaults,size=1024m,auto        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-sda2         swap                    swap    defaults        0 0
[root@marte /]#

 reboot :

[root@marte /]# shutdown -r now


Broadcast message from root (pts/2) (Tue Feb 23 11:50:40 2010):


The system is going down for reboot NOW!
[root@marte /]#

Curiosidade  - Oracle Restart em ação
[root@marte ~]# tail -f /var/log/messages
Feb 23 11:52:34 localhost smartd[2568]: Device: /dev/sde, IE (SMART) not enabled, skip device Try 'smartctl -s on /dev/sde' to turn on SMART features
Feb 23 11:52:34 localhost smartd[2568]: Unable to register SCSI device /dev/sde at line 36 of file /etc/smartd.conf
...
Feb 23 11:52:37 localhost pcscd: winscard.c:219:SCardConnect() Reader E-Gate 0 0 Not Found
Feb 23 11:52:37 localhost last message repeated 3 times
Feb 23 11:52:38 localhost /u01/app/oracle/product/11.2.0/grid/bin/crswrapexece.pl[2552]: executing "/u01/app/oracle/product/11.2.0/grid/bin/ohasd.bin reboot"

Após o boot total,vamos tentar subir a instance dbpost.

Abaixo podemos ver que o /dev/shm está com a tamanho que foi colocado no /etc/fstab

[root@marte ~]# df -Ph
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              23G   15G  6.7G  70% /
tmpfs                 1.0G  154M  871M  16% /dev/shm
[root@marte ~]#

Startup no dbpost :

[oracle@marte dbs]$ ps -ef|grep pmon
oracle    2994     1  0 11:53 ?        00:00:00 asm_pmon_+ASM
oracle    3124  2948  0 12:00 pts/2    00:00:00 grep pmon
[oracle@marte dbs]$ strings spfiledbpost.ora |grep memory
*.memory_target=512m
[oracle@marte dbs]$ srvctl start database -d dbpost -o open
PRCR-1079 : Failed to start resource ora.dbpost.db
CRS-2501: Resource 'ora.dbpost.db' is disabled
[oracle@marte dbs]$
[oracle@marte dbs]$
[oracle@marte dbs]$ echo $ORACLE_HOME
/u01/app/oracle/product/11.2.0/dbhome_1
[oracle@marte dbs]$ echo $ORACLE_SID
dbpost
[oracle@marte dbs]$ sqlplus "/ as sysdba"


SQL*Plus: Release 11.2.0.1.0 Production on Tue Feb 23 12:03:58 2010


Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to an idle instance.


idle on 23-FEB-10 >startup nomount ;
ORACLE instance started.


Total System Global Area  535662592 bytes
Fixed Size                  1337720 bytes
Variable Size             364906120 bytes
Database Buffers          163577856 bytes
Redo Buffers                5840896 bytes
idle on 23-FEB-10 >alter database mount ;


Database altered.


Elapsed: 00:00:05.45
idle on 23-FEB-10 >alter database open;


Database altered.


Elapsed: 00:00:22.07
idle on 23-FEB-10 >exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@marte dbs]$ sqlplus "/ as sysdba"


SQL*Plus: Release 11.2.0.1.0 Production on Tue Feb 23 12:05:57 2010


Copyright (c) 1982, 2009, Oracle.  All rights reserved.



Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options


sys@DBPOST on 23-FEB-10 >select open_mode from v$database ;


OPEN_MODE
--------------------
READ WRITE


Elapsed: 00:00:00.03
sys@DBPOST on 23-FEB-10 >exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
[oracle@marte dbs]$


Links para maiores informações :


http://www.oracle-base.com/articles/linux/LargeSGAOnLinux.php


metalink.oracle.com/ - Note ID 260152.1


Abs,

Júlio César Corrêa



No comments: