CentOS 6.5에 Oracle Database 11g R2 x86_64 설치하기

  • Post author:
  • Post category:
  • Post comments:5 Comments
  • Post last modified:December 7, 2020

참고 : http://www.tecmint.com/oracle-database-11g-release-2-installation-in-linux/ , http://matthiashoys.wordpress.com/2012/04/20/automatically-start-oracle-11g-on-oracle-linux-6-2-after-server-reboot/ , http://www.binarytides.com/open-http-port-iptables-centos/ , http://www.transnexus.com/index.php/how-to-fix-oracle-dbconsole-after-hostname-or-ip-change

1. 선행 작업으로 의존성 해결을 위해 메뉴얼 방식이 아닌 오라클 공개 YUM 저장소의 “oracle-rdbms-server-11gR2-preinstall” 패키지를 설치합니다.

다음 일련의 작업들은 root 계정으로 수행합니다.

먼저 오라클의 저장소 정보와 키를 받아옵니다.

cd /etc/yum.repos.d
wget https://public-yum.oracle.com/public-yum-ol6.repo
wget https://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6 -O /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle

oracle-rdbms-server-11gR2-preinstall 패키지를 설치합니다.

yum install oracle-rdbms-server-11gR2-preinstall
  1. 호스트 네임과 관련한 정보를 수정합니다. HOSTNAME 값은 FQDN(Fully Qualified Domain Name)에 맞춰 설정합니다.
vi /etc/sysconfig/network
vi /etc/hosts

* hosts 파일에는 서버의 아이피에 HOSTNAME을 할당합니다.

3. 앞서 설치한 패키지에서 자동으로 생성된 oracle 계정에 대한 설정을 진행합니다.

passwd oracle

/etc/security/limits.d/90-nproc.conf“에 다음 항목을 추가 합니다.

vi /etc/security/limits.d/90-nproc.conf

# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

* soft nproc 1024
# for Oracle database
* - nproc 16384

/etc/selinux/config“를 열어 SELINUX 항목을 permissive로 변경합니다.

vi /etc/selinux/config

SELINUX=permissive

설정후 서버를 재시작 합니다.

다음 일련의 작업들은 앞서 생성한 oracle 계정으로 수행합니다. oracle 계정의 .bash_profile에 다음 내용을 추가합니다.

vi .bash_profile

# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR

ORACLE_HOSTNAME=localhost; export ORACLE_HOSTNAME
ORACLE_UNQNAME=DB11G; export ORACLE_UNQNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1; export ORACLE_HOME
ORACLE_SID=DB11G; export ORACLE_SID
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH export PATH

ORACLE_HOSTNAME을 앞서 설정한 HOSTNAME으로 변경합니다. ORACLE_UNQNAME, ORACLE_SID값을 설치에 앞서 확인합니다.

다음 작업을 위해 root로 계정을 변경합니다.

X Server에 oracle 계정이 접근할 수 있도록 다음을 실행합니다.

xhost +

설치를 위해 다음 디렉토리를 생성하고 권한을 수정합니다.

mkdir -p /u01/app/oracle/product/11.2.0/dbhome_1
chown -R oracle:oinstall /u01
chmod -R 775 /u01
  1. 다운로드 한 Oracle database의 설치를 위해 oracle 계정으로 전환 합니다.

    /home/oracle/ ” 디렉토리에 다운로드한 파일의 압축을 해제합니다.

unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip

OUI(Oracle Universal Installer)를 실행 합니다.

cd database
./runInstaller

** 인스톨러를 통한 설치 항목은 비교적 단순하기에 생략합니다. 몇가지 체크할 사항으로 앞서 .bash_profile에 설정한 환경변수와 실재 값이 일치하도록 확인합니다. 필요 조건 체크와 관련한 페이지에서 Failed가 뜨는 항목은 “Fix & Check Again“을 통해 문제를 해결이 가능한데 제 경우는 패키지를 YUM 저장소에서도 찾을 수 없는 것들이 존재해서 “Ignore All“을 체크하고 넘어갔으나 별다른 문제는 발생하지 않는 것 같습니다.

설치 마지막 즈음 나오는 2개의 스크립트를 root 계정으로 실행하라는 메시지를 확인하고 계정을 전환하여 다음의 작업들을 진행합니다.

cd /u01/app/oraInventory
./orainstRoot.sh
cd /u01/app/oracle/product/11.2.0/dbhome_1/
./root.sh
  1. 방화벽에 Oracle EM(Enterprise Manager Console)과 LISTENER에 접근 가능 하도록 포트를 등록합니다.
iptables --line -vnL

Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
1 1 328 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
2 0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0
3 0 0 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
4 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
5 3 234 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
1 0 0 REJECT all -- * * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT 13 packets, 808 bytes)
num pkts bytes target prot opt in out source destination
iptables -I INPUT 5 -m state --state NEW -m tcp -p tcp --dport 1158 -j ACCEPT
iptables -I INPUT 6 -m state --state NEW -m tcp -p tcp --dport 1521 -j ACCEPT
service iptables save
service iptables restart

iptables 정보를 조회하여 INPUT 체인의 REJECT항목보다 선행 넘버로 해당 포트를 등록합니다. 해당 설정 값은 “/etc/sysconfig/iptables” 파일을 수정하여 변경이 가능합니다.

