Memeriksa Jumlah CPU dari SQL*Plus

Saat bekerja dengan server Linux, cara untuk menentukan jumlah CPU yang terpasang pada sebuah server adalah dengan melihat berkas /proc/cpuinfo. Contohnya seperti tampilan berikut ini :

[oracle@uimdbsit01 ~]$ cat /proc/cpuinfo 
processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 37
model name  : Intel(R) Xeon(R) CPU E7- 4870  @ 2.40GHz
stepping    : 1
cpu MHz     : 2394.000
cache size  : 30720 KB
physical id : 0
siblings    : 5
core id     : 0
cpu cores   : 5
apicid      : 0
initial apicid  : 0
fpu     : yes
fpu_exception   : yes
cpuid level : 11
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 popcnt aes hypervisor lahf_lm ida arat
bogomips    : 4788.00
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

processor   : 1
vendor_id   : GenuineIntel
cpu family  : 6
model       : 37
model name  : Intel(R) Xeon(R) CPU E7- 4870  @ 2.40GHz
stepping    : 1
cpu MHz     : 2394.000
cache size  : 30720 KB
physical id : 0
siblings    : 5
core id     : 1
cpu cores   : 5
apicid      : 1
initial apicid  : 1
fpu     : yes
fpu_exception   : yes
cpuid level : 11
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 popcnt aes hypervisor lahf_lm ida arat
bogomips    : 4788.00
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

processor   : 2
vendor_id   : GenuineIntel
cpu family  : 6
model       : 37
model name  : Intel(R) Xeon(R) CPU E7- 4870  @ 2.40GHz
stepping    : 1
cpu MHz     : 2394.000
cache size  : 30720 KB
physical id : 0
siblings    : 5
core id     : 2
cpu cores   : 5
apicid      : 2
initial apicid  : 2
fpu     : yes
fpu_exception   : yes
cpuid level : 11
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 popcnt aes hypervisor lahf_lm ida arat
bogomips    : 4788.00
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

processor   : 3
vendor_id   : GenuineIntel
cpu family  : 6
model       : 37
model name  : Intel(R) Xeon(R) CPU E7- 4870  @ 2.40GHz
stepping    : 1
cpu MHz     : 2394.000
cache size  : 30720 KB
physical id : 0
siblings    : 5
core id     : 3
cpu cores   : 5
apicid      : 3
initial apicid  : 3
fpu     : yes
fpu_exception   : yes
cpuid level : 11
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 popcnt aes hypervisor lahf_lm ida arat
bogomips    : 4788.00
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

processor   : 4
vendor_id   : GenuineIntel
cpu family  : 6
model       : 37
model name  : Intel(R) Xeon(R) CPU E7- 4870  @ 2.40GHz
stepping    : 1
cpu MHz     : 2394.000
cache size  : 30720 KB
physical id : 0
siblings    : 5
core id     : 4
cpu cores   : 5
apicid      : 4
initial apicid  : 4
fpu     : yes
fpu_exception   : yes
cpuid level : 11
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 popcnt aes hypervisor lahf_lm ida arat
bogomips    : 4788.00
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

processor   : 5
vendor_id   : GenuineIntel
cpu family  : 6
model       : 37
model name  : Intel(R) Xeon(R) CPU E7- 4870  @ 2.40GHz
stepping    : 1
cpu MHz     : 2394.000
cache size  : 30720 KB
physical id : 1
siblings    : 5
core id     : 0
cpu cores   : 5
apicid      : 8
initial apicid  : 8
fpu     : yes
fpu_exception   : yes
cpuid level : 11
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 popcnt aes hypervisor lahf_lm ida arat
bogomips    : 4788.00
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

processor   : 6
vendor_id   : GenuineIntel
cpu family  : 6
model       : 37
model name  : Intel(R) Xeon(R) CPU E7- 4870  @ 2.40GHz
stepping    : 1
cpu MHz     : 2394.000
cache size  : 30720 KB
physical id : 1
siblings    : 5
core id     : 1
cpu cores   : 5
apicid      : 9
initial apicid  : 9
fpu     : yes
fpu_exception   : yes
cpuid level : 11
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 popcnt aes hypervisor lahf_lm ida arat
bogomips    : 4788.00
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

