Comandos uteis Linux

Mostrar a hierarquia dos processos – pstree

[oracle@oracle ~]$ pstree
init─┬─acpid
├─atd
├─auditd─┬─audispd───{audispd}
│ └─{auditd}
├─automount───4*[{automount}]
├─avahi-daemon───avahi-daemon
├─bonobo-activati───{bonobo-activati}

Investigar os processos cat /proc/

/

[oracle@oracle ~]$ ps -ef |grep pmon
oracle 4040 1 0 16:01 ? 00:00:00 asm_pmon_+ASM
oracle 12688 11666 0 18:43 pts/4 00:00:00 grep pmon

[oracle@oracle ~]$ cat /proc/4040/status

e varios outros.

Memoria livre atualmente em mega bytes – free

[oracle@oracle ~]$ free -m
total used free shared buffers cached
Mem: 4049 3579 470 0 96 2957
-/+ buffers/cache: 525 3524
Swap: 8189 0 8189

Visualizar as bibliotecas utilizadas pelo processo naquele momento – pstack

[oracle@oracle ~]$ ps -ef |grep pmon
oracle 4040 1 0 16:01 ? 00:00:00 asm_pmon_+ASM
oracle 12688 11666 0 18:43 pts/4 00:00:00 grep pmon
[oracle@oracle ~]$ pstack
Usage: pstack
[oracle@oracle ~]$ pstack 4040
#0 0x00e52410 in __kernel_vsyscall ()
#1 0x00c50feb in poll () from /lib/libc.so.6
#2 0x0bb5750c in ntevpque ()
#3 0x0bb554be in ntevque ()
#4 0x0bb34937 in nsevwait ()
#5 0x084b2b3f in ksnwait ()

Finalizar o processo pelo nome pkill

[oracle@oracle ~]$ ps -ef |grep pmon
oracle 4040 1 0 16:01 ? 00:00:00 asm_pmon_+ASM
oracle 9720 1 0 17:47 ? 00:00:00 ora_pmon_orcl
oracle 12588 11666 0 18:41 pts/4 00:00:00 grep pmon

[oracle@oracle ~]$ pkill -9 -f ora_pmon_orcl
[oracle@oracle ~]$ ps -ef |grep pmon
oracle 4040 1 0 16:01 ? 00:00:00 asm_pmon_+ASM
oracle 12688 11666 0 18:43 pts/4 00:00:00 grep pmon

Visualizar a memoria alocada:

[oracle@oracle ~]$ ipcs -m

– Segmentos da memória compartilhada –
chave shmid proprietário perms bytes nattch status
0x351b2710 458762 oracle 640 85983232 13
0xbe3bb918 2719757 oracle 640 1260388352 33

Visualizar os semaforos:

[oracle@oracle ~]$ ipcs -m

– Segmentos da memória compartilhada –
chave shmid proprietário perms bytes nattch status
0x351b2710 458762 oracle 640 85983232 13
0xbe3bb918 2719757 oracle 640 1260388352 33

Criar os dispositivos – rawdevices e loop

MAKEDEV raw
MAKEDEV loop

Portas em uso no linux e mensagens do KERNEL

Para verificar as portas em uso utilize o NMAP

