본문 바로가기
정보관리(데이터베이스, DB)/오라클

리눅스 Rock9 오라클18c 설치하기

by 3604 2023. 7. 26.
728x90

출처: 개발과 일상 (tistory.com)

오라클 설치

이전에 GoogleCloud 에서 IaaS 환경의 가상머신을 만드는 방법에 대해 포스팅했었습니다.

 

이번에는 DBMS중 하나인 오라클 18c 버전을 GoogleCloud 가상머신에 설치하는 방법에 대해

설명해보겠습니다.

 

사용자 생성및 환경변수 설정

설치를 하기에 앞서서 oracle 계정과 오라클 DBMS를 사용하기위한 환경변수 설정이 필요합니다.

 

$ useradd oracle
$ passwd oracle
Changing password for user oracle.
New password: 
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: 
passwd: all authentication tokens updated successfully.

oracle 계정생성후 바로 패스워드 생성까지 해줍시다.

 

환경변수 설정은 /etc/bashrc 파일의 가장 아래부분에 내용을 추가하여 저장합니다.

$ vi /etc/bashrc
export ORACLE_HOME=/opt/oracle/product/18c/dbhomeXE
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORACLE_SID=XE
export ORAENV_ASK=NO
export PATH=$PATH:$ORACLE_HOME/bin

 

oracle-database-preinstall-18c 다운및 설치

$ curl -o oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm

$ yum -y localinstall oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm

오라클 18c 설치전 먼저 설치해놔야 하는 패키지입니다.

 

파일 다운로드

오라클 18c 설치프로그램을 다운받고 설치를 진행합니다.

$ wget https://download.oracle.com/otn-pub/otn_software/db-express/oracle-database-xe-18c-1.0-1.x86_64.rpm

 

설치 시작

$ yum -y localinstall oracle-database*18c*
참고
 
오류 발생
 문제 1: 충돌하는 요청
  - compat-libcap1 필요한 oracle-database-preinstall-18c-1.0-1.el7.x86_64 제공되지 않았습니다
- compat-libstdc++-33 필요한 oracle-database-preinstall-18c-1.0-1.el7.x86_64 제공되지 않았습니다
 
오류 해결
 
yum install -y http://mirror.centos.org/centos/7/os/x86_64/Packages/compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
 
yum install -y http://mirror.centos.org/centos/7/os/x86_64/Packages/compat-libcap1-1.10-7.el7.x86_64.rpm

초기 설정

$ /etc/init.d/oracle-xe-18c configure

 

Specify a password to be used for database accounts. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9]. Note that the same password will be used for SYS, SYSTEM and PDBADMIN accounts:oracle

 

참고

오류 발생
/opt/oracle/product/18c/dbhomeXE/bin/orabase: error while loading shared libraries: libnsl.so.1: cannot open shared object file: No such file or directory

오류 해결
$yum install -y libnsl

 [/etc/init.d]$ ./oracle-xe-18c configure


초기설정중에 SYS, SYSTEM 계정에 대한 비밀번호(예시: oracle)를 설정하는 부분이 있는데 잊지 않도록 주의하며

잘 만들어야 합니다.

설치 다해놓고 비밀번호 까먹어서 찾아 헤메다 재설치하는 대참사가 일어날수 있습니다...

참고

데이터베이스 생성이 완료되었습니다. 자세한 내용은 다음의 로그 파일에서 확인하십시오.
 /opt/oracle/cfgtoollogs/dbca/XE
데이터베이스 정보:
전역 데이터베이스 이름:XE
SID(시스템 식별자):XE
자세한 내용은 로그 파일 "/opt/oracle/cfgtoollogs/dbca/XE/XE.log"을(를) 참조하십시오.

Connect to Oracle Database using one of the connect strings:
     Pluggable database: localhost.localdomain/XEPDB1
     Multitenant container database: localhost.localdomain
Use https://localhost:5500/em to access Oracle Enterprise Manager for Oracle Database XE

오라클 접속

먼저 오라클 리스너의 상태를 확인해보겠습니다.

 

리스너 상태확인

