caterinhuang

Getting Partition Information Behind the Oracleasm Label

In RHEL, there is option to use oracleasm library to label ASM disk. When ASM labelling is used, we may find it difficult to get  which disk is behind this ASM disk. We can use below asmtool library command to check whether that disk is already marked as ASM partition or not

oracleasm querydisk <device name>

But to check which Linux Partition a ASM disk belong to, we need to do further checking.

$ ls -ltrh /dev/oracleasm/disks/ brw-rw---- 1 oracle dba 8, 144 Jul 27 16:07 DATA01

From above output, we can see that there are 2 numbers after the owner group. These two numbers reflect the Linux partition major/minor number. In this case, the major number is 8 and the minor number is 144.

We can check these two numbers belong to which partition from /proc/partitions file

$ cat /proc/partitions
...
 8 144 537120000 sdj
 8 160 537120000 sdk
...

From above output, we can see that partition with major number 8 and minor number 144 is sdj. Thus DATA01 is mapped to /dev/sdj in this environment

Checking RMAN Backup Job Progress

Performing database backup is part of daily Database Administrator task. Often this backup process takes long time. It is important to know the progress of RMAN Backup job. We can use below query to check the RMAN backup progress

SQL> SELECT SID, SERIAL#, OPNAME, CONTEXT, TIME_REMAINING, SOFAR, TOTALWORK,ROUND(SOFAR/TOTALWORK*100,2) "%_COMPLETE" 
FROM GV$SESSION_LONGOPS 
WHERE OPNAME LIKE 'RMAN%'AND TOTALWORK != 0 
AND SOFAR  TOTALWORK;

Melakukan backup database merupakan bagian dari tugas penting seorang Database Administrator. Namun seringkali proses backup ini memakan waktu yang cukup lama. Sedangkan jika dalam environment hardware yang terbatas, proses backup ini sering mengganggu performance database. Seorang DBA sering didesak untuk menjawab pertanyaan berapa lama lagi waktu yang diperlukan sampai backup selesai. Dan dari pengalaman saya, script berikut cukup menolong dan cukup akurat. Script ini saya modifikasi dari script yang didapat dari rekan saya.

SQL> SELECT SID, SERIAL#, OPNAME, CONTEXT, TIME_REMAINING, SOFAR, TOTALWORK,ROUND(SOFAR/TOTALWORK*100,2) "%_COMPLETE" 
FROM GV$SESSION_LONGOPS 
WHERE OPNAME LIKE 'RMAN%'AND TOTALWORK != 0 
AND SOFAR  TOTALWORK;

Useful SQLPLUS Shortcut Summary

SQLplus is one of the most used Oracle tools. Usually we use sqlplus to execute SQL command or another database administration task. SQLplus is available in various platform. In this article, I would like to introduce some useful shortcuts which will help us in our daily activities in this tools.

1. Define a default text editor to do editing on sqlplus

define _editor=vi

or if you are using Windows, you can use

define _editor=notepad

2. Show the last SQL command which is stored in the buffer

SQL> LIST

or use a shortcut l

 SQL> l

3. Execute the last SQL command which is stored in the buffer

 SQL> RUN

Or use a shortcut /

 SQL> /

4. Edit the last SQL command which is stored in the buffer using the default text editor.

SQL> edit

Or use a shortcut ed

 SQL> ed

5. Run a SQL script

SQL> START

Or use a shortcut @

 SQL> @

6. Store the screen output of sqlplus to a file

SQL> spool namafile

7. Show the environment variable of sqlplus

SQL> SHOW ALL

8. Update the environment variabel of sqlplus

SQL> set  namavariabel nilaivariabel

Example:

SQL> set linesize 200

9. Save the command which stored in a buffer to a file

SQL> save namafile

Contoh:

SQL> save cek_datafile.sql

This command will create a file which name is cek_datafile.sql in the directory where we run sqlplus
10. Execute a operating system command

SQL> host

Or use a shortcut !

SQL> !pwd

SQLplus merupakan salah satu tools oracle yang paling sering digunakan. Biasanya sqlplus digunakan untuk menjalankan command atau perintah SQL maupun untuk administrasi database sehari-hari. SQLplus tersedia dalam berbagai platform. Pada artikel kali ini kita akan membahas beberapa shortcut yang berguna untuk aktivitas kita di dalam tools oracle ini 🙂

1. Menentukan text editor default untuk melakukan editing pada sqlplus

define _editor=vi

atau pada windows dapat menggunakan

define _editor=notepad

2. Menampilkan command sql terakhir yang tersimpan dalam buffer

SQL> LIST

Atau dengan shortcut l

 SQL> l

3. Menjalankan command sql terakhir yang tersimpan dalam buffer

 SQL> RUN

Atau dengan shortcut /

 SQL> /