[root@oracle logs]# nmap -sV 192.168.21.50

Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2009-11-26 13:44 AMT
Interesting ports on oracle.com (192.168.21.50):
Not shown: 1673 closed ports
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 4.3 (protocol 2.0)
80/tcp open http Apache httpd 2.2.3 ((Oracle))
111/tcp open rpcbind 2 (rpc #100000)
682/tcp open status 1 (rpc #100024)
1158/tcp open http Oracle Application Server httpd 9.0.4.1.0
1521/tcp open oracle-tns Oracle TNS Listener 10.2.0.1.0 (for Linux)
5520/tcp open sdlog Oracle Enterprise Manager

[root@oracle logs]# nmap -sV 192.168.21.50 |wc -l
16

ou o LSOF

[root@oracle logs]# lsof -i
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
portmap 2161 rpc 3u IPv4 5460 UDP *:sunrpc
portmap 2161 rpc 4u IPv4 5461 TCP *:sunrpc (LISTEN)
rpc.statd 2196 root 3u IPv4 5587 UDP *:mrm
rpc.statd 2196 root 6u IPv4 5578 UDP *:vpps-via
rpc.statd 2196 root 7u IPv4 5597 TCP *:xfr (LISTEN)
hpiod 2808 root 0u IPv4 7852 TCP localhost.localdomain:2208 (LISTEN)
python 2813 root 4u IPv4 7870 TCP localhost.localdomain:2207 (LISTEN)
sshd 2826 root 3u IPv6 7906 TCP *:ssh (LISTEN)
cupsd 2835 root 4u IPv4 7941 TCP localhost.localdomain:ipp (LISTEN)
cupsd 2835 root 6u IPv4 7944 UDP *:ipp
sendmail 2868 root 4u IPv4 8064 TCP localhost.localdomain:smtp (LISTEN)
avahi-dae 3033 avahi 13u IPv4 8432 UDP *:mdns
avahi-dae 3033 avahi 14u IPv6 8433 UDP *:mdns
avahi-dae 3033 avahi 15u IPv4 8434 UDP *:61200
avahi-dae 3033 avahi 16u IPv6 8435 UDP *:53453
ocssd.bin 3983 oracle 7u IPv4 12009 UDP localhost.localdomain:32291
ocssd.bin 3983 oracle 9u IPv4 12012 UDP localhost.localdomain:41644
ocssd.bin 3983 oracle 10u IPv4 12013 TCP localhost.localdomain:50340 (LISTEN)
ocssd.bin 3983 oracle 11u IPv4 12014 UDP localhost.localdomain:47455
ocssd.bin 3983 oracle 14u IPv4 12019 UDP localhost.localdomain:7847
ocssd.bin 3983 oracle 15u IPv4 12020 TCP localhost.localdomain:19119 (LISTEN)
java 8892 oracle 7u IPv4 714077 TCP *:5520 (LISTEN)
java 8892 oracle 10u IPv4 714078 TCP *:dbcontrol-oms (LISTEN)
java 8892 oracle 25u IPv4 720399 TCP oracle.com:44781->oracle.com:ncube-lm (ESTABLISHED)

[root@oracle logs]# lsof -i:1521 |wc -l
20

[root@oracle logs]# dmesg
Linux version 2.6.18-164.el5PAE ([email protected]) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)) #1 SMP Tue Aug 18 15:59:11 EDT 2009
BIOS-provided physical RAM map:
BIOS-e820: 0000000000010000 – 000000000009f800 (usable)
BIOS-e820: 000000000009f800 – 00000000000a0000 (reserved)
BIOS-e820: 00000000000f0000 – 0000000000100000 (reserved)
BIOS-e820: 0000000000100000 – 00000000bfee0000 (usable)
BIOS-e820: 00000000bfee0000 – 00000000bfee3000 (ACPI NVS)
BIOS-e820: 00000000bfee3000 – 00000000bfef0000 (ACPI data)
BIOS-e820: 00000000bfef0000 – 00000000bff00000 (reserved)
BIOS-e820: 00000000c0000000 – 00000000d0000000 (reserved)
BIOS-e820: 00000000fec00000 – 0000000100000000 (reserved)
BIOS-e820: 0000000100000000 – 0000000140000000 (usable)
4224MB HIGHMEM available.
896MB LOWMEM available.
found SMP MP-table at 000f4f50
Memory for crash kernel (0x0 to 0x0) notwithin permissible range
disabling kdump

Enabling Asynchronous I/O in Oracle 9i and 10g

To enable async I/O in Oracle, the disk_asynch_io parameter needs to be set to true:

disk_asynch_io=true

