CentOS6.9 Oracle12g 소스 설치

ETC

(Update : 2018-04-24)

Language :

Oracle

GUI

1. 패키지 설치

# yum -y groupinstall "Desktop" "Desktop Platform" "X Window System" "Fonts"
# yum -y groupinstall "General Purpose Desktop" "Internet Browser"
# yum -y install fonts-korean
# yum -y groupinstall korean-support

Complete!

2. 실행

# startx

#. GUI로 부팅 설정

# vi /etc/inittab
id:5:initdefault:

JAVA

1. JDK 다운로드

​http://www.oracle.com/technetwork/java/index.html

JavaSE 다운로드 (​http://www.oracle.com/technetwork/java/javase/downloads/index.html​)

2. 압축 파일 옮기기

Computer > Filesystem > /usr/local 로 이동 (압축 파일 안의 jdk-9.0.4를 바로 /usr/local 로 이동해도 상관없다.)

Applications > System Tools > Terminal

3. 압축 해제 및 권한부여

# cd /usr/local
src]# tar -xvzf jdk-9.0.4_linux-x64_bin.tar.gz
src]# chown -R root:root jdk-9.0.4

4. 환경설정 및 환경변수 설정

# vi /root/.bash_profile

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

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
PATH=$PATH$HOME/bin:/usr/local/mysql/bin:
export PATH

export JAVA_HOME=/usr/local/jdk-9.0.4
export PATH=$JAVA_HOME/bin:$PATH

export CLASSPATH=.:$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/tools.jar
export CATALINA_OPTS=java.awt.headless=true
# source /root/.bash_profile

5. 버전 확인

# java -version
java version “9.0.4”
Java(™) SE Runtime Environment (build 9.0.4+!1)
Java HotSpot(™) 64-bit Server VM (build 9.0.4+11, mixed mode)
# javac
javac 9.0.4

Oracle 설치 전 환경 설정

01. 필수 유틸 설치

# yum -y install binutils compat-libstdc++-33 compat-libstdc++-33.i686 ksh
elfutils-libelf elfutils-libelf-devel glibc glibc-common glibc-devel gcc gcc-c++ libaio
libaio.i686 libaio-devel libaio-devel.i686 libgcc libstdc++ libstdc++.i686
libstdc++-devel libstdc++-devel.i686 make sysstat unixODBC unixODBC-devel

Complete!

02. 커널 매개 변수 파일 수정

# vi /etc/sysctl.conf
(...)
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.tcp_syncookies = 1
kernel.sysrq = 0
kernel.msgmnb = 65536
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 65535
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
kernel.shmall = 2097152
kernel.shmmax = 536870912

03. 커널 매개 변수 파일 저장

# cd /usr/sbin/
# sysctl -p

04. 로그인 설정 파일 수정

# vi /etc/pam.d/login
(...)
session required pam_namespace.so
session required pam_limits.so
session optional pam_keyinit.so force revoke
(..)

05. 사용자 리소스 파일 수정

# vi /etc/security/limits.conf
(...)
oracle	soft	nproc	2047
oracle	hard	nproc	16384
oracle	soft	nofile	1024
oracle	hard	nofile	65536

# End of file

06. SELINUX 해제

# vi /etc/selinux/config
SELINUX=disabled

07. 호스트명 변경

# ifconfig								// IP 확인
eth1	Link encap:Ethernet	HWaddr 08:00:27:7D:88:E8
	inet addr:10.0.2.15	Bcast:10.0.2.255	Mask:255.255.255.0
(...)
# cat /etc/sysconfig/network | grep HOSTNAME				// 호스트명 확인
HOSTNAME=dico
# vi /etc/hosts
127.0.0.1	localhost localhost.localdomain localhost4 localhost4.localdomain4
::1		localhost localhost.localdomain localhost6 localhost6.localdomain6

10.0.2.15 dico dico							// IP 호스트명 별칭
  • 호스트명 영구 변경 방법
# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=oracle
# reboot
  • 호스트명 일시적 변경. 재시작하면 풀림
