我正在关注这些instructions。
我创建了一个这样的docker容器:
docker run --name oracle \
-p 1521:1521 \
-e ORACLE_SID=ORASID \
-e ORACLE_PDB=ORAPDB \
-e ORACLE_PWD=F1f@f23_ \
-v /mnt_point/oradata:/home/oracle/oradata \
oracle/database:12.2.0.1-ee
输出结果为:
#########################
DATABASE IS READY TO USE!
#########################
The following output is now a tail of the alert.log:
Completed: alter pluggable database ORAPDB open
2017-08-07T19:16:31.190780+00:00
ORAPDB(3):CREATE SMALLFILE TABLESPACE "USERS" LOGGING DATAFILE '/opt/oracle/oradata/ORASID/ORAPDB/users01.dbf' SIZE 5M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO
ORAPDB(3):Completed: CREATE SMALLFILE TABLESPACE "USERS" LOGGING DATAFILE '/opt/oracle/oradata/ORASID/ORAPDB/users01.dbf' SIZE 5M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO
ORAPDB(3):ALTER DATABASE DEFAULT TABLESPACE "USERS"
ORAPDB(3):Completed: ALTER DATABASE DEFAULT TABLESPACE "USERS"
2017-08-07T19:16:32.867558+00:00
ALTER SYSTEM SET control_files='/opt/oracle/oradata/ORASID/control01.ctl' SCOPE=SPFILE;
ALTER PLUGGABLE DATABASE ORAPDB SAVE STATE
Completed: ALTER PLUGGABLE DATABASE ORAPDB SAVE STATE
我通过ctrl + c杀了它。然后我跑:
docker start oracle
docker logs -f oracle
#########################
DATABASE IS READY TO USE!
#########################
The following output is now a tail of the alert.log:
ORAPDB(3):Undo initialization finished serial:0 start:508498668 end:508498772 diff:104 ms (0.1 seconds)
ORAPDB(3):Database Characterset for ORAPDB is AL32UTF8
ORAPDB(3):Opatch validation is skipped for PDB ORAPDB (con_id=0)
2017-08-07T19:25:39.799508+00:00
ORAPDB(3):Opening pdb with no Resource Manager plan active
Pluggable database ORAPDB opened read write
Starting background process CJQ0
Completed: ALTER DATABASE OPEN
2017-08-07T19:25:40.536753+00:00
CJQ0 started with pid=38, OS id=239
2017-08-07T19:25:42.538433+00:00
Shared IO Pool defaulting to 64MB. Trying to get it from Buffer Cache for process 77.
===========================================================
Dumping current patch information
===========================================================
No patches have been applied
===========================================================
然后我尝试连接:
docker exec -ti oracle sqlplus pdbadmin@ORAPDB
结果是:
ORA-12154: TNS:could not resolve the connect identifier specified
然后它要求我输入用户名。无论哪个用户SYS,SYSTEM或PDBADMIN,我都无法连接。我已经多次重新输入密码(F1f @ f23_),以确保它不是拼写错误。对此有任何想法将不胜感激。
答案 0 :(得分:1)
我也遇到过这些图片。首先必须先打开可插拔数据库,然后才能连接它。
我是这样做的:
docker exec -ti oracle sqlplus / as sysdba
alter pluggable database pdb1 open;
答案 1 :(得分:0)
启动容器并创建数据库后,您可以通过以下方法之一连接到任何其他数据库:
1) sqlplus sys/<your password>@//localhost:1521/<your SID> as sysdba
2) sqlplus system/<your password>@//localhost:1521/<your SID>
3) sqlplus pdbadmin/<your password>@//localhost:1521/<Your PDB name>
在Docker容器中运行SQL * Plus
您可以使用与启动数据库相同的Docker镜像来运行sqlplus来连接它,例如:
docker run --rm -ti oracle/database:12.2.0.1-ee sqlplus pdbadmin/<yourpassword>@//<db-container-ip>:1521/ORCLPDB1
另一种选择是使用docker exec并在已经运行数据库的同一容器中运行sqlplus:
docker exec -ti <container name> sqlplus pdbadmin@ORCLPDB1
要运行Oracle Database Docker映像,请使用docker run命令,如下所示:
docker run --name <container name> \
-p <host port>:1521 -p <host port>:5500 \
-e ORACLE_SID=<your SID> \
-e ORACLE_PDB=<your PDB name> \
-e ORACLE_PWD=<your database passwords> \
-e ORACLE_CHARACTERSET=<your character set> \
-v [<host mount point>:]/opt/oracle/oradata \
oracle/database:12.2.0.1-ee
Parameters:
--name: The name of the container (default: auto generated)
-p: The port mapping of the host port to the container port.
Two ports are exposed: 1521 (Oracle Listener), 5500 (OEM Express)
-e ORACLE_SID: The Oracle Database SID that should be used (default: ORCLCDB)
-e ORACLE_PDB: The Oracle Database PDB name that should be used (default: ORCLPDB1)
-e ORACLE_PWD: The Oracle Database SYS, SYSTEM and PDB_ADMIN password (default: auto generated)
-e ORACLE_CHARACTERSET:
The character set to use when creating the database (default: AL32UTF8)
-v /opt/oracle/oradata
The data volume to use for the database.
Has to be owned by the Unix user "oracle" or set appropriately.
If omitted the database will not be persisted over container recreation.
-v /opt/oracle/scripts/startup | /docker-entrypoint-initdb.d/startup
Optional: A volume with custom scripts to be run after database startup.
For further details see the "Running scripts after setup and on startup" section below.
-v /opt/oracle/scripts/setup | /docker-entrypoint-initdb.d/setup
Optional: A volume with custom scripts to be run after database setup.
For further details see the "Running scripts after setup and on startup" section below.
有用:https://github.com/oracle/docker-images/tree/master/OracleDatabase
答案 2 :(得分:0)
Yes, I got the same error after setting up Oracle database in docker too.
So first check the instance is running (and look for the ORACLE_SID):
The Oracle SID is ORCLCDB.
If you don't have the environment set for ORACLE_SID, you get:
Connection failed.
But after you set your ORACLE_SID:
And now you no longer get the connection failure error, but a different SYSDBA instead.
Just add "/ as sysdba" to your entire sqlplus command and you are good to go.
答案 3 :(得分:0)
此说明对我有用:
启动SQL * Plus并连接到数据库
https://docs.oracle.com/database/121/ADMQS/GUID-DE8A79BD-FAE4-4364-98FF-D2BD992A06E7.htm#ADMQS0361
基本上进入oracle容器,然后输入sqlplus。在用户名提示符下键入SYS AS SYSDBA,然后输入密码。之后,创建用户和表。