Oracle 11gR2 설치 (Linux)

출처 : http://blueray21.tistory.com/21


1. Oracle 11g R2

http://www.oracle.com/technetwork/products/express-edition/downloads/index.html

  • linux_11gR2_database_1of2.zip

  • linux_11gR2_database_2of2.zip


2. 패키지 확인

http://docs.oracle.com/cd/E11882_01/install.112/e24323/toc.htm#autoId8

compat-libstdc++-33-3.2.3-61.i386.rpm
libaio-devel-0.3.106-5.i386.rpm
sysstat-7.0.2-12.el5.i386.rpm
unixODBC-2.2.11-10.el5.i386.rpm
unixODBC-libs-2.2.11-10.el5.i386.rpm
unixODBC-devel-2.2.11-10.el5.i386.rpm
pdksh-5.2.14-37.el5_8.1.i386.rpm


  • 설치 시 오류를 피하기 위해서 모든 모듈을 최신 버전으로 유지


3. Oracle 계정 및 디렉토리 생성

3.1 Oracle 계정 생성

 [ray@centos ~]$ sudo groupadd oinstall
 [ray@centos ~]$ sudo groupadd dba
 [ray@centos ~]$ sudo useradd -m -g oinstall -G dba oracle
 [ray@centos ~]$ sudo passwd oracle

3.2 디렉토리 생성

 [ray@centos ~]$ sudo mkdir /oracle
 [ray@centos ~]$ sudo chown -R oracle.dba /oracle
 [ray@centos ~]$ sudo chmod -R 755 /oracle


4. 커널 파라미터 설정

4.1 커널 수정

 [ray@centos ~]$ sudo vi /etc/sysctl.conf

1
2
3
4
5
6
7
8
9
10
11
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
  • 파일 맨 하단에 추가하되 없는 것만 추가

4.2 커널 수정 내역 적용

 [ray@centos ~]$ sudo /sbin/sysctl -p


5. Oracle 사용자 계정 Shell Limit 설정

5.1 /etc/security/limits.conf 파일 수정

 [ray@centos ~]$ sudo vi /etc/security/limits.conf


1
2
3
4
5
#<domain> <type>    <item>    <value>
oracle  soft    nproc   2047
oracle  hard    nproc   16384
oracle  soft    nofile  1024
oracle  hard    nofile  65536

5.2 /etc/pam.d/login 파일 수정

 [ray@centos ~]$ sudo vi /etc/pam.d/login


1
session required    pam_limits.so
  • 파일 맨 하단에 추가

5.3 SELinux 비활성화

 [ray@centos ~]$ sudo vi /etc/selinux/config


1
SELINUX=disabled
  • 파일 맨 하단에 추가

6. 환경변수

 [ray@centos ~]$ sudo vi /home/oracle/.bash_profile


# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

# Oracle
export ORACLE_HOSTNAME=localhost.localdomain
export ORACLE_BASE=/oracle
export ORACLE_HOME=$ORACLE_BASE/product/db/11.2.0
export ORACLE_TERM=xterm
export PATH=$PATH:/sbin:/bin:/usr/bin:$HOME/bin:$ORACLE_HOME/bin

export LANG=ko_KR.UTF-8
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
export ORACLE_SID=SID_TEST

ulimit -u 16384 -n 65536
  • 경로와 SID 등은 뒤에 Oracle 설치 시 동일하게 적용되어야 함.


7. 설치

7.1 다운로드한 파일을 oracle 계정으로 FTP 접속하여 서버에 업로드

7.2 oracle 계정으로 변경

 [ray@centos ~]$ su - oracle
 Password:
 
 [oracle@centos ~]$

7.3 압축 파일 해제

 [oracle@centos ~]$ ls -l
 total 2227312
 -rw-r--r--. 1 oracle oinstall 1285396902 Apr  4 17:06 linux_11gR2_database_1of2.zip
 -rw-r--r--. 1 oracle oinstall  995359177 Apr  4 17:06 linux_11gR2_database_2of2.zip
 [oracle@centos ~]$ unzip linux_11gR2_database_1of2.zip
 [oracle@centos ~]$ unzip linux_11gR2_database_2of2.zip
 [oracle@centos ~]$ ls -l
 total 2227316
 drwxr-xr-x. 8 oracle oinstall       4096 Aug 19  2009 database
 -rw-r--r--. 1 oracle oinstall 1285396902 Apr  4 17:06 linux_11gR2_database_1of2.zip
 -rw-r--r--. 1 oracle oinstall  995359177 Apr  4 17:06 linux_11gR2_database_2of2.zip

7.4 설치프로그램 실행

 [oracle@centos ~]$ cd database
 [oracle@centos database]$ ./runInstaller

7.5 설치화면















7.6 설치 완료 후 ROOT 권한으로 스크립트 수행

 [root@centos ~]$ /oracle/oraInventory/orainstRoot.sh
 [root@centos ~]$ /oracle/product/11g/root.sh

7.7 자동실행 설정

 [root@centos ~]$ vi /etc/oratab



ora11:/oracle/product/11g:Y

Create a file called "/etc/rc.d/init.d/dbora" as the root user, containing the following.