6. 스크립트와 서비스등록을 위해 oracle 계정으로 전환합니다. 데이터베이스의 인스턴스를 자동으로 실행할 수 있도록 하기 위해 앞서 root.sh 스크립트를 실행하여 생성된 “/etc/oratab” 파일을 수정합니다.

vi /etc/oratab

# This file is used by ORACLE utilities. It is created by root.sh
# and updated by the Database Configuration Assistant when creating
# a database.

# A colon, ':', is used as the field terminator. A new line terminates
# the entry. Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
# $ORACLE_SID:$ORACLE_HOME:[N|Y]:
#
# The first and second fields are the system identifier and home
# directory of the database respectively. The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
DB11G:/u01/app/oracle/product/11.2.0/dbhome_1:Y

다음의 실행과 종료 스크립트를 생성합니다.

vi /home/oracle/scripts/ora_start.sh

#!/bin/bash

# script to start the Oracle database, listener and dbconsole

. ~/.bash_profile

# start the listener and the database
$ORACLE_HOME/bin/dbstart $ORACLE_HOME

# start the Enterprise Manager db console
$ORACLE_HOME/bin/emctl start dbconsole

exit 0
vi /home/oracle/scripts/ora_stop.sh

#!/bin/bash

# script to stop the Oracle database, listener and dbconsole

. ~/.bash_profile

# stop the Enterprise Manager db console
$ORACLE_HOME/bin/emctl stop dbconsole

# stop the listener and the database
$ORACLE_HOME/bin/dbshut $ORACLE_HOME

exit 0

스크립트에 실행할 수 있는 권한을 줍니다.

chmod u+x ora_start.sh ora_stop.sh

서비스 등록을 위해 root 계정으로 전환 합니다. “/etc/init.d/oracle” 스크립트 파일을 생성합니다.

vi /etc/init.d/oracle

#!/bin/bash
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.

# Set ORA_OWNER to the user id of the owner of the
# Oracle database in ORA_HOME.

ORA_OWNER=oracle
RETVAL=0

case "$1" in
'start')
# Start the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c "/home/oracle/scripts/ora_start.sh"
touch /var/lock/subsys/oracle
;;
'stop')
# Stop the Oracle databases:
# The following command assumes that the oracle login
# will not prompt the user for any values
su - $ORA_OWNER -c "/home/oracle/scripts/ora_stop.sh"
rm -f /var/lock/subsys/oracle
;;
*)
echo $"Usage: $0 {start|stop}"
RETVAL=1
esac
exit $RETVAL

생성한 스크립트의 권한을 변경합니다.

chmod 750 /etc/init.d/oracle

oracle 스크립트를 서비스에 등록합니다.

chkconfig --add oracle

Author Details
Linus Lee aka y1sh former ATiMania.com sysop during 2001-2012. DevSecOps Engineer who likes tech, science, programming and solving problems 🙂
0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

5 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
y1sh
9 years ago

프로젝트가 크런치모드라 이제야 봤네요.. x서버가 설치되지 않은 환경이신 것 같은데.. 제 게시물 보다는 x서버가 설치되지 않은 환경에서의 설치 가이드를 참고하시는 쪽이 나아 보이는군요

익명
익명
9 years ago

xhost + 에서 막혔습니다…ㅠ
>>> 필수 필요 조건을 만족하지 않지만 무시하고 계속하는 중입니다.
다음에서 Oracle Universal Installer의 시작을 준비하는 중 /tmp/OraInstall2014-10-31_02-06-31PM. 기다리십시오.
DISPLAY가 설정되지 않았습니다. DISPLAY를 설정한 후 다시 시도하십시오.
Unix 셸에 따라 다음 명령 중 하나를 DISPLAY 환경 변수 설정 예제로 사용할 수 있습니다.
– csh의 경우: % setenv DISPLAY 192.168.1.128:0.0
– sh, ksh 및 bash의 경우: $ DISPLAY=192.168.1.128:0.0; export DISPLAY
사용 중인 셸을 보려면 다음 명령을 사용하십시오.
echo $SHELL
현재 DISPLAY 환경 변수 설정을 보려면 다음 명령을 사용하십시오.
echo $DISPLAY
– 클라이언트 사용자가 X 서버에 접속하도록 인증되었는지 확인하십시오.
클라이언트 사용자가 X 서버에 액세스할 수 있도록 하려면 세션을 시작한 사용자로 xterm, dtterm 또는 xconsole을 열고 다음 명령을 입력하십시오.
% xhost +
DISPLAY 환경 변수가 올바르게 설정되었는지 테스트하려면 고유 운영 체제에 제공되는 'xclock'과 같은 X11 기반 프로그램을 실행하십시오.
%
xclock을 실행할 수 없는 경우에는 PC-X 서버를 참조하거나 OS 업체에 도움을 요청하십시오.
xclock에 대한 일반 경로: /usr/X11R6/bin/xclock
이 상황이 자꾸 발생하는데 해결방법좀 부탁드립니다. ㅠㅠ

y1sh
9 years ago

도움이 되셨다니 다행이네요 🙂

Unknown
9 years ago

퍼갑니다.

Unknown
9 years ago

완전 감사합니다 덕분에 몇날 몇일 고생하던게 한번에 해결 됬습니다.