4. Mengedit command sql terakhir yang tersimpan dalam buffer dengan menggunakan text editor default

SQL> edit

Atau dengan shortcut ed

 SQL> ed

5. Menjalankan script SQL

SQL> START

Atau dengan shortcut @

 SQL> @

6. Mencatat hasil output dari sqlplus ke dalam sebuah file

SQL> spool namafile

7. Menampilkan environment variabel sqlplus

SQL> SHOW ALL

8. Mengubah environment variabel sqlplus

SQL> set  namavariabel nilaivariabel

Contoh:

SQL> set linesize 200

9. Save command yang ada pada buffer ke dalam sebuah file

SQL> save namafile

Contoh:

SQL> save cek_datafile.sql

Maka akan terbentuk file cek_datafile.sql pada direktori tempat kita menjalankan sqlplus

10. Menjalankan command pada operating System

SQL> host

Atau dengan shortcut !

SQL> !pwd

PFILE dan SPFILE

Parameter file is one of important component in Oracle Database. This file contains all parameter information that is used in Oracle. There are 2 type of parameter file in Oracle: PFILE and SPFILE.

PFILE is stored in text file format under $ORACLE_HOME/dbs/init$ORACLE_SID.ora. SPFILE is binary file under $ORACLE_HOME/dbs/spfile$ORACLE_SID.ora. We can edit PFILE by using text editor tools but not PFILE. 

When starting up database, Oracle will look for parameter file in below sequence:
– If SPFILE is found in $ORACLE_HOME/dbs, database will be started using SPFILE
– If SPFILE is not found, but PFILE is found in $ORACLE_HOME/dbs, database will be started using PFILE
– If both files are not found, database can’t be started

To check if database is started using PFILE or SPFILE, we can check from the SPFILE parameter. If this parameter value is null, it means that database was started using PFILE. 

We can update the parameter value from oracle client by using ALTER SYSTEM. There are 3 different scope of parameter change:

MEMORY: The parameter change will only take effect for the life of the instance. Once we restart the database, the change will be reverted
SPFILE: The parameter change will only be made in the SPFILE and take effect only after next instance restart.
BOTH: The parameter change will take place in both MEMORY and SPFILE. The change take effect from the time it changed and even after next instance restart.

When doing alter system scope=both or scope=spfile, we may get ORA-32001: write to SPFILE requested but no SPFILE specified at startup error if we don’t use SPFILE in the current instance.

We can create PFILE from SPFILE and vice versa with below command

SQL> create PFILE from SPFILE;
SQL> create SPFILE from PFILE;

Above command will create a PFILE or SPFILE at $ORACLE_HOME/dbs. If we want them to be created in a custom location and name, we can use below command

SQL> create PFILE='/tmp/pfileDB.ora' from SPFILE;
SQL> create SPFILE='/tmp/spfileDB.ora' from PFILE;

 

Command Unix basic

Berikut merupakan daftar command unix dasar yang sering digunakan untuk administrasi database sehari-hari:
1.    Mengetahui informasi mengenai operating system yang digunakan
$uname –a

2.    Mengetahui konfigurasi ip address dari server yang digunakan
$ifconfig

3.    melihat instance apa saja yang ada pada server
$ps -ef | grep smon

4.    Melihat listener apa saja yang menyala pada server
$ps –ef | grep listener

5.    melihat ukuran dan status pemakaian filesystem
$df –h

6.    melihat memory dari server (dalam ukuran mega)
$free –m

7.    melihat pemakaian virtual memory
vmstat [-a] [-n] [delay [ count]]
contoh:
$vmstat –a 2 10
akan memunculkan statistik pemakaian virtual memory dan juga cpu dengan setiap 2 detik refresh dan 10 kali baru berhenti

result:
procs                     memory    swap        io     system cpu
r  b  w   swpd   free  buff  cache  si so   bi  bo   in    cs us sy  id
0  0  0  29232 116972  4524 244900   0  0    0   0    0     0 0   0   0
0  0  0  29232 116972  4524 244900   0  0    0   0 2560     6 0   1  99
0  0  0  29232 116972  4524 244900   0  0    0   0 2574    10 0   2  98

8.    melihat pemakaian I/O
iostat
contoh:
$iostat -xtc 5 2
akan memunculkan statistik pemakaian disk dan juga cpu dengan setiap 5 detik refresh dan 2 kali baru berhenti

result:
extended disk statistics       tty         cpu
disk r/s  w/s Kr/s Kw/s wait actv svc_t  %w  %b  tin tout us sy wt id
sd0   2.6 3.0 20.7 22.7 0.1  0.2  59.2   6   19   0   84  3  85 11 0
sd1   4.2 1.0 33.5  8.0 0.0  0.2  47.2   2   23
sd2   0.0 0.0  0.0  0.0 0.0  0.0   0.0   0    0
sd3  10.2 1.6 51.4 12.8 0.1  0.3  31.2   3   31