processor   : 7
vendor_id   : GenuineIntel
cpu family  : 6
model       : 37
model name  : Intel(R) Xeon(R) CPU E7- 4870  @ 2.40GHz
stepping    : 1
cpu MHz     : 2394.000
cache size  : 30720 KB
physical id : 1
siblings    : 5
core id     : 2
cpu cores   : 5
apicid      : 10
initial apicid  : 10
fpu     : yes
fpu_exception   : yes
cpuid level : 11
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 popcnt aes hypervisor lahf_lm ida arat
bogomips    : 4788.00
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

processor   : 8
vendor_id   : GenuineIntel
cpu family  : 6
model       : 37
model name  : Intel(R) Xeon(R) CPU E7- 4870  @ 2.40GHz
stepping    : 1
cpu MHz     : 2394.000
cache size  : 30720 KB
physical id : 1
siblings    : 5
core id     : 3
cpu cores   : 5
apicid      : 11
initial apicid  : 11
fpu     : yes
fpu_exception   : yes
cpuid level : 11
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 popcnt aes hypervisor lahf_lm ida arat
bogomips    : 4788.00
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

processor   : 9
vendor_id   : GenuineIntel
cpu family  : 6
model       : 37
model name  : Intel(R) Xeon(R) CPU E7- 4870  @ 2.40GHz
stepping    : 1
cpu MHz     : 2394.000
cache size  : 30720 KB
physical id : 1
siblings    : 5
core id     : 4
cpu cores   : 5
apicid      : 12
initial apicid  : 12
fpu     : yes
fpu_exception   : yes
cpuid level : 11
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 popcnt aes hypervisor lahf_lm ida arat
bogomips    : 4788.00
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

[oracle@uimdbsit01 ~]$ 

Pada contoh ini server yang sedang saya akses memiliki 10 buah CPU Intel(R) Xeon(R). Penomoran CPUnya dimulai dari angka 0.

Server pada contoh ini dipakai untuk menjalankan Oracle Database 11g. Bila sedang mengakses database melalui SQL*Plus, kita bisa juga memeriksa jumlah CPU yang terpasang. Lihat contoh berikut ini :

SQL> select a.inst_id,a.instance_name,b.name,b.value
  2  from gv$instance a, gv$parameter b
  3  where a.inst_id=b.inst_id
  4  and
  5  b.name in ('cpu_count','parallel_threads_per_cpu')
  6  ;

   INST_ID INSTANCE_NAME    NAME                                     VALUE
---------- ---------------- ---------------------------------------- ------------
         1 uimdbsit1        parallel_threads_per_cpu                 2
         1 uimdbsit1        cpu_count                                10
         2 uimdbsit2        parallel_threads_per_cpu                 2
         2 uimdbsit2        cpu_count                                10

SQL>

Karena databasenya adalah cluster RAC, maka akan muncul informasi CPU yang dimiliki oleh masing-masing node RAC. Dalam contoh tadi, dari SQL*Plus kita bisa melihat bahwa masing-masing node RAC beroperasi pada server berkekuatan 10 CPU. Sebagai catatan, untuk bisa menggunakan perintah SQL di atas, user harus punya privilege untuk mengakses gv$parameter (atau jalankan saja lewat user sysdba)

SQL*Plus Pada Mac OSX

SQLPlus adalah aplikasi yang berfungsi sebagai antar muka (interface) Oracle Database. Dengan menggunakan SQLPlus user bisa menjalankan perintah-perintah SQL, mengeksekusi PL/SQL procedure, atau melakukan administrasi databasenya (menyalakan/mematikan database, membuat tablespace, membuat schema, dsb). SQLPlus termasuk dalam paket instalasi Oracle Database. Biasanya saya menggunakan perntah sqlplus langsung dari server databasenya.

Beberapa waktu lalu saya iseng mencari apakah ada caranya memasang SQLPlus pada Mac OSX. Ternyata saya bisa memasang paket SQLPlus-nya saja tanpa harus memasang Oracle Database. Aplikasi SQL*Plus tersedia di website Oracle ini : http://www.oracle.com/technetwork/topics/intel-macsoft–096467.html

Ada 2 berkas instalasi SQL*Plus yang perlu saya unduh dari web Oracle tadi :

ttirtawi@macbookpro:Downloads$ ll instantclient-*
-rw-r--r--@ 1 ttirtawi  staff    25M Apr 14 22:06 instantclient-basiclite-macos.x64-11.2.0.4.0.zip
-rw-r--r--@ 1 ttirtawi  staff   864K Apr 14 22:06 instantclient-sqlplus-macos.x64-11.2.0.4.0.zip
ttirtawi@macbookpro:Downloads$

