Oracle

無法更改 container-registry.oracle.com/database/enterprise 的 ORACLE_SID

  • November 15, 2020

我像這樣在docker中執行oracle數據庫

docker run -d --rm --name oracle_online -e ORACLE_SID=xxx -e ORACLE_PDB=xxx -e ORACLE_PWD=xxx -v /home/data/oracle:/opt/oracle/oradata -it -p 1521:1521 container-registry.oracle.com/database/enterprise:12.2.0.1

當它啟動時,ORACLE_SID 沒有改變,它總是ORCLCDB

TNSLSNR for Linux: Version 12.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/12.2.0/dbhome_1/admin/ORCLCDB/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/95c1ad3d33bd/listener/alert/log.xml

...

#ip-address : IP address of the host where the container is running.
#port       : Host Port that is mapped to the port 1521 of the container.
#
# The mapped port can be obtained from running "docker port <container-id>"
# ===========================================================================
Completed:     alter pluggable database ORCLPDB1 open
2020-11-14T05:42:36.136965+00:00
   alter pluggable database all save state
Completed:     alter pluggable database all save state
2020-11-14T05:42:36.426957+00:00
ALTER SYSTEM SET encrypt_new_tablespaces='DDL' SCOPE=BOTH;
2020-11-14T05:42:38.664560+00:00

有誰知道如何更改SID?

當然,您需要在數據庫啟動之前更改 pfile/spfile 並設置 ORACLE_SID以更改實例的名稱。這意味著您需要更改 docker 映像啟動數據庫的方式,如果您希望自動完成此操作。

在數據庫啟動後簡單地通過 docker 傳遞一些環境變數不會改變任何東西。

Oracle 僅提供 12.X 和最新版本(目前為 19.X),我查看了 docker 入口點,得出的結論是:

  1. 對於 12.X -e DB_SID=XXX -e DB_PASSWD=XXX,用於更改 SID 和密碼(來自 paramChk.sh)
  2. 用於最新版本-e ORACLE_SID=XXX -e ORACLE_PWD=XX(來自 setPassword.sh)

引用自:https://dba.stackexchange.com/questions/279676