Server는 Oracle DB가 있는 구성에서 설치를 할 수 있습니다.
1.
설치 전에 필요 패키지가 있는데 없으면 설치해줍니다.
$ rpm -qa perl-Env
perl-Env-1.04-460.el9.noarch
없는경우 root에서 dnf 명령어로 수행합니다.
# dnf -y install perl-Env
Last metadata expiration check: 0:39:29 ago on Mon 04 Nov 2024 01:59:30 AM EST.
Dependencies resolved.
======================================================================================================================
Package Architecture Version Repository Size
======================================================================================================================
Installing:
perl-Env noarch 1.04-460.el9 appstream 20 k
Installing dependencies:
perl-Tie noarch 4.6-481.el9 appstream 31 k
Transaction Summary
======================================================================================================================
Install 2 Packages
Total download size: 51 k
Installed size: 62 k
Downloading Packages:
(1/2): perl-Tie-4.6-481.el9.noarch.rpm 195 kB/s | 31 kB 00:00
(2/2): perl-Env-1.04-460.el9.noarch.rpm 115 kB/s | 20 kB 00:00
----------------------------------------------------------------------------------------------------------------------
Total 56 kB/s | 51 kB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : perl-Tie-4.6-481.el9.noarch 1/2
Installing : perl-Env-1.04-460.el9.noarch 2/2
Running scriptlet: perl-Env-1.04-460.el9.noarch 2/2
Verifying : perl-Env-1.04-460.el9.noarch 1/2
Verifying : perl-Tie-4.6-481.el9.noarch 2/2
Installed:
perl-Env-1.04-460.el9.noarch perl-Tie-4.6-481.el9.noarch
Complete!
2.필요 패키지를 설치합니다.
필요패키지 목록
pandas==2.1.1
setuptools==68.0.0
scipy==1.12.0
matplotlib==3.8.4
oracledb==2.2.0
joblib==1.3.2
scikit-learn==1.4.1.post1
numpy==1.26.4
[oracle@localhost ~]$ cat b.txt
pandas==2.1.1
setuptools==68.0.0
scipy==1.12.0
matplotlib==3.8.4
oracledb==2.2.0
joblib==1.3.2
scikit-learn==1.4.1.post1
numpy==1.26.4
[oracle@localhost ~]$ pip install -r b.txt
Requirement already satisfied: pandas==2.1.1 in /opt/oracle/product/23ai/dbhomeFree/python/lib/python3.12/site-packages (from -r b.txt (line 1)) (2.1.1)
Requirement already satisfied: setuptools==68.0.0 in /opt/oracle/product/23ai/dbhomeFree/python/lib/python3.12/site-packages (from -r b.txt (line 2)) (68.0.0)
Requirement already satisfied: scipy==1.12.0 in /opt/oracle/product/23ai/dbhomeFree/python/lib/python3.12/site-packages (from -r b.txt (line 3)) (1.12.0)
Requirement already satisfied: matplotlib==3.8.4 in /opt/oracle/product/23ai/dbhomeFree/python/lib/python3.12/site-packages (from -r b.txt (line 4)) (3.8.4)
Requirement already satisfied: oracledb==2.2.0 in /opt/oracle/product/23ai/dbhomeFree/python/lib/python3.12/site-packages (from -r b.txt (line 5)) (2.2.0)
Collecting joblib==1.3.2 (from -r b.txt (line 6))
Downloading joblib-1.3.2-py3-none-any.whl.metadata (5.4 kB)
Requirement already satisfied: scikit-learn==1.4.1.post1 in /opt/oracle/product/23ai/dbhomeFree/python/lib/python3.12/site-packages (from -r b.txt (line 7)) (1.4.1.post1)
Requirement already satisfied: numpy==1.26.4 in /opt/oracle/product/23ai/dbhomeFree/python/lib/python3.12/site-packages (from -r b.txt (line 8)) (1.26.4)
Requirement already satisfied: python-dateutil>=2.8.2 in /opt/oracle/product/23ai/dbhomeFree/python/lib/python3.12/site-packages (from pandas==2.1.1->-r b.txt (line 1)) (2.9.0.post0)
Requirement already satisfied: pytz>=2020.1 in /opt/oracle/product/23ai/dbhomeFree/python/lib/python3.12/site-packages (from pandas==2.1.1->-r b.txt (line 1)) (2024.2)
Requirement already satisfied: tzdata>=2022.1 in /opt/oracle/product/23ai/dbhomeFree/python/lib/python3.12/site-packages (from pandas==2.1.1->-r b.txt (line 1)) (2024.2)
Requirement already satisfied: contourpy>=1.0.1 in /opt/oracle/product/23ai/dbhomeFree/python/lib/python3.12/site-packages (from matplotlib==3.8.4->-r b.txt (line 4)) (1.3.0)
Requirement already satisfied: cycler>=0.10 in /opt/oracle/product/23ai/dbhomeFree/python/lib/python3.12/site-packages (from matplotlib==3.8.4->-r b.txt (line 4)) (0.12.1)
Requirement already satisfied: fonttools>=4.22.0 in /opt/oracle/product/23ai/dbhomeFree/python/lib/python3.12/site-packages (from matplotlib==3.8.4->-r b.txt (line 4)) (4.54.1)
Requirement already satisfied: kiwisolver>=1.3.1 in /opt/oracle/product/23ai/dbhomeFree/python/lib/python3.12/site-packages (from matplotlib==3.8.4->-r b.txt (line 4)) (1.4.7)
Requirement already satisfied: packaging>=20.0 in /opt/oracle/product/23ai/dbhomeFree/python/lib/python3.12/site-packages (from matplotlib==3.8.4->-r b.txt (line 4)) (24.1)
Requirement already satisfied: pillow>=8 in /opt/oracle/product/23ai/dbhomeFree/python/lib/python3.12/site-packages (from matplotlib==3.8.4->-r b.txt (line 4)) (11.0.0)
Requirement already satisfied: pyparsing>=2.3.1 in /opt/oracle/product/23ai/dbhomeFree/python/lib/python3.12/site-packages (from matplotlib==3.8.4->-r b.txt (line 4)) (3.2.0)
Requirement already satisfied: cryptography>=3.2.1 in /opt/oracle/product/23ai/dbhomeFree/python/lib/python3.12/site-packages (from oracledb==2.2.0->-r b.txt (line 5)) (43.0.3)
Requirement already satisfied: threadpoolctl>=2.0.0 in /opt/oracle/product/23ai/dbhomeFree/python/lib/python3.12/site-packages (from scikit-learn==1.4.1.post1->-r b.txt (line 7)) (3.5.0)
Requirement already satisfied: cffi>=1.12 in /opt/oracle/product/23ai/dbhomeFree/python/lib/python3.12/site-packages (from cryptography>=3.2.1->oracledb==2.2.0->-r b.txt (line 5)) (1.15.1)
Requirement already satisfied: six>=1.5 in /opt/oracle/product/23ai/dbhomeFree/python/lib/python3.12/site-packages (from python-dateutil>=2.8.2->pandas==2.1.1->-r b.txt (line 1)) (1.16.0)
Requirement already satisfied: pycparser in /opt/oracle/product/23ai/dbhomeFree/python/lib/python3.12/site-packages (from cffi>=1.12->cryptography>=3.2.1->oracledb==2.2.0->-r b.txt (line 5)) (2.21)
Downloading joblib-1.3.2-py3-none-any.whl (302 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 302.2/302.2 kB 6.3 MB/s eta 0:00:00
Installing collected packages: joblib
Attempting uninstall: joblib
Found existing installation: joblib 1.4.2
Uninstalling joblib-1.4.2:
Successfully uninstalled joblib-1.4.2
Successfully installed joblib-1.3.2
[notice] A new release of pip is available: 24.0 -> 24.3.1
[notice] To update, run: pip install --upgrade pip
3.
설정을 위해서는 pyqcfg.sql 라는 sql스크립트를 수행하여 설정을 해야합니다.
스크립트의 위치는 /opt/oracle/product/23ai/dbhomeFree/oml4py/server입니다.
cd $ORACLE_HOME/oml4py/server 로도 이동이 가능합니다.
$ pwd
/opt/oracle/product/23ai/dbhomeFree/oml4py/server
$ ls
oml4py.ver omlpu21.sql pyqcfg.sql pyqepdrp00.sql pyqsys.sql
omlpdbmig.sql pyqadmin.plb pyqcrt.sql pyqgrant.sql pyquncfg.sql
omlpdwgrd.sql pyqapply.sql pyqdrp.sql pyqpdrp00.sql pyquser.sql
omlpe21.sql pyqatmldrp00.sql pyqecrt.sql pyqproc.plb pyqviw.sql
omlprelod.sql pyqcfg_dwcs.sql pyqembed.plb pyqrollback.sql
5.
CDB$ROOT에 설정을 먼저 진행합니다.
PYQSYS계정을 생성하고 해당 계정의 tablespace (SYSAUX)와 TEMP tablespace(TEMP)를 설정합니다.
spool 로 생성한 install_root.txt로 로그를 확인할 수 있습니다.
$ sqlplus / as sysdba
SQL*Plus: Release 23.0.0.0.0 - for Oracle Cloud and Engineered Systems on 수 11월 6 23:26:05 2024
Version 23.5.0.24.07
Copyright (c) 1982, 2024, Oracle. All rights reserved.
다음에 접속됨:
Oracle Database 23ai Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
Version 23.5.0.24.07
SQL> spool install_root.txt
SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
SQL> @pyqcfg.sql SYSAUX TEMP
세션이 변경되었습니다.
...
완료
6.
PDB에도 같은 스크립트로 생성합니다.
spool 로 생성한 install_pdb.txt로 로그를 확인할 수 있습니다.
$ sqlplus / as sysdba
SQL*Plus: Release 23.0.0.0.0 - for Oracle Cloud and Engineered Systems on 수 11월 6 23:32:44 2024
Version 23.5.0.24.07
Copyright (c) 1982, 2024, Oracle. All rights reserved.
다음에 접속됨:
Oracle Database 23ai Free Release 23.0.0.0.0 - Develop, Learn, and Run for Free
Version 23.5.0.24.07
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 FREEPDB1 READ WRITE NO
SQL> spool install_pdb.txt
SQL> alter session set container=FREEPDB1;
세션이 변경되었습니다.
SQL> show con_name
CON_NAME
------------------------------
FREEPDB1
SQL> @pyqcfg.sql SYSAUX TEMP
세션이 변경되었습니다.
...
완료
7.
설치 확인(PDB)
sys.pyq_config 테이블을 조회하여 잘 설정되었는지 확인할 수 있습니다.
SQL> show con_name
CON_NAME
------------------------------
FREEPDB1
SQL> select * from sys.pyq_config;
NAME
--------------------------------------------------------------------------------
VALUE
--------------------------------------------------------------------------------
PYTHONHOME
/opt/oracle/product/23ai/dbhomeFree/python
PYTHONPATH
/opt/oracle/product/23ai/dbhomeFree/oml4py/modules
VERSION
2.0
NAME
--------------------------------------------------------------------------------
VALUE
--------------------------------------------------------------------------------
PLATFORM
ODB
DSWLIST
oml.*;pandas.*;numpy.*;matplotlib.*;sklearn.*
8.
OML4Y를 이용하기 위한 새로운 유저를 생성
pyquser.sql 를 이용하여 편하게 유저를 생성할 수 있습니다.
사용 방법을 아래와 같습니다.
@pyquser.sql oml_user USERS TEMP unlimited pyqadmin
앞에서부터 각 변수의 설명입니다.
Username ,User's permanent tablespace , User's temporary tablespace , Permanent tablespace quota , PYQADMIN role
PDB에서 생성할 예정이므로 PDB로 접속후 수행합니다.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 FREEPDB1 READ WRITE NO
SQL> alter session set container=FREEPDB1;
세션이 변경되었습니다.
SQL>
SQL> @pyquser.sql oml_user USERS TEMP unlimited pyqadmin
세션이 변경되었습니다.
password의 값을 입력하십시오: oracle
구 1: create user &&1 identified by &password
신 1: create user oml_user identified by oracle
구 2: default tablespace &&2
신 2: default tablespace USERS
구 3: temporary tablespace &&3
신 3: temporary tablespace TEMP
구 4: quota &&4 on &&2
신 4: quota unlimited on USERS
사용자가 생성되었습니다.
구 4: 'create procedure, create mining model to &&1';
신 4: 'create procedure, create mining model to oml_user';
구 6: IF lower('&&5') = 'pyqadmin' THEN
신 6: IF lower('pyqadmin') = 'pyqadmin' THEN
구 7: execute immediate 'grant PYQADMIN to &&1';
신 7: execute immediate 'grant PYQADMIN to oml_user';
PL/SQL 처리가 정상적으로 완료되었습니다.
세션이 변경되었습니다.
9.접속 테스트
python에 접속하여 위에서 생성한 유저(oml_user)로 connect하여 python의 함수를 수행하는 테스트입니다. 2가 나오면 정상입니다.
$ python3
Python 3.12.3 (main, Jul 3 2024, 08:35:38) [GCC 8.5.0 20210514 (Red Hat 8.5.0-18.0.6)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import oml
>>> oml.connect(user='oml_user', password='oracle', host='192.168.56.1', port=1521, service_name='FREEPDB1')
>>> oml.script.create("TEST", func='def func():return 1+1', overwrite=True)
>>> res = oml.do_eval(func='TEST')
>>> res
2
테스트 후에는 삭제
oml.script.drop("TEST")
완료.
출처 : Oracle® Machine Learning for Python User's Guide
'Oracle > 설치' 카테고리의 다른 글
Oracle 23ai에 OML4Y client 설치 (1) | 2024.11.08 |
---|---|
[23ai free]를 rpm으로 설치해보기 (0) | 2024.10.28 |
DB 설치 전 OS 구성 시 각각 설정값의 의미 (0) | 2020.12.01 |
Oracle 19c Silent Single Install (CentOS 7.8 64bit) (0) | 2020.11.17 |
OEL 8.1 19c DB runinstall 시 나는 패키지 관련 에러 (0) | 2020.06.04 |
댓글