#oracle 설치한 계정으로 접속한 후
$su - oracle 
#listener 상태 확인
$ lsnrctl status
LSNRCTL for Linux: Version 18.0.0.0.0 - Production on 17-JUN-2021 00:48:38

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle-install.asia-northeast3-a.c.eighth-physics-314814.internal)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 18.0.0.0.0 - Production
Start Date                17-JUN-2021 00:15:56
Uptime                    0 days 0 hr. 32 min. 42 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Default Service           XE
Listener Parameter File   /opt/oracle/product/18c/dbhomeXE/network/admin/listener.ora
Listener Log File         /opt/oracle/diag/tnslsnr/oracle-install/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle-install.asia-northeast3-a.c.eighth-physics-314814.internal)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=127.0.0.1)(PORT=5500))(Security=(my_wallet_directory=/opt/oracle/admin/XE/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "XE" has 1 instance(s).
Instance "XE", status READY, has 1 handler(s) for this service...
Service "XEXDB" has 1 instance(s).
Instance "XE", status READY, has 1 handler(s) for this service...
Service "c4ec4500348319eee0530600b20a292c" has 1 instance(s).
Instance "XE", status READY, has 1 handler(s) for this service...
Service "xepdb1" has 1 instance(s).
Instance "XE", status READY, has 1 handler(s) for this service...
The command completed successfully

로그에 별문제가 없이 리스너가 실행중이라면 정상적으로 설치되었다는 뜻입니다.

참고

리스너 오류

리스너 기동 에러/TNS-12541/TNS-12560/TNS-00511/Linux Error: 111


1. /etc/hosts에  IP 추가(예시: 192.168.56.10) 및 localhost를 아래와 같이 기재






2. 사례

출처: 리스너 기동 에러/TNS-12541/TNS-12560/TNS-00511/Linux Error: 111 :: 멋지게 놀아라 (tistory.com)
리스너 start하면 정상기동으로 나오지만 status  보면 리스너가 기동되지 않음

ㅁ listener.ora 파일 내용---------------------------------------------

[oracle@ora11g admin]$ cat listener.ora

# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

# Generated by Oracle configuration tools.

 

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = TCP)(HOST = ora11g)(PORT = 1521))

      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

    )

  )

 

ADR_BASE_LISTENER = /u01/app/oracle
--------------------------------------------------ㅁ


ㅁ lsnrctl start 기동 내용-------------------------------------------------

[oracle@ora11g admin]$ lsnrctl start

 

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 13-MAY-2016 15:36:28

 

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

 

Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...

 

TNSLSNR for Linux: Version 11.2.0.4.0 - Production

System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

Log messages written to /u01/app/oracle/diag/tnslsnr/ora11g/listener/alert/log.xml

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ora11g)(PORT=1521)))

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

 

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ora11g)(PORT=1521)))

STATUS of the LISTENER

------------------------

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production

Start Date                13-MAY-2016 15:36:29

Uptime                    0 days 0 hr. 0 min. 0 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

Listener Log File         /u01/app/oracle/diag/tnslsnr/ora11g/listener/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ora11g)(PORT=1521)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Services Summary...

Service "ora11g" has 1 instance(s).

  Instance "ora11g", status UNKNOWN, has 1 handler(s) for this service...

The command completed successfully
------------------------------------------------------ㅁ

ㅁ lsnrctl status 명령 수행-------------------------------------------------------------

[oracle@ora11g admin]$ lsnrctl stauts

 

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 13-MAY-2016 15:36:37

 

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

 

NL-00853: undefined command "stauts".  Try "help"

[oracle@ora11g admin]$ lsnrctl status

 

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 13-MAY-2016 15:36:42

 

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

 

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ora11g)(PORT=1521)))

TNS-12541: TNS:no listener

 TNS-12560: TNS:protocol adapter error

  TNS-00511: No listener

   Linux Error: 111: Connection refused

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))

TNS-12541: TNS:no listener

 TNS-12560: TNS:protocol adapter error

  TNS-00511: No listener

   Linux Error: 111: Connection refused

-------------------------------------------------------ㅁ

대부분 인터넷을 찾아보면 ora11g 대하여 /etc/hosts 파일에 설정이 안되어 있어서 그렇다는 내용이 대부분


[oracle@ora11g admin]$ ping ora11g
PING ora11g (192.168.10.10) 56(84) bytes of data.
64 bytes from ora11g (192.168.10.10): icmp_seq=1 ttl=64 time=0.021 ms
64 bytes from ora11g (192.168.10.10): icmp_seq=2 ttl=64 time=0.074 ms
64 bytes from ora11g (192.168.10.10): icmp_seq=3 ttl=64 time=0.065 ms


--- ora11g ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 0.021/0.053/0.074/0.023 ms


[oracle@ora11g admin]$ cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1        localhost.localdomain
::1                localhost6.localdomain6 localhost6


192.168.10.10   ora11g
192.168.10.11   winvm


위와 같이 모든  정상적임 .


한참 구글링 하다가 우연히 /etc/hosts 파일에 localhost 설정 안되어 있으면 그렇다는 포스팅을 보게 .


[oracle@ora11g admin]$ cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1        localhost.localdomain localhost
::1                localhost6.localdomain6 localhost6


