Linux İşletim Sistemlerinde rlwrap ile Oracle Sqlplus ve Rman’de Komut Geçmişi Kullanma

LinuxAll

Bu makalemizde Linux işletim sistemlerinde “Sqlplus” ve “Rman” araçlarını çalıştırdığımızda Linux “bash” özelliğindeki gibi yukarı aşağı tuşları ile geçmiş komutları görmeyi geri tuşu ile silme özelliğini kullanmayı ayarlayacağız.

1. Öncelikle “rlwrap” yazılımının sitesinden yazılımı indiriyoruz.

2. İndirmiş olduğumuz “rlwrap” yazılımını sunucumuzda “oracle” kullanıcısının yetkisinin olduğu bir dizine ftp vb. yöntemle kopyalıyoruz. Ben sunucumda oracle kurulumları için daha önce yarattığım “/u01/orainstall/rlwrap” dizinine kopyaladım.

3. Kopyalamış olduğumuz “rlwrap-0.37.tar.gz” sıkıştırılmış dosyasını açıyoruz.

-- Dosyamızı kopyaladığımız dizine geçiyoruz.

$ cd /u01/orainstall/rlwrap

-- Gunzip programı ile sıkıştırılmış dosyayı tar dosyasına
dönüştürüyoruz.

$ gunzip rlwrap-0.37.tar.gz

tar programı ile sıkıştırılmış dosyayı açıyoruz.

$ tar -xvf rlwrap-0.37.tar
rlwrap-0.37/
rlwrap-0.37/completions/
rlwrap-0.37/completions/testclient
rlwrap-0.37/completions/coqtop
rlwrap-0.37/doc/
rlwrap-0.37/doc/rlwrap.man.in
rlwrap-0.37/doc/Makefile.am
rlwrap-0.37/doc/Makefile.in
rlwrap-0.37/filters/
rlwrap-0.37/filters/README
rlwrap-0.37/filters/RlwrapFilter.pm
rlwrap-0.37/filters/RlwrapFilter.3pm
rlwrap-0.37/filters/count_in_prompt
rlwrap-0.37/filters/pipeto
rlwrap-0.37/filters/logger
rlwrap-0.37/filters/null
rlwrap-0.37/filters/unbackspace
rlwrap-0.37/filters/pipeline
rlwrap-0.37/filters/ftp_filter
rlwrap-0.37/filters/history_format
rlwrap-0.37/filters/simple_macro
rlwrap-0.37/filters/template
rlwrap-0.37/filters/scrub_prompt
rlwrap-0.37/filters/paint_prompt
rlwrap-0.37/filters/censor_passwords
rlwrap-0.37/filters/listing
rlwrap-0.37/filters/Makefile.am
rlwrap-0.37/filters/Makefile.in
rlwrap-0.37/src/
rlwrap-0.37/src/rlwrap.h
rlwrap-0.37/src/redblack.h
rlwrap-0.37/src/malloc_debug.h
rlwrap-0.37/src/completion.rb
rlwrap-0.37/src/Makefile.am
rlwrap-0.37/src/Makefile.in
rlwrap-0.37/src/main.c
rlwrap-0.37/src/signals.c
rlwrap-0.37/src/readline.c
rlwrap-0.37/src/pty.c
rlwrap-0.37/src/completion.c
rlwrap-0.37/src/term.c
rlwrap-0.37/src/ptytty.c
rlwrap-0.37/src/utils.c
rlwrap-0.37/src/string_utils.c
rlwrap-0.37/src/malloc_debug.c
rlwrap-0.37/src/filter.c
rlwrap-0.37/test/
rlwrap-0.37/test/testclient
rlwrap-0.37/test/testit
rlwrap-0.37/tools/
rlwrap-0.37/tools/config.guess
rlwrap-0.37/tools/config.sub
rlwrap-0.37/tools/depcomp
rlwrap-0.37/tools/install-sh
rlwrap-0.37/tools/missing
rlwrap-0.37/README
rlwrap-0.37/configure.ac
rlwrap-0.37/aclocal.m4
rlwrap-0.37/Makefile.am
rlwrap-0.37/Makefile.in
rlwrap-0.37/config.h.in
rlwrap-0.37/configure
rlwrap-0.37/AUTHORS
rlwrap-0.37/COPYING
rlwrap-0.37/ChangeLog
rlwrap-0.37/INSTALL
rlwrap-0.37/NEWS
rlwrap-0.37/TODO
rlwrap-0.37/BUGS
rlwrap-0.37/PLEA

4. Açma işlemi bittiğinde açılmış dosyanın bulunduğu dizine geçip programı derliyoruz.

-- Bundan sonraki işlemleri "root" kullanıcısı ile yapacağız.
"root" kullanıcısına geçiş yapıyoruz.

$ su root
Password: 

-- Aynı klasör altındaki dosyanın açıldığı dizine geçiyoruz.

# cd /u01/orainstall/rlwrap/rlwrap-0.37

-- Ardından programımızı derliyoruz.