#!/bin/sh
# chkconfig: 345 99 10
# description: Oracle auto start-stop script.
#
# Set ORA_OWNER to the user id of the owner of the
# Oracle database software.

ORA_OWNER=oracle
SCRIPTS_DIR=/opt/oracle/app/script

case "$1" in
    'start')
        # Start the Oracle databases:
        # The following command assumes that the oracle login
        # will not prompt the user for any values
        echo "Starting Oracle Database Server..."
        su $ORA_OWNER -c "$SCRIPTS_DIR/startup.sh >> $SCRIPTS_DIR/startup_shutdown.log 2>&1"
        touch /var/lock/subsys/dbora
        ;;
    'stop')
        # Stop the Oracle databases:
        # The following command assumes that the oracle login
        # will not prompt the user for any value
        echo "Shutting down Oracle Database Server..."
        su $ORA_OWNER -c "$SCRIPTS_DIR/shutdown.sh >> $SCRIPTS_DIR/startup_shutdown.log 2>&1"
        rm -f /var/lock/subsys/dbora
        ;;
    restart)
        $0 stop
        $0 start
        ;;
    *)
        echo "Usage: dbora {start|stop|restart}"
        exit 1
esac

Use the chmod command to set the privileges to 750.
chmod 750 /etc/rc.d/init.d/dbora

Associate the dbora service with the appropriate run levels and set it to auto-start using the following command.

chkconfig --add dbora

Next, we must create the "startup.sh" and "shutdown.sh" scripts in the "/home/oracle/scripts". First create the directory.

# mkdir -p /home/oracle/scripts
# chown oracle.oinstall /home/oracle/scripts

The "/home/oracle/scripts/startup.sh" script should contain the following commands.

#!/bin/bash

export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_BASE=/opt/oracle/app/oracle
export ORACLE_HOSTNAME=localhost
export ORACLE_UNQNAME=DB11G
export ORACLE_HOME=$ORACLE_BASE/11g
export PATH=/usr/sbin:$ORACLE_HOME/bin:$PATH:/usr/local/bin

export ORACLE_SID=orcl
ORAENV_ASK=NO
. oraenv
ORAENV_ASK=YES

# Start Listener
echo "    Starting lsnrctl..."
lsnrctl start

# Start Database
export ORACLE_SID=orcl
echo "    Starting ${ORACLE_SID} Database..."
sqlplus / as sysdba << EOF
STARTUP;
EXIT;
EOF

sleep 2

# Start Database
export ORACLE_SID=MYDATABASE1
echo "    Starting ${ORACLE_SID} Database..."
sqlplus / as sysdba << EOF
STARTUP;
EXIT;
EOF

sleep 2

# Start Database
export ORACLE_SID=MYDATABASE2
echo "    Starting ${ORACLE_SID} Database..."
sqlplus / as sysdba << EOF
STARTUP;
EXIT;
EOF


The "/home/oracle/scripts/shutdown.sh" script is similar.


#!/bin/bash

export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_BASE=/opt/oracle/app/oracle
export ORACLE_HOSTNAME=localhost
export ORACLE_UNQNAME=DB11G
export ORACLE_HOME=$ORACLE_BASE/11g
export PATH=/usr/sbin:$ORACLE_HOME/bin:$PATH:/usr/local/bin

export ORACLE_SID=orcl
ORAENV_ASK=NO
. oraenv
ORAENV_ASK=YES

# Stop Database
export ORACLE_SID=MYDATABASE2
echo "    Shutting down ${ORACLE_SID} Database..."
sqlplus / as sysdba << EOF
SHUTDOWN IMMEDIATE;
EXIT;
EOF

sleep 2

# Stop Database
export ORACLE_SID=MYDATABASE1
echo "    Shutting down ${ORACLE_SID} Database..."
sqlplus / as sysdba << EOF
SHUTDOWN IMMEDIATE;
EXIT;
EOF

sleep 2

# Stop Database
export ORACLE_SID=orcl
echo "    Shutting down ${ORACLE_SID} Database..."
sqlplus / as sysdba << EOF
SHUTDOWN IMMEDIATE;
EXIT;
EOF

sleep 3

# Stop Listener
echo "    Shutting down lsnrctl..."
lsnrctl stop

Note. You could move the environment settings into the "dbora" file or into a separate file that is sourced in the startup and shutdown script. I kept it local to the script so you could see the type of things that need to be set in case you have to write a script to deal with multiple installations, instances and listeners.

Make sure the permissions and ownership of the files is correct.

# chmod u+x /home/oracle/scripts/startup.sh /home/oracle/scripts/shutdown.sh
# chown oracle.oinstall /home/oracle/scripts/startup.sh /home/oracle/scripts/shutdown.sh

The listener and database will now start and stop automatically with the machine. You can test them using the following command as the "root" user.


7.8 정상적으로 기동되었는지 확인

 [oracle@centos ~]$ sqlplus / as sysdba

 SQL*Plus: Release 11.2.0.1.0 Production on Wed Apr 4 23:48:43 2012

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

 Connected to:
 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
 With the Partitioning, OLAP, Data Mining and Real Application Testing options

 SQL> select instance_name from v$instance;
 INSTANCE_NAME
 ----------------
 ora11
 
 SQL>


위로 스크롤