Note this parameter is set to true by default in Oracle 9i and 10g:

SQL> show parameter disk_asynch_io;

NAME TYPE VALUE
———————————— ———– ——————————
disk_asynch_io boolean TRUE
SQL>

If you use filesystems instead of raw devices, block devices (available in 10gR2) or ASM for datafiles, then you need to ensure that the datafiles reside on filesystems that support asynchronous I/O (e.g., OCFS/OCFS2, ext2, ext3). To do async I/O on filesystems the filesystemio_options parameter needs to be set to “asynch” in addition to disk_asynch_io=true:

filesystemio_options=asynch

This parameter is platform-specific. By default, this parameter is set to none for Linux and thus needs to be changed:

SQL> show parameter filesystemio_options;

NAME TYPE VALUE
———————————— ———– ——————————
filesystemio_options string none
SQL>

The filesystemio_options can have the following values with Oracle9iR2:
asynch: This value enables asynchronous I/O on file system files.
directio: This value enables direct I/O on file system files.
setall: This value enables both asynchronous and direct I/O on file system files.
none: This value disables both asynchronous and direct I/O on file system files.

If you also want to enable Direct I/O Support which is available in RHEL 3/4, set filesystemio_options to “setall”.

Ensure that the datafiles reside on filesystems that support asynchronous I/O (e.g., OCFS, ext2, ext3).

Tuning Asynchronous I/O for Oracle 9i and 10g

For RHEL 3 it is recommended to set aio-max-size to 1048576 since Oracle uses I/Os of up to 1MB. It controls the maximum I/O size for asynchronous I/Os. Note this tuning parameter is not applicable to 2.6 kernel, i.e RHEL 4.

To determine the maximum I/O size in bytes, execute:

$ cat /proc/sys/fs/aio-max-size
131072

To change the maximum number of bytes without reboot:

# echo 1048576 > /proc/sys/fs/aio-max-size

Alternatively, you can use sysctl(8) to change it:

# sysctl -w fs.aio-max-size=1048576

To make the change permanent, add the following line to the /etc/sysctl.conf file. This file is used during the boot process:

$ echo “fs.aio-max-size=1048576” >> /etc/sysctl.conf

Checking Asynchronous I/O Usage

To verify whether $ORACLE_HOME/bin/oracle was linked with async I/O, you can use the Linux commands ldd and nm.

In the following example, $ORACLE_HOME/bin/oracle was relinked with async I/O:

$ ldd $ORACLE_HOME/bin/oracle | grep libaio
libaio.so.1 => /usr/lib/libaio.so.1 (0x0093d000)
$ nm $ORACLE_HOME/bin/oracle | grep io_getevent
w io_getevents@@LIBAIO_0.1
$

In the following example, $ORACLE_HOME/bin/oracle has NOT been relinked with async I/O:

$ ldd $ORACLE_HOME/bin/oracle | grep libaio
$ nm $ORACLE_HOME/bin/oracle | grep io_getevent
w io_getevents
$

Referencia:

http://www.puschitz.com/TuningLinuxForOracle.shtml

Pacotes faltantes redhat 5 produzem erro no instalador do Banco

O Oracle database ao ser instalado no redhat 5, necessita de todos os pacotes que são solicitados pelo instalador:

rpm -qa –queryformat “%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})n” | grep glibc-devel

Observe a notacao X86_64 ou seja deve ser tanto para instalacoes 64 bits ou 32 bits.