# ./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make sets $(MAKE)... (cached) yes
checking whether build environment is sane... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking how to run the C preprocessor... gcc -E
checking for perl... /usr/bin/perl
checking for strip... strip
checking for ANSI C header files... (cached) yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking errno.h usability... yes
checking errno.h presence... yes
checking for errno.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking libutil.h usability... no
checking libutil.h presence... no
checking for libutil.h... no
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking sched.h usability... yes
checking sched.h presence... yes
checking for sched.h... yes
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking for sys/wait.h... (cached) yes
checking sys/resource.h usability... yes
checking sys/resource.h presence... yes
checking for sys/resource.h... yes
checking stddef.h usability... yes
checking stddef.h presence... yes
checking for stddef.h... yes
checking termios.h usability... yes
checking termios.h presence... yes
checking for termios.h... yes
checking for unistd.h... (cached) yes
checking for stdint.h... (cached) yes
checking time.h usability... yes
checking time.h presence... yes
checking for time.h... yes
checking getopt.h usability... yes
checking getopt.h presence... yes
checking for getopt.h... yes
checking regex.h usability... yes
checking regex.h presence... yes
checking for regex.h... yes
checking curses.h usability... yes
checking curses.h presence... yes
checking for curses.h... yes
checking termcap.h usability... yes
checking termcap.h presence... yes
checking for termcap.h... yes
checking for term.h... yes
checking for ncurses/term.h... yes
checking argument type of tputs putc function... int
checking whether your getopt() ... yes
checking for an ANSI C-conforming const... yes
checking for pid_t... yes
checking whether time.h and sys/time.h ... yes
checking whether gcc needs -traditional... no
checking return type of signal handlers... void
checking for getopt_long... yes
checking for getopt_long... (cached) yes
checking for isastream... yes
checking for mkstemp... yes
checking for pselect... yes
checking for putenv... yes
checking for readlink... yes
checking for sched_yield... yes
checking for setenv... yes
checking for setitimer... yes
checking for setsid... yes
checking for setrlimit... yes
checking for sigaction... yes
checking for snprintf... yes
checking for strlcpy... no
checking for strlcat... no
checking for strnlen... yes
checking for system... yes
checking for openpty in -lutil... yes
checking for openpty... yes
checking for getpty... no
checking for grantpt... yes
checking for unlockpt... yes
checking for getpt... yes
checking for pty/tty type... checking ... yes
checking pty.h presence... yes
checking for pty.h... yes
OPENPTY
configure: checking for pty ranges...
checking for tgetent... no
checking for tgetent in -lcurses... yes
checking for readline in -lreadline... yes
checking whether your readline headers ... yes
checking whether your readline library ... yes
checking whether your readline ... yes
checking whether your readline ... yes
Will rlwrap find command's working directory...
checking for /proc/8342/cwd/configure.ac... yes

configure: creating ./config.status
config.status: creating Makefile
config.status: creating filters/Makefile
config.status: creating doc/Makefile
config.status: creating src/Makefile
config.status: creating doc/rlwrap.man
config.status: creating config.h
config.status: executing depfiles commands

Now do:
    make (or gmake)  to build rlwrap
    make check       for instructions how to test it
    make install     to install it

5. Derleme işlemimiz bittikten sonra artık programımızı kurabiliriz. Bunun için aşağıdaki komutları çalıştırıyoruz.

-- Make komutları ile programımızı kuruyoruz.

# make
# make check
# make install

-- Kurulum işlemimiz tamamlanmıştır.

-- Komutlarımızın anlamı aşağıdaki gibidir.

make (or gmake)  to build rlwrap
make check       for instructions how to test it
make install     to install it

6. Şimdi “oracle” kullanıcısına geçerek gerekli ayarlarımızı yapıyoruz. Bu ayarlar ile “sqlplus” veya “rman” araçları çalıştırıldığında “rlwrap” bunların yerine geçerek bize komut satırı geçmişi tutma özelliği sunacaktır. Bu komutları “rlsqlplus” ve “rlrman” gibi çağıracağız.

# su - oracle 

-- bash_profile dosyamıza aşağıdaki satırları ekliyoruz.

$ vim .bash_profile

alias rlsqlplus='rlwrap sqlplus'
alias rlrman='rlwrap rman'

7. Değişikliklerin hemen geçerli olması için “.bash_profile” dosyamızı çalıştırıyoruz. Artık “rlwrap” aracımız kullanıma hazır. Aşağıdaki gibi test ettiğimizde yukarı aşağı tuşlarıyla komut geçmişinin tıpkı Linux bash’deki gibi geldiğini geri tuşu ile garip karakterler çıkmadan silme işlemi yapabildiğimizi göreceğiz.

$ . .bash_profile
$ rlrman target /

Recovery Manager:
Release 11.2.0.3.0 - Production on Wed Mar 13 16:31:51 2013

Copyright (c) 1982, 2011, Oracle and/or its affiliates.
All rights reserved.

connected to target database: ORCL (DBID=1337532004)

RMAN> backup database;

Starting backup at 13-MAR-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=28 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001
name=+DATA/orcl/datafile/system.261.809751305
input datafile file number=00002
name=+DATA/orcl/datafile/sysaux.262.809751323
input datafile file number=00003
name=+DATA/orcl/datafile/undotbs1.263.809751341
input datafile file number=00004
name=+DATA/orcl/datafile/users.265.809751371
channel ORA_DISK_1: starting piece 1 at 13-MAR-13
channel ORA_DISK_1: finished piece 1 at 13-MAR-13
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 13-MAR-13
channel ORA_DISK_1: finished piece 1 at 13-MAR-13
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 13-MAR-13

RMAN> backup database;

RMAN> exit

Recovery Manager complete.
[oracle@koraykey-db ~]$ rlsqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Wed Mar 13 16:34:45 2013

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

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

SQL> select status from v$instance;

STATUS
------------
OPEN

SQL> select status from v$instance;

Bu makalemizdeki adımlar Oracle Enterprise Linux 6.4 üzerinde test edilmiştir. Daha önceki tecrübelerimden diğer Linux işletim sitemleri ile HP-UX 11.31 v3 March 2012 işletim sistemlerinde çalıştığını gördüm.

Başka bir makalede görüşmek üzere…  

Bu yazı Oracle, Unix / Linux kategorisine gönderilmiş ve , , , , , , , , , , , ile etiketlenmiş. Kalıcı bağlantıyı yer imlerinize ekleyin.