yum, EPEL 통한 리눅스 패키지 설치, rlwrap 패키지
MobaXterm에서 원격으로 SQL*Plus 통해 SQL 작업시 키보드 커서 입력 불편함 해결하는 예를 통해 리눅스 패키지 설치하는 방법을 확인한다.
sqlplus에서 방향키가 기능적으로 작동(예를 들면, 윗방향 화살표 입력 시 이전 명령 붙여넣기)하지 않고, 일반적인 방향키처럼 커서의 위치가 이동되는 문제를 발견했다. 심지어 SQL> 라고 나오는 프롬프트 부분도 상관없이 넘어간다(이동한다). 해결 방법으로 rlwrap 유틸리티를 설치한다.
rlwrap(readline wrapper) 유틸리티는 명령 기록을 제공하고 다른 명령에 대한 키보드 입력 편집을 제공한다. 이것은 Linux의 SQL*Plus 및 RMAN에 정말 편리한 추가 기능이다. 여기서는 rlwrap을 설치하고 SQL*Plus으로 설정하는 방법을 설명한다. RMAN용으로도 설정할 수 있다.
- rpm파일 다운로드 및 설치: 우선 https://yum.oracle.com/oracle-linux-7.html 에 가서(Oracle Linux 7 기준) EPEL 부분의 자신의 해당 머신 부분 리스트로 들어간다. EPEL Packages: x86_64, Source(x86_64), aarch64, Source(aarch64)
Latest EPEL packages for Oracle Linux 7. 일반적으로는 위에서 x86_64로 선택해서 들어가면 된다. 소스는 개발이나 디버깅할 때 필요하다. 운영 체제는 위에서 볼 수 있듯 x86_64와 arch64를 지원한다. 그 후 필요한 패키지를 찾고 우측의 다운로드 링크를 복사한다. 터미널에 curl -O https://yum.oracle.com/repo/OracleLinux/OL7/developer_EPEL/x86_64/getPackage/rlwrap-0.43-2.el7.x86_64.rpm 이처럼 입력해서 패키지를 다운로드 받는다.
- 바이너리 파일 보는 방법: hexdump -C yourfile.bin 그러나 편집은 제한된다. 대부분의 Linux 배포판에는 기본적으로 hexdump가 있다.
- yum으로 파이썬 설치: [root@enp0s3 sjh]# yum install python3
Loaded plugins: langpacks, ulninfo
Resolving Dependencies
--> Running transaction check
---> Package python3.x86_64 0:3.6.8-18.0.3.el7 will be installed
--> Processing Dependency: python3-libs(x86-64) = 3.6.8-18.0.3.el7 for package: python3-3.6.8-18.0.3.el7.x86_64
--> Processing Dependency: python3-pip for package: python3-3.6.8-18.0.3.el7.x86_64
--> Processing Dependency: python3-setuptools for package: python3-3.6.8-18.0.3.el7.x86_64
--> Processing Dependency: libpython3.6m.so.1.0()(64bit) for package: python3-3.6.8-18.0.3.el7.x86_64
--> Running transaction check
---> Package python3-libs.x86_64 0:3.6.8-18.0.3.el7 will be installed
---> Package python3-pip.noarch 0:9.0.3-8.el7 will be installed
---> Package python3-setuptools.noarch 0:39.2.0-10.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================
Installing:
python3 x86_64 3.6.8-18.0.3.el7 ol7_latest 70 k
Installing for dependencies:
python3-libs x86_64 3.6.8-18.0.3.el7 ol7_latest 6.9 M
python3-pip noarch 9.0.3-8.el7 ol7_latest 1.6 M
python3-setuptools noarch 39.2.0-10.el7 ol7_latest 628 k
Transaction Summary
====================================================================================================================================
Install 1 Package (+3 Dependent packages)
Total download size: 9.3 M
Installed size: 47 M
Is this ok [y/d/N]: y
Downloading packages:
(1/4): python3-3.6.8-18.0.3.el7.x86_64.rpm | 70 kB 00:00:00
(2/4): python3-pip-9.0.3-8.el7.noarch.rpm | 1.6 MB 00:00:00
(3/4): python3-setuptools-39.2.0-10.el7.noarch.rpm | 628 kB 00:00:00
(4/4): python3-libs-3.6.8-18.0.3.el7.x86_64.rpm | 6.9 MB 00:00:01
------------------------------------------------------------------------------------------------------------------------------------
Total 4.9 MB/s | 9.3 MB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : python3-setuptools-39.2.0-10.el7.noarch 1/4
Installing : python3-libs-3.6.8-18.0.3.el7.x86_64 2/4
Installing : python3-3.6.8-18.0.3.el7.x86_64 3/4
Installing : python3-pip-9.0.3-8.el7.noarch 4/4
Verifying : python3-pip-9.0.3-8.el7.noarch 1/4
Verifying : python3-3.6.8-18.0.3.el7.x86_64 2/4
Verifying : python3-setuptools-39.2.0-10.el7.noarch 3/4
Verifying : python3-libs-3.6.8-18.0.3.el7.x86_64 4/4
Installed:
python3.x86_64 0:3.6.8-18.0.3.el7
Dependency Installed:
python3-libs.x86_64 0:3.6.8-18.0.3.el7 python3-pip.noarch 0:9.0.3-8.el7 python3-setuptools.noarch 0:39.2.0-10.el7
Complete!
- 위에서 의존성 해결하기 위해서 파이썬(3.6)설치 했지만 여전히 의존성 에러 발생함. [root@enp0s3 sjh]# yum install rlwrap-0.43-2.el7.x86_64.rpm
Loaded plugins: langpacks, ulninfo
Examining rlwrap-0.43-2.el7.x86_64.rpm: rlwrap-0.43-2.el7.x86_64
Marking rlwrap-0.43-2.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package rlwrap.x86_64 0:0.43-2.el7 will be installed
--> Processing Dependency: /usr/bin/python3.4 for package: rlwrap-0.43-2.el7.x86_64
--> Processing Dependency: /usr/bin/python3.4 for package: rlwrap-0.43-2.el7.x86_64
--> Finished Dependency Resolution
Error: Package: rlwrap-0.43-2.el7.x86_64 (/rlwrap-0.43-2.el7.x86_64)
Requires: /usr/bin/python3.4
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
- EPEL로부터 rlwrap 설치하는 방법으로 재시도..
- EPEL yum 구성: 먼저 EPEL yum 저장소를 구성한다. 이 경우 el7등에 설치 가능하고 아래 표시된 패키지를 다운로드한다. yum 저장소만 설치하면 됩니다. 다음 명령은 EPEL 리포지토리를 다운로드하고 구성한다.
[root@enp0s3 sjh]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm(을)를 복구합니다
경고: /var/tmp/rpm-tmp.pZVJOy: Header V4 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
준비 중... ################################# [100%]
Updating / installing...
1:epel-release-7-14 ################################# [100%]
저장소가 제자리에 있으면 다음 명령을 사용하여 rlwrap을 설치할 수 있다.
[root@enp0s3 sjh]# yum install rlwrap
Loaded plugins: langpacks, ulninfo
ol7_UEKR6 | 3.0 kB 00:00:00
ol7_latest | 3.6 kB 00:00:00
(1/2): ol7_latest/x86_64/updateinfo | 3.3 MB 00:00:00
(2/2): ol7_latest/x86_64/primary_db | 36 MB 00:00:04
Resolving Dependencies
--> Running transaction check
---> Package rlwrap.x86_64 0:0.43-2.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================
Installing:
rlwrap x86_64 0.43-2.el7 epel 119 k
Transaction Summary
====================================================================================================================================
Install 1 Package
Total download size: 119 k
Installed size: 281 k
Is this ok [y/d/N]: y
Downloading packages:
경고: /var/cache/yum/x86_64/7Server/epel/packages/rlwrap-0.43-2.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Public key for rlwrap-0.43-2.el7.x86_64.rpm is not installed
rlwrap-0.43-2.el7.x86_64.rpm | 119 kB 00:00:00
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Importing GPG key 0x352C64E5:
Userid : "Fedora EPEL (7) <epel@fedoraproject.org>"
Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
Package : epel-release-7-14.noarch (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : rlwrap-0.43-2.el7.x86_64 1/1
Verifying : rlwrap-0.43-2.el7.x86_64 1/1
Installed:
rlwrap.x86_64 0:0.43-2.el7
Complete!
중간에 Public key 미설치 관련 경고나 RPMDB 관련 경고가 떴지만 rlwrap 패키지를 설치완료했다.
- 추가로 구성한 epel등 저장소를 나열하는 명령은 다음과 같다.
[root@enp0s3 sjh]# yum repolist
Loaded plugins: langpacks, ulninfo
repo id repo name status
epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,683
ol7_UEKR6/x86_64 Latest Unbreakable Enterprise Kernel Release 6 for Oracle Linux 7Server (x86_64) 456
ol7_latest/x86_64 Oracle Linux 7Server Latest (x86_64) 23,282
repolist: 37,421
- 이렇게 의존성 해결이 자동으로 안될땐 epel을 통해 다시 시도해본다. 또한 위처럼 직접 URL을 지정할 수도 있지만, yum install epel-release로 구성할 수도 있다.
( https://medium.com/sjk5766/yum%EC%97%90-%EB%8C%80%ED%95%B4-%EC%95%8C%EC%95%84%EB%B3%B4%EC%9E%90-a41a75a0136b )
- 이제 명령줄에서 rlwrap을 사용하여 SQL*Plus 로드를 더 친숙하게 만들 수 있다. SQLPlus에 readline 지원을 추가하여 커서 키를 사용하여 이전 쿼리로 이동하고(기록을 유지) 실수를 했을 때 이를 편집할 수 있다. 사용 방법 예는 다음과 같다. [oracle@orcl ~]$ rlwrap -i sqlplus 혹은 rlwrap sqlplus 으로 가능하다.
- Alias에 rlwrap추가하기
- oracle계정에 alias 추가: 작업 전 확인한다.
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functions
명령줄에 echo 'alias sqlplus="rlwrap sqlplus"' >> ~/.bashrc 입력한다. 그 후 변경됐는지 확인한다.
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functions
alias sqlplus="rlwrap sqlplus"
변경된 부분 확인하고 다음과 같이 .(점) 명령으로 변경 적용한다.
[oracle@orcl ~]$ . ~/.bashrc
이제 sqlplus 유틸 시작 시마다 앞에 rlwrap 붙일 필요없이, 평소처럼 sqlplus 입력만으로도 rlwrap을 붙인 것과 동일하게 명령을 받는다.