# hostname oracle
  • /etc/hosts

     리눅스에서 DNS보다 먼저 호스트명을 IP로 풀어주는 파일.

     DNS요청을 네임서버에 보내지 않고 등록되어 있는 주소로 연결된다.

08. 오라클 그룹 및 계정 생성

# groupadd oinstall
# groupadd dba
# useradd -g oinstall -G dba oracle
# passwd oracle
Changing password for user oracle
New password:
Retype new password:
Passwd : all authentication tokens updated successfully.

09.  설치디렉토리 생성 및 

# mkdir -p /usr/local/oracle
# mkdir -p /usr/local/oraInventory
# mkdir -p /usr/local/oracle/product/12.2.0/db_1
# mkdir -p /data/database/oracle

mkdir -p명령어 : 기술된 경로가 없을 경우 자동으로 생성한다.

10. 설치 디렉토리에 계정과 그룹 권한 부여

# chown -R oracle:oinstall /usr/local/oracle
# chown -R oracle:oinstall /usr/local/oraInventory
# chown -R oracle:oinstall /usr/local/oracle/product/12.2.0/db_1
# chown -R oracle:oinstall /data/database/oracle
# chmod -R 775 /usr/local/oracle
# chmod -R 775 /usr/local/oraInventory
# chmod -R 775 /usr/local/oracle/product/12.2.0/db_1
# chmod -R 775 /data/database/oracle

권한을 변경해주지 않으면 Oracle 설치 과정에서 변경하라고 뜬다.

11. 계정 환경설정

재시작할 경우 다시 설정 적용해줘야 PATH를 사용할 수 있다. 

# vi /home/oracle/.bash_profile
export PATH

export TMP=/tmp
export TMPDIR=$TMP
export EDITOR=vi

export ORACLE_HOSTNAME=dico
export ORACLE_SID=orcl
export ORACLE_UNQNAME=orcl
export ORACLE_BASE=/usr/local/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1
export ORACLE_HOME_LISTNER=$ORACLE_HOME/bin/lsnrctl

export NLS_LANG=AMERICAN_AMERICA.KO16MSWIN949
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

# source /home/oracle/.bash_profile
  • ORACLE_BASE : 오라클 기본 디렉토리 구조
  • ORACLE_HOME : 오라클 프로그램 설치 경로
  • orcl은 소문자로 입력한다.

설치

1-1). GUI 환경에서 오라클 사이트 접속

1-2) Oracle Database 12c Release 2 Linux x86-64 다운로드

1-3) Computer > Filesystem > /usr/local/src로 zip파일 이동

2. 압축 해제

GUI:X Window의 Terminal

# yum -y install unzip
# cd /usr/local/src
src]# unzip ./linuxx64_12201_database.zip

3. oracle 계정 접속

# xhost +SI:localuser:oracle
localuser:oracle being added to access control list
# su oracle
  • xhost

     특정 사용자가 X 서버에 접근하는 것을 허용해주는 명령어

  • Text Terminal에서 [unable to open display ""] 오류가 발생할 경우, GUI Terminal에서 실행한다.

4. Oracle Universal Installer 실행

$ cd /usr/local/src/database/
database]$ runInstaller

5. 설치

  • Configure Security Updates     : Next (경고창 무시)
  • Installation Option                     : Create and configure a database
  • System Class                               : Server class
  • Database Installation Options : Single instance database installation
  • Install Type                                  : Advanced install
  • Database Edition                        : Enterprise Edition
  • Installation Location

     /home/oracle/.bash_profile에서 등록한 PATH가 정상적으로 설정되면 자동으로 경로가 설정된다.

    - Oracle base : /usr/local/oracle

    - Software  location                     : /usr/local/oracle/product/12.2.0/db_1

  • Create Inventory 

    - Inventory Directory                   : /usr/local/oraInventory

    - oraInventory Group Name      : oinstall

  • Configuration Type                    : General Purpose / Transaction Processing
  • Database Identifiers

    - Global database name             : orcl

    - Oracle System identifier (SID) : orcl

    - Pluggable database name       : orclpdb

  • Configuration Options

    - Character sets - Use Unicode (AL32UTF8)

  • Database Storage

    - File system - Specify database file location : /usr/local/oracle/oradata

  • Management Options               : Next
  • Recovery Options                       : Next
  • Schema Passwords                    : Use the same password for all accounts
  • Operating System Groups

    - Database Operator (OSOPER) group (Optional) : dba

  • Prerequisite Checks                   : lgnore All

    - 경고창 무시

  • Summary                                     : install
  • Install Product                             : 스크립트 설치창 나올 경우 ↓