192.168.10.10   ora11g
192.168.10.11   winvm


위와 같이 localhost 추가.

ㅁ 리스너 기동 결과-----------------------------------------------------

[oracle@ora11g admin]$ lsnrctl status

 

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 13-MAY-2016 15:40:38

 

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

 

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ora11g)(PORT=1521)))

STATUS of the LISTENER

------------------------

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production

Start Date                13-MAY-2016 15:40:30

Uptime                    0 days 0 hr. 0 min. 8 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

Listener Log File         /u01/app/oracle/diag/tnslsnr/ora11g/listener/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ora11g)(PORT=1521)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

The listener supports no services

The command completed successfully

[oracle@ora11g admin]$ lsnrctl status

 

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 13-MAY-2016 15:40:46

 

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

 

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ora11g)(PORT=1521)))

STATUS of the LISTENER

------------------------

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production

Start Date                13-MAY-2016 15:40:30

Uptime                    0 days 0 hr. 0 min. 15 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

Listener Log File         /u01/app/oracle/diag/tnslsnr/ora11g/listener/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ora11g)(PORT=1521)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

The listener supports no services

The command completed successfully
----------------------------------------------------ㅁ
 

 

 

sqlplus 접속및 DB 시작/종료 테스트

이제 sqlplus로 오라클DB에 접속해서 데이터베이스를 종료하고 다시 시작해봅시다.

 

sysdba 계정으로 접속해야하는데 위에서 설정한 비밀번호를 입력하여 접속합니다.

$ sqlplus /nolog

SQL> conn sys /as sysdba
Enter password: 
Connected.

SQL> SHUTDOWN IMMEDIATE
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> STARTUP
ORACLE instance started.

Total System Global Area 1191181104 bytes
Fixed Size                  8895280 bytes
Variable Size             436207616 bytes
Database Buffers          738197504 bytes
Redo Buffers                7880704 bytes
Database mounted.
Database opened.

 

사용자 계정 생성

리스너도 정상이고 데이터베이스도 정상 실행확인이 되었으니 이제 사용자 계정을 해봅시다.

 

계정생성

SQL> CREATE USER [USER_NAME] IDENTIFIED BY [PASSWD];

 

권한 부여

SQL> GRANT CONNECT, RESOURCE, DBA TO [USER_NAME]

 

예시

SQL> CREATE USER C##TEST IDENTIFIED BY 1234;

User created.

SQL> GRANT CONNECT, RESOURCE, DBA TO C##TEST;

Grant succeeded.

 

사용자 접속

SQL> conn
Enter user-name: C##TEST
Enter password: 
Connected.

 

여기까지해서 GoogleCloud 서버에 오라클 설치및 사용자 계정생성까지 모두 끝났습니다~

 

참고

오라클 설치 후 폰트 깨짐

출처: [ Oracle ] 오라클 한글 깨짐 현상 (tistory.com)

 

CentOS에서 오라클 설치를 완료한 후, 

SQLPlus를 통해 접속을 했는데, 다음과 같이 한글이 나오지 않는 현상 발생함

 

[oracle@imcodding ~]$ sqlplus "/as sysdba"

SQL*Plus: Release 19.0.0.0.0 - Production on 금 6월 12 10:35:34 2020
Version 19.3.0.0.0

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


??? ???:
...

 

왜 이런 현상이 발생하는 걸까요? 바로 characterset 때문입니다.

오라클 데이터베이스를 생성할 때, .bash_profile에서 미리 NLS_LANG을 지정하지 않는다면
오라클은 US7ASCII 가 Default로 설정됩니다. 하지만 이는 한국어를 지원하지 않습니다.

 

SQL> select parameter, value from nls_database_parameters;

PARAMETER		VALUE
--------------------	---------------------
	:			:
NLS_LANGUAGE		KOREAN
NLS_TERRITORY		KOREA
NLS_CHARACTERSET	AL32UTF8
	:			:

 

위와 같이 보면, 현재 Client의 characterset은 AL32UTF8인 것을 알 수 있습니다.

오라클 데이터베이스와 클라이언트의 characterset은 일치해야 합니다. 

AL32UTF8이 한국어를 지원하기 때문에 이에 맞춰줍니다.

 

오라클의 .bash_profile에 다음과 같은 문장을 추가해줍니다.

export NLS_LANG=KOREAN_KOREA.AL32UTF8 

 

다시 오라클 시스템 계정으로 접속해보면, ? 로 나오던 것이 

정상적으로 한글로 나오는 것을 학인할 수 있습니다.

 

도움이 돼셨다면 로그인 필요없는 좋아요 ♡

부탁드립니다.

 

 

 

 

 

 

 

 

 

 

 

728x90