본문 바로가기

학습/DataBase

Rocky 9에 Oracle XE 21c 설치 가이드


# 의존 패키지 설치
wget https://dl.rockylinux.org/pub/rocky/8/AppStream/x86_64/os/Packages/c/compat-openssl10-1.0.2o-4.el8_6.x86_64.rpm
dnf -y localinstall compat-openssl10-1.0.2o-4.el8_6.x86_64.rpm

# 사전 설치 파일 다운로드
curl -o oracle-database-preinstall-21c-1.0-1.el8.x86_64.rpm https://yum.oracle.com/repo/OracleLinux/OL8/appstream/x86_64/getPackage/oracle-database-preinsta

# 설치 파일 다운로드

# oracle 로그인해야만 다운로드 받을 수 있으므로 웹브라우저 이용해서 다운 받고 진행

# https://www.oracle.com/kr/database/technologies/xe-downloads.html
curl -o oracle-database-xe-21c-1.0-1.ol8.x86_64.rpm https://yum.oracle.com/repo/OracleLinux/OL8/appstream/x86_64/getPackage/oracle-database-xe-21c-1.0-1.ol8.x86_64.rpm

# 사전 설치 파일 실행
sudo dnf -y localinstall oracle-database-preinstall-21c*
# 설치 파일 실행
sudo dnf -y localinstall oracle-database-xe-21c*

# redhat 9버전에서 사용하려면 추가해야 하는 옵션 
# 출처: https://www.reddit.com/r/oracle/comments/wdjslm/oracle_database_21c_xe_oracle_linux_9/?rdt=49103
export CV_ASSUME_DISTID=OEL8.4

# oracle 환경변수 설정 
su
echo "export ORACLE_HOME=/opt/oracle/product/21c/dbhomeXE" >> ~/.bashrc
echo "export PATH=\$PATH:\$ORACLE_HOME/bin" >> ~/.bashrc
echo "export ORACLE_SID=XE" >> ~/.bashrc
source ~/.bashrc

# 참고. https://docs.oracle.com/en/database/oracle/oracle-database/21/xeinl/installing-oracle-database-free.html#GUID-A5FCC804-5786-4B4B-B1B4-60E36E80B73F
# export ORACLE_SID=XE 
# export ORAENV_ASK=NO 
# . /opt/oracle/product/21c/dbhomeXE/bin/oraenv

  
# 비밀번호 설정
/etc/init.d/oracle-xe-21c configure

 

# oracle db 접속

sqlplus


# oracle 계정 추가
Enter user-name: system
Enter password: 
??? ??? ??? ??: ?  11? 02 2024 22:48:46 +09:00

??? ???:
Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0

SQL> alter session set "_ORACLE_SCRIPT"=true;

??? ???????.

SQL> 
SQL> create user ksson identified by oracle;
SQL> grant resource, connect, dba to ksson;
SQL> exit

# 접근 허용 정보 확인
[root@localhost 다운로드]# cat /opt/oracle/homes/OraDBHome21cXE/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /opt/oracle/homes/OraDBHome21cXE/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

XE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = XE)
    )
  )

LISTENER_XE =
  (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))

 

# 모든 ip 허용하도록 수정
[root@localhost 다운로드]# nano /opt/oracle/homes/OraDBHome21cXE/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /opt/oracle/homes/OraDBHome21cXE/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

XE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = XE)
    )
  )

LISTENER_XE =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))



# 모든 ip 허용하도록 수정
[root@localhost 다운로드]# nano /opt/oracle/homes/OraDBHome21cXE/network/admin/listener.ora 
# listener.ora Network Configuration File: /opt/oracle/homes/OraDBHome21cXE/network/admin/listener.ora
# Generated by Oracle configuration tools.

DEFAULT_SERVICE_LISTENER = XE

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )



# 오라클 재시작
[root@localhost 다운로드]# /etc/init.d/oracle-xe-21c restart
Shutting down Oracle Database instance XE.
Oracle Database instance XE shut down.
Stopping Oracle Net Listener.
Oracle Net Listener stopped.

Starting Oracle Net Listener.
Oracle Net Listener started.
Starting Oracle Database instance XE.
Oracle Database instance XE started.

[root@localhost 다운로드]# 


# 접속

1) 디비버를 사용해서 Database SID : XE 만 수정하고, Username, Password 입력하면 접속이 성공한다

2) sqlplus : sqlplus user/password@//hostname:port/service_name

예 : sqlplus ksson/oracle@//localhost:1521/XE