Windows WSL 登陆后显示如下:
Welcome to Ubuntu 20.04.4 LTS (GNU/Linux 4.4.0-19041-Microsoft x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Tue Aug 22 14:12:16 CST 2023
System load: 0.52
Usage of /home: unknown
Memory usage: 75%
Swap usage: 2%
Processes: 12
Users logged in: 0
登陆WSL系统上,从Oracle下载几个压缩包
~# wget https://download.oracle.com/otn_software/linux/instantclient/2111000/instantclient-sqlplus-linux.x64-21.11.0.0.0dbru.zip
--2023-08-22 10:26:32-- https://download.oracle.com/otn_software/linux/instantclient/2111000/instantclient-sqlplus-linux.x64-21.11.0.0.0dbru.zip
Resolving download.oracle.com (download.oracle.com)... 23.203.124.79
Connecting to download.oracle.com (download.oracle.com)|23.203.124.79|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 936855 (915K) [application/zip]
Saving to: ‘instantclient-sqlplus-linux.x64-21.11.0.0.0dbru.zip’
instantclient-sqlplus-linux.x 100%[==============================================>] 914.90K 172KB/s in 5.3s
2023-08-22 10:26:38 (172 KB/s) - ‘instantclient-sqlplus-linux.x64-21.11.0.0.0dbru.zip’ saved [936855/936855]
~# wget https://download.oracle.com/otn_software/linux/instantclient/2111000/instantclient-basic-linux.x64-21.11.0.0.0dbru.zip
--2023-08-22 10:27:18-- https://download.oracle.com/otn_software/linux/instantclient/2111000/instantclient-basic-linux.x64-21.11.0.0.0dbru.zip
Resolving download.oracle.com (download.oracle.com)... 23.203.124.79
Connecting to download.oracle.com (download.oracle.com)|23.203.124.79|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 78744025 (75M) [application/zip]
Saving to: ‘instantclient-basic-linux.x64-21.11.0.0.0dbru.zip’
instantclient-basic-linux.x64 100%[==============================================>] 75.10M 1.75MB/s in 59s
2023-08-22 10:28:19 (1.27 MB/s) - ‘instantclient-basic-linux.x64-21.11.0.0.0dbru.zip’ saved [78744025/78744025]
~# wget https://download.oracle.com/otn_software/linux/instantclient/2111000/instantclient-jdbc-linux.x64-21.11.0.0.0dbru.zip
--2023-08-22 10:40:23-- https://download.oracle.com/otn_software/linux/instantclient/2111000/instantclient-jdbc-linux.x64-21.11.0.0.0dbru.zip
Resolving download.oracle.com (download.oracle.com)... 23.203.124.79
Connecting to download.oracle.com (download.oracle.com)|23.203.124.79|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1579011 (1.5M) [application/zip]
Saving to: ‘instantclient-jdbc-linux.x64-21.11.0.0.0dbru.zip’
instantclient-jdbc-linux.x64- 100%[==============================================>] 1.51M 301KB/s in 5.1s
2023-08-22 10:40:29 (301 KB/s) - ‘instantclient-jdbc-linux.x64-21.11.0.0.0dbru.zip’ saved [1579011/1579011]
~# wget https://download.oracle.com/otn_software/linux/instantclient/2111000/instantclient-sdk-linux.x64-21.11.0.0.0dbru.zip
--2023-08-22 10:28:39-- https://download.oracle.com/otn_software/linux/instantclient/2111000/instantclient-sdk-linux.x64-21.11.0.0.0dbru.zip
Resolving download.oracle.com (download.oracle.com)... 104.76.200.85
Connecting to download.oracle.com (download.oracle.com)|104.76.200.85|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1001766 (978K) [application/zip]
Saving to: ‘instantclient-sdk-linux.x64-21.11.0.0.0dbru.zip’
instantclient-sdk-linux.x64-2 100%[==============================================>] 978.29K 479KB/s in 2.0s
2023-08-22 10:28:42 (479 KB/s) - ‘instantclient-sdk-linux.x64-21.11.0.0.0dbru.zip’ saved [1001766/1001766]
分别解压四个压缩包:
root@jinju:~# mkdir instantclient
root@jinju:~# mv instantclient-* instantclient
# unzip instantclient-basic-linux.x64-21.11.0.0.0dbru.zip
# unzip instantclient-sqlplus-linux.x64-21.11.0.0.0dbru.zip
# unzip instantclient-sdk-linux.x64-21.11.0.0.0dbru.zip
# unzip instantclient-jdbc-linux.x64-21.11.0.0.0dbru.zip
然后全部进入~/instantclient/instantclient_21_11里了
root@jinju:~/instantclient# cd instantclient_21_11/
root@jinju:~/instantclient/instantclient_21_11# ls
BASIC_LICENSE genezi libclntsh.so.21.1 libocci.so libocci_gcc53.so.21.1 orai18n.jar
BASIC_README glogin.sql libclntshcore.so libocci.so.10.1 libociei.so sdk
JDBC_LICENSE libclntsh.so DESKTOP-35UHREQ- libclntshcore.so.12.1 libocci.so.11.1 libocijdbc21.so sqlplus
JDBC_README libclntsh.so.10.1 libclntshcore.so.18.1 libocci.so.12.1 liboramysql.so ucp.jar
SDK_LICENSE libclntsh.so.11.1 libclntshcore.so.19.1 libocci.so.18.1 libsqlplus.so uidrvci
SDK_README libclntsh.so.12.1 libclntshcore.so.20.1 libocci.so.19.1 libsqlplusic.so xstreams.jar
SQLPLUS_LICENSE libclntsh.so.18.1 libclntshcore.so.21.1 libocci.so.20.1 network
SQLPLUS_README libclntsh.so.19.1 libheteroxa21.so libocci.so.21.1 ojdbc8.jar
adrci libclntsh.so.20.1 libnnz21.so libocci_gcc53.so orai18n-mapping.jar
规范一下放置的路径,放到上面解压的路径也是可以的
root@jinju:~/instantclient# mkdir -p /u01/app/oracle/product/19.0.0/client_1
root@jinju:~/instantclient# cp -rf ~/instantclient/instantclient_21_11/* /u01/app/oracle/product/19.0.0/client_1/
/etc/profile 添加路径
root@jinju:~/instantclient/instantclient_21_11# more /etc/profile
。。。
export ORACLE_HOME=/u01/app/oracle/product/19.0.0/client_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=$PATH:$ORACLE_HOME:$ORACLE_HOME/lib:$ORACLE_HOME/sdk/include
安装个JDK
root@jinju:~/instantclient/instantclient_21_11/sdk# apt install openjdk-17*
测试下SQL*Plus ,可以用连接串访问Oracle
root@jinju:~# sqlplus test/test@192.168.3.107:1521/PDB1
SQL*Plus: Release 21.0.0.0.0 - Production on Tue Aug 22 11:16:16 2023
Version 21.11.0.0.0
Copyright (c) 1982, 2022, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> show user;
USER is "TEST"
SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
添加tnsnames.ora 配置,简化连接串访问
root@jinju:~# cd $ORACLE_HOME/network/admin
root@jinju:/u01/app/oracle/product/19.0.0/client_1/network/admin# touch tnsnames.ora
root@jinju:/u01/app/oracle/product/19.0.0/client_1/network/admin# more tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/19.3.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
107ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.3.107)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
107PDB1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.3.107)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdb1)
)
)
继续测试
root@jinju:/u01/app/oracle/product/19.0.0/client_1/network/admin# sqlplus test/test@107PDB1
SQL*Plus: Release 21.0.0.0.0 - Production on Tue Aug 22 11:29:21 2023
Version 21.11.0.0.0
Copyright (c) 1982, 2022, Oracle. All rights reserved.
Last Successful login time: Tue Aug 22 2023 11:29:16 +08:00
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> show user;
USER is "TEST"
SQL> show con_name;
CON_NAME
------------------------------
PDB1
Ok,使用正常