“连接 Debian + Oracle”通常有以下几种常见场景,我分别说明,你可以对号入座:
在 Debian 上一般使用 Oracle Instant Client。
sudo apt update
sudo apt install -y libaio1 wget unzip
下载 Instant Client(以 19c 为例):
cd /opt
sudo wget https://download.oracle.com/otn_software/linux/instantclient/1919000/instantclient-basic-linux.x64-19.19.0.0.0dbru.zip
sudo wget https://download.oracle.com/otn_software/linux/instantclient/1919000/instantclient-sqlplus-linux.x64-19.19.0.0.0dbru.zip
sudo unzip instantclient-basic-linux.x64-19.19.0.0.0dbru.zip
sudo unzip instantclient-sqlplus-linux.x64-19.19.0.0.0dbru.zip
sudo mv instantclient_19_19 /opt/oracle
echo 'export ORACLE_HOME=/opt/oracle/instantclient_19_19' >> ~/.bashrc
echo 'export PATH=$ORACLE_HOME:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=$ORACLE_HOME:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc
sqlplus 用户名/密码@//IP:1521/服务名
示例:
sqlplus system/oracle@//192.168.1.100:1521/ORCLPDB1
oracledb)pip install oracledb
import oracledb
conn = oracledb.connect(
user="system",
password="oracle",
host="192.168.1.100",
port=1521,
service_name="ORCLPDB1"
)
cursor = conn.cursor()
cursor.execute("SELECT sysdate FROM dual")
print(cursor.fetchone())
⚠️ Oracle 官方 不支持 Debian,只在 RHEL / Oracle Linux 上支持。
如果你一定要装:
docker run -d \
-p 1521:1521 \
-e ORACLE_PASSWORD=oracle \
container-registry.oracle.com/database/free
ORA-12170:网络或防火墙问题libaio.so 缺失:安装 libaio1lsnrctl status 查如果你能具体说明:
我可以给你更精确的步骤。