9.    melihat daftar error dengan kode ORA- dari alert log
$tail -100f alert.log | grep ORA-

10.    mengetahui hostname dari server
$hostname

11.    melakukan remote copy ke server lain
scp namafile username@ipserver2:/direktoritarget
contoh:
$scp system01.dbf oracle@10.25.130.93:/home/oracle/system01.dbf

12.    melakukan remote login ke server lain
ssh username@ipserver2
contoh:
$ssh oracle@10.25.130.93

ORA-00600: internal error code, arguments: [kcratr1 lastbwr], , , , ,

Kemarin saya menemui suatu kejadian yang mendebarkan.. dimana setelah shutdown, database tiba-tiba tidak mau up.. sedangkan database tersebut belum pernah di fullbackup sama sekali. dan juga sedang dalam masa development. error yang ditemui adalah:



ORA-00600: internal error code, arguments: [kcratr1 lastbwr], , , , ,

Setelah saya googling, malah dikatakan ini sebagai bug dari oracle. (sumber: http://ora-00600.ora-code.com) semakin mendebarkan saja rasanya…

tapi Puji Tuhan! akhirnya error ini bisa ditangani juga pada akhirnya. Step-step untuk menanganinya adalah sebagai berikut:

1. Shutdown immediate

2. Startup mount

3. Recover Database

4. Alter database open

yup, puji Tuhan dengan recover database, masalah dapat diselesaikan

Semoga dapat membantu rekan yang menghadapi masalah yang sama 🙂

Cognos Error CM-CFG-5076

Ketika mencoba melakukan migrasi database content manager Cognos 8.4 dari Microsoft SQL Server 2008 ke Microsoft SQL Server 2008R2, terdapat error berikut ketika start

CMCFG5076 A Content Manager configuration error occurred during the initialization of Cognos Access Manager

Awalnya saya kira error tersebut dikarenakan versi SQL Server yang tidak support terhadap Cognos 8.4. Tetapi ternyata error disebabkan oleh hal lain,yaitu tidak diberikannya akses kepada user LDAP untuk connect ke DB.

 

Oleh karena itu step-step untuk memperbaikinya adalah berikut:

  1.  Pastikan koneksi cognos ke database content manager berhasil dilakukan
  2. Pastikan koneksi cognos ke user authentication (bisa berupa LDAP,atau Active Directory,atau sejenisnya)
  3. Jika belum berrhasil connect ke LDAP, buat agar allow anonymous user login menjadi true

Kemudian coba start kembali services cognosnya

 

Semoga membantu 🙂

Linux Error: 104: Connection reset by peer

Kemarin ketika mencoba menyalakan listener di server , saya mendapatkan error sebagai berikut:

$ lsnrctl start
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC)))
TNS-12547: TNS:lost contact
TNS-12560: TNS:protocol adapter error
TNS-00517: Lost contact
Linux Error: 104: Connection reset by peer
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=orclmain)(PORT=1521)))
TNS-12547: TNS:lost contact
TNS-12560: TNS:protocol adapter error
TNS-00517: Lost contact
Linux Error: 104: Connection reset by peer

Selidik sana sini,akhirnya diketahui bahwa penyebab error tersebut adalah tidak adanya loopback adapter pada /etc/hosts..

karena itu jangan lupa tambahkan

127.0.0.1 localhost.localdomain localhost

pada file /etc/hosts

kemudian start kembali listener dan pasti berhasil

Selamat mencoba 🙂

Database tidak mau start setelah Upgrade/Patch

Ketika melakukan patch dari oracle 10.2.0.1 ke 10.2.0.4 pada environment oracle linux, saya menemukan error bahwa database tidak dapat dinaikkan dengan error

ORA-01092:
ORACLE instance terminated. Disconnection forced.

Hasil penyelidikan terhadap alert log,ditemukan bahwa ada error:

ORA-00704: bootstrap process failure
ORA-39700: database must be opened with UPGRADE option
Mon Jun 30 11:53:43 2008
Error 704 happened during db open, shutting down database
USER: terminating instance due to error 704
Instance terminated by USER, pid = 582062
ORA-1092 signalled during: ALTER DATABASE OPEN...

Error di atas diakibatkan karena adanya perbedaan pada dictionary setelah upgrade/patching. Dengan demikian kita perlu melakukan beberapa langkah perbaikan

Langkah-langkah untuk memperbaiki error ini adalah sebagai berikut:

  1. SQL>  startup upgrade

 

2.  Jalankan script sql berikut yang ada di direktori $ORACLE_HOME/rdbms/admin

catupgrd.sql

catalog.sql

catproc.sql

SQL> @catupgrd.sql
SQL> @catalog.sql
SQL> @catproc.sql

3. Database sudah  kembali berfungsi normal 🙂