내용

글번호 70
작성자 heojk
작성일 2016-06-25 00:00:00
제목 CentOS 6.8에 Oracle Database 11g R2 x86_64 설치하기
내용 CentOS 6.8에 Oracle Database 11g R2 x86_64 설치하기 1. 선행 작업으로 의존성 해결을 위해 메뉴얼 방식이 아닌 오라클 공개 YUM 저장소의 "oracle-rdbms-server-11gR2-preinstall" 패키지를 설치합니다. 다음 일련의 작업들은 root 계정으로 수행합니다. 먼저 오라클의 저장소 정보와 키를 받아옵니다. # cd /etc/yum.repos.d # wget https://public-yum.oracle.com/public-yum-ol6.repo --no-check-certificate # wget https://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6 -O /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle --no-check-certificate oracle-rdbms-server-11gR2-preinstall 패키지를 설치합니다. # yum install oracle-rdbms-server-11gR2-preinstall 2. 호스트 네임과 관련한 정보를 수정합니다. 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 4. 설정 후 서버를 재시작 합니다.   5. 다음 일련의 작업들은 앞서 생성한 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=ORCL; 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=ORCL; 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값을 설치에 앞서 확인합니다. 6. 다음 작업을 위해 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 7. 다운로드 한 Oracle database의 설치를 위해 oracle 계정으로 전환 합니다. "/home/oracle/ " 디렉토리에 다운로드한 파일의 압축을 해제합니다. # su - oracle password: ***** $ unzip linux.x64_11gR2_database_1of2.zip $ unzip linux.x64_11gR2_database_2of2.zip 8. OUI(Oracle Universal Installer)를 실행 합니다. $ cd database $ ./runInstaller ** 인스톨러를 통한 설치 항목은 비교적 단순하기에 생략합니다. 몇 가지 체크할 사항으로 앞에서 .bash_profile에 설정한 환경변수와 실재 값이 일치하도록 확인합니다. 필요 조건 체크와 관련한 페이지에서 Failed가 뜨는 항목은 "Fix & Check Again"을 통해 문제를 해결이 가능한데 제 경우는 패키지를 YUM 저장소에서도 찾을 수 없는 것들이 존재해서 "Ignore All"을 체크하고 넘어갔으나 별다른 문제는 발생하지 않습니다. 9. 설치 마지막 즈음 나오는 2개의 스크립트를 root 계정으로 실행하라는 메시지를 확인하고 계정을 전환하여 다음의 작업들을 진행합니다. # cd /u01/app/oraInventory/orainstRoot.sh # cd /u01/app/oracle/product/11.2.0/dbhome_1/root.sh 10. 방화벽에 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 정보를 조회하여 INPUT 체인의 REJECT항목보다 선행 넘버로 해당 포트를 등록합니다. 해당 설정 값은 "/etc/sysconfig/iptables" 파일을 수정하여 변경이 가능합니다. # 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 11. 스크립트와 서비스등록을 위해 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. # # ORCL:/u01/app/oracle/product/11.2.0/dbhome_1:Y 12. 다음의 실행과 종료 스크립트를 생성합니다. 스크립트를 작성할 디렉토리를 만듭니다. $ mkdir ~/scripts 시작 스크립트를 작성합니다. $ 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 13. 스크립트에 실행할 수 있는 권한을 줍니다. $ chmod u+x ora_start.sh ora_stop.sh 14. 서비스 등록을 위해 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 15. 생성한 스크립트의 권한을 변경합니다. # chmod 750 /etc/init.d/oracle 16 oracle 스크립트를 서비스에 등록합니다. # chkconfig --add oracle 여러분은 OUI로 오라클 설치 후 root계정으로 다음 명령을 실행시켜 OS 재시작 시 서비스 자동 실행하도록 구성해야 합니다. # chkconfig oracle on