5-2) root 로 스크립트 설치

Execute Configuration Scripts 창이 나타나면 그 상태 그대로 다른 Terminal을 켠다.

root 권한으로 접속하여 GUI에서 명시한 그대로 스크립트를 실행한다.

# /usr/local/oraInventory/orainstRoot.sh
Changing permissions of /usr/local/oraInventory.
Adding read, write permissions for group.
Removing read, write, execute permissions for world.

Changing groupname of /usr/local/oraInventory to oinstall.
The execution of the script is complete.
# /usr/local/oracle/product/12.2.0/db_1/root.sh
Performing root user operation.

The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /usr/local/oracle/product/12.2.9/db_1

Enter the full pathname of the local bin directory: [/usr/local/bin]: [enter]
	Copying dbhome to /usr/local/bin …
	Copying oraenv to /usr/local/bin …
	Copying coraenv to /usr/local/bin …

Creating /etc/oratab file…
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root script.
Now product-specific root actions will be performed.
Do you want to setup Oracle Trace File Analyzer (TFA) now ? yes|[no] : y
Installing Oracle Trace File Analyzer (TFA).
Log File: /usr/local/oracle/product/12.2.0/db_1/install/root_dico_2018-04-05_00-17-12-430393987.log

Finished installing Oracle Trace File Analyzer (TFA)

5-3) 스크립트 실행한 뒤 설치 계속

#. HOSTNAME이 제대로 인식되지 않을 경우 설치가 92%에서 멈춘 상태로 끝난다.

당장에 문제는 없겠지만 앞으로 여러 문제가 발생할 수 있다.

[INS-20802] Oracle Net Configuration Assistant failed

Refer to the logs or contact Oracle Support Services.

The plug-in failed in its perform method

Oracle 설치 후 환경설정

1. 서비스 등록 및 설정 변경

# su root
# vi /etc/oratab
#


# This file is used by ORACLE utilities. It is created by root.sh
# and updated by either Database. Configuration Assistant while creating.
# a database or ASM Configuration Assistant while creating ASM instance.

# 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 field indicated
# 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:/usr/local/oracle/product/12.2.0/db_1:Y
# vi /home/oracle/.bash_profile
export ORACLE_SID=orcl						// orcl 인지 확인

2) 스크립트 등록 및 실행 권한 변경

#  vi /etc/init.d/oracle
#!/bin/bash
# oracle: Start/Stop Oracle Database 12c
# chkconfig: 2345 90 10
# description: The Oracle Database is an Object-Relational Database Management System.
# processname: oracle
 
. /etc/rc.d/init.d/functions
 
LOCKFILE=/var/lock/subsys/oracle
ORACLE_HOME=/home/oracle/db/product/12.1.0/dbhome_1
ORACLE_USER=oracle
 
case "$1" in
'start')
   if [ -f $LOCKFILE ]; then
      echo $0 already running.
      exit 1
   fi
   echo -n $"Starting Oracle Database:"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl start"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl start dbconsole"
   touch $LOCKFILE
   ;;
'stop')
   if [ ! -f $LOCKFILE ]; then
      echo $0 already stopping.
      exit 1
   fi
   echo -n $"Stopping Oracle Database:"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl stop"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut"
   su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
   rm -f $LOCKFILE
   ;;
'restart')
 $0 stop
 $0 start
   ;;
'status')
   if [ -f $LOCKFILE ]; then
      echo $0 started.
      else
      echo $0 stopped.
   fi
   ;;
*)
   echo "Usage: $0 [start|stop|status]"
   exit 1
esac
 
exit 0
# chmod 755 /etc/init.d/oracle

3) 서비스 등록