binutils-2.17.50 (x86_64)
compat-db-4.2.52 (x86_64)
compat-libstdc++-296(i386)
compat-libstdc++-33-3.2.3 (x86_64)
compat-libstdc++-33-3.2.3(i386)
control-center-2.16.0 (x86_64)
gcc-4.1.1 (x86_64)
gcc-c++-4.1.1 (x86_64)
glibc-2.5-12 (x86_64)
glibc-2.5-12 (i686)
glibc-common-2.5-12 (x86_64)
glibc-devel-2.5-12 (x86_64)
glibc-devel-2.5-12(i386)
glibc-headers-2.5-12 (x86_64)
ksh-20060214-1.4 (x86_64)
libaio-0.3.96 (x86_64)
libgcc-4.1.1(i386)
libgcc-4.1.1(x86_64)
libgnome-2.16.0 (x86_64)
libgnomeui-2.16.0 (x86_64)
libgomp-4.1.1 (x86_64)
libstdc++-4.1.1 (x86_64)
libstdc++-devel-4.1.1 (x86_64)
libXp-1.0.0-8 (i386)
make-3.81 (x86_64)
sysstat-7.0.0 (x86_64)

Para resolver alguns pacotes use a ULN

http://public-yum.oracle.com/

http://public-yum.oracle.com/repo/EnterpriseLinux/EL5/0/base/i386/

libXp package is missing from list of packages required to install Oracle
10.2 on RHEL 5 in the Release Notes

libXp.so.6 missing

problema xorg-x11-depreciated-libs-6.8.2-1.EL.13.6.i386.rpm

Para resolver o problema baixe a biblioteca faltante do site da Oracle e instale no seu servidor:

http://public-yum.oracle.com/repo/EnterpriseLinux/EL5/0/base/i386/libXp-1.0.0-8.i386.rpm

rpm -i libXp-1.0.0-8.i386.rpm

se caso ainda persistir por erro do sistema operacional rode com a opcao abaixo:

./runInstaller -ignoreSysPrereqs

Movimentar os datafiles

As vezes, se faz necessário movimentar os datafiles para outros locais, outros discos ou o ASM. Entao usamos os comandos abaixo. Na versão 10g inclusive, podemos mover o banco de dados todo para o ASM. No exemplo é demonstrado como movimentar o datafile a quente para outro disco – poderia ser o ASM sem maiores problemas.

C:>rman target /

Recovery Manager: Release 10.1.0.4.2 – Production

Copyright (c) 1995, 2004, Oracle. All rights reserved.

conectado ao banco de dados de destino: INFRA (DBID=3796089948)

RMAN> backup as copy tablespace users format ‘e:users.dbf’;

Iniciando backup em 05/11/09
usar o arquivo de controle do banco de dados de destino em vez do catßlogo de re
cuperaþÒo
canal alocado: ORA_DISK_1
canal ORA_DISK_1: sid=370 devtype=DISK
canal ORA_DISK_1: iniciando c¾pia de arquivo de dados
fno=00002 name=C:ORACLEUSERS01.DBF do arquivo de dados de entrada
nome do arquivo de saÝda=E:USERS.DBF tag=TAG20091105T144322 recid=56 stamp=7021
39411
canal ORA_DISK_1: c¾pia de arquivo de dados concluÝda; tempo decorrido: 00:00:15

Finalizado backup em 05/11/09

RMAN> sql ‘alter tablespace users offline immediate’;

instruþÒo sql: alter tablespace users offline immediate

RMAN> switch tablespace users to copy;

arquivo de dados 2 alternado para a c¾pia de arquivo de dados “E:USERS.DBF”

RMAN> sql ‘alter tablespace users online’;

instruþÒo sql: alter tablespace users online
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of sql command on default channel at 11/05/2009 14:44:41
RMAN-11003: failure during parse/execution of SQL statement: alter tablespace us
ers online
ORA-01113: o arquivo 2 precisa da recuperaþÒo de mÝdia
ORA-01110: 2 do arquivo de dados: ‘E:USERS.DBF’

RMAN> recover tablespace users;

Iniciando recover em 05/11/09
utilizando o canal ORA_DISK_1

iniciar recuperaþÒo de mÝdia
recuperaþÒo de mÝdia concluÝda

Finalizado recover em 05/11/09

RMAN> sql ‘alter tablespace users online’;

instruþÒo sql: alter tablespace users online

RMAN>