Ini catatan saya untuk memasang SQL*Plus pada Mac OSX :

  1. Saya siapkan direktori baru untuk tempat instalasi SQL*Plus
    ttirtawi@macbookpro:Downloads$ cd /usr/local/
    ttirtawi@macbookpro:local$ mkdir instantclient_11_2
    ttirtawi@macbookpro:local$ cd instantclient_11_2/
    
  2. Berikutnya saya ekstrak kedua berkas instalasi yang sudah diunduh tadi :
    ttirtawi@macbookpro:~$ cd /usr/local/instantclient_11_2/
    ttirtawi@macbookpro:instantclient_11_2$ sudo unzip /Users/ttirtawi/Downloads/instantclient-basiclite-macos.x64-11.2.0.4.0.zip
    Archive:  /Users/ttirtawi/Downloads/instantclient-basiclite-macos.x64-11.2.0.4.0.zip
      inflating: instantclient_11_2/BASIC_LITE_README 
      inflating: instantclient_11_2/adrci 
      inflating: instantclient_11_2/genezi 
      inflating: instantclient_11_2/libclntsh.dylib.11.1 
      inflating: instantclient_11_2/libnnz11.dylib 
      inflating: instantclient_11_2/libocci.dylib.11.1 
      inflating: instantclient_11_2/libociicus.dylib 
      inflating: instantclient_11_2/libocijdbc11.dylib 
      inflating: instantclient_11_2/ojdbc5.jar 
      inflating: instantclient_11_2/ojdbc6.jar 
      inflating: instantclient_11_2/uidrvci 
      inflating: instantclient_11_2/xstreams.jar 
    ttirtawi@macbookpro:instantclient_11_2$ sudo unzip /Users/ttirtawi/Downloads/instantclient-sqlplus-macos.x64-11.2.0.4.0.zip
    Archive:  /Users/ttirtawi/Downloads/instantclient-sqlplus-macos.x64-11.2.0.4.0.zip
      inflating: instantclient_11_2/SQLPLUS_README 
      inflating: instantclient_11_2/glogin.sql 
      inflating: instantclient_11_2/libsqlplus.dylib 
      inflating: instantclient_11_2/libsqlplusic.dylib 
      inflating: instantclient_11_2/sqlplus 
    ttirtawi@macbookpro:instantclient_11_2$
    
  3. Lalu saya perlu mengatur ulang berkas tnsnames.ora. Berkas tnsnames.ora berisi detail koneksi ke setiap remote database.
    ttirtawi@macbookpro:instantclient_11_2$ vi tnsnames.ora
    RSDOD =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.57.100)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = ORCL)
        )
      )
    ttirtawi@macbookpro:~$ 
    

    Pada contoh di atas saya tambahkan 1 koneksi ke database ORCL yang berada pada server dengan IP 192.168.57.100.

  4. Berikutnya saya perlu menambahkan direktori tempat instalasi SQL*Plus tadi ke dalam berkas .bash_profile.
    ttirtawi@macbookpro:~$ cat .bash_profile
    export LC_ALL=en_US.UTF-8 
    export LANG=en_US.UTF-8
    export DYLD_LIBRARY_PATH=/usr/local/instantclient_11_2
    export TNS_ADMIN=/usr/local/instantclient_11_2
    export PATH="${PATH}:/Users/ttirtawi/MacPorts/bin:/Users/ttirtawi/bin:$PATH:/usr/local/instantclient_11_2"
    [[ -s ~/.bashrc ]] && source ~/.bashrc
    ttirtawi@macbookpro:~$ 
    ttirtawi@macbookpro:~$ 
    
  5. Sekarang saya bisa tes koneksi ke database tadi :
    ttirtawi@macbookpro:~$ sqlplus orauser/orauser@RSDOD
    
    SQL*Plus: Release 11.2.0.4.0 Production on Tue Dec 9 22:14:12 2014
    
    Copyright (c) 1982, 2013, Oracle.  All rights reserved.
    
    
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    
    SQL> show parameter db_name;
    
    NAME                         TYPE      VALUE
    ------------------------------------ ----------- ------------------------------
    db_name                     string      orcl
    SQL>
    

Kira-kira begitu langkah-langkah instalasi SQL*Plus pada MacOSX. Dengan begitu sekarang saya bisa langsung mengakses database tanpa perlu login dulu ke server databasenya.