# chkconfig --add oracle
# chkconfig oracle on 
# chkconfig --list
oracle	0:off	1:off	2:on	3:on	4:on	5:on	6:off
# reboot

데이터베이스 및 테이블 생성

1. 오라클 계정 접속

# su oracle

2. 오라클 리스너 실행

$ cd $ORACLE_HOME/bin
bin]$ lsnrctl start
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 05-APR-2018 01:23:04

Copyright (c) 1991, 2016, Oracle. All rights reserved.

Starting /usr/local/oracle/product/12.2.0/db_1/bin/tnslsnr: please wait..

TNSLSNR for Linux: Version 12.2.0.1.0 - Production
System parameter file is /usr/local/oracle/product/12.2.0/db_1/network/admin/listener.org
Log messages written to /usr/local/oracle/diag/tnslsnr/dico/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1539)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1539)))
STATUS of the LISTENER
---------------------------------------------------------
Alias		LISTENER
Version		TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date	05-APR-2018 01:07:20
Uptime		0 days 0 hr. 0 min. 4 sec
Trace Level	off
Security		ON: Local OS Authentication
SNMP		OFF
Listener Parameter File	/usr/local/oracle/product/12.2.0/db_1/network/admin/listener.ora
Listener Log File	/usr/local/oracle/diag/tnslsnr/oracle/listener/alert/log.xml
Listening Endpoints Summary…
	(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1539)))
	(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully
  • 이미 리스너가 실행되어 있을 경우

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 05-APR-2018 01:23:04

Copyright (c) 1991, 2016, Oracle. All rights reserved.

TNS-01106: Listener using listener name LISTENER has already been started

3. 접속

bin]$ sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Thu Apr 5 00:41:41 2018

Copyright © 1982, 2016,  Oracle. All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> conn / as sysdba
Connected
bin]$ sqlplus /nolog

SQL*Plus: Release 12.2.0.1.0 Production on Thu Apr 5 00:41:41 2018

Copyright © 1982, 2016,  Oracle. All rights reserved.

SQL> conn scoff/tiger;
    • sysdba : 시스템 관리자
    • sqlplus /nolog : 로그인 없이 sqlplus로 접속
    • scoff/tiger : 기본 계정/비밀번호

    4. DB 사용자 생성 및 테이블 생성

    SQL> conn / as sysdba
    Connected
    
    SQL> SELECT user FROM dual;
    
    USER
    --------------------
    SYS
    
    SQL> CREATE USER c##test IDENTIFIED BY 123;				// c##유저명(12c이상)
    
    User created.
    
    SQL> GRANT connect, resource, dba TO c##test;
    
    Grant succeeded.
    
    SQL> exit
    Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
    bin]$ sqlplus c##test/123;                				// 생성한 유저로 접속
    
    SQL*Plus: Release 12.2.0.1.0 Production on Thu Apr 5 00:41:41 2018
    
    Copyright © 1982, 2016,  Oracle. All rights reserved.
    
    Connected to:
    Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
    
    SQL> CREATE TABLE test (no int, name varchar2(20));
    
    Table created.
    
    SQL> INSERT INTO test VALUES (1, ’oracle’);	
    				
    1 row created.
    
    SQL> SELECT * FROM test;
    
    	NO   NAME
    ----------- -------------------------------------------------------------------------- 
            1    oracle

    #. 시작 & 중지

    • 인스턴스 시작/중지

    sqlplus를 시작하여 나오는 SQL> 프롬프트에서 인스턴스를 시작/중지할 수 있다

    sqlplus '/as sysdba'
    SQL> startup
    SQL> shutdown 
    • 리스너 시작/중지
    # lsnrctl start
    # lsnrctl stop
    • 시작하는 순서 : 인스턴스 > 리스너
    # su oracle
    bin]$ sqlplus / as sysdba
    SQL> startup
    bin]$ lsnrctl start
    • 종료하는 순서 : 리스너 > 인스탄스
    # su oracle
    bin]$ lsnrctl stop
    bin]$ sqlplus / as sysdba
    SQL> shutdown

    민갤

    Back-End Developer

    백엔드 개발자입니다.