ORA-01017: invalid username/password error with Oracle Express: 21.3.0-xe container

huangapple go评论47阅读模式
英文:

ORA-01017: invalid username/password error with oracle express:21.3.0-xe container

问题

我使用搭载苹果M1芯片的MAC电脑,使用[Colima][1]来在M1芯片上运行Oracle容器。

我有一个需求,需要在Oracle容器上运行集成测试用例。我正在尝试使用在docker-compose.yaml文件中定义的服务来创建Oracle容器。

我能够成功启动容器,但无法从我机器上安装的SQL Developer工具登录。

我遇到了身份验证错误:

状态:失败 - 测试失败:ORA-01017:用户名/密码无效;拒绝登录。

这个问题中令人惊讶的部分是,如果我明确使用以下docker run命令启动容器,那么使用SQL Developer工具可以正常登录数据库,但是在使用compose文件和docker compose up命令运行容器时失败。

以下是我用来启动容器并成功登录到数据库的docker命令,使用用户名"SYS"和密码"secret"。

docker run --name devdb -p 1521:1521 -p 5500:5500 -e ORACLE_PWD=secret container-registry.oracle.com/database/express:21.3.0-xe

以下是导致数据库登录问题的docker-compose.yaml文件。

version: '3'
services:
  oracle:
    image: container-registry.oracle.com/database/express:21.3.0-xe
    hostname: oracle
    container_name: oracle
    ports:
      - 1521:1521
      - 5500:5500
    environment:
      - ORACLE_PWD:secret
    volumes:
      - ./scripts/startup:/opt/oracle/scripts/startup

以下是Oracle服务器启动日志,您可以看到数据库服务器成功启动且没有错误:

[+] Running 1/1
 ⠿ Container oracle  Created                                                                                                                           0.1s
Attaching to oracle
oracle  | Starting Oracle Net Listener.
oracle  | Oracle Net Listener started.
oracle  | Starting Oracle Database instance XE.
oracle  | Oracle Database instance XE started.
...

我尝试去掉了hostname、containerName和自定义启动脚本配置,但没有帮助。我还尝试了使用SYS用户名和默认密码"CHANGE_ON_INSTALL",但不起作用。

是什么导致了身份验证失败?

在使用docker-compose命令时,是否需要明确提供tnsnames.ora或其他配置?

英文:

I am using MAC book with apple M1 chip, and I am using [Colima][1] to run the oracle container over M1 chip.

I have a requirement to run integration test cases over the oracle container. And I am trying to create oracle container using service defined in docker-compose.yaml file.

I am able to start the container successfully but I am not able to login from the SQL Developer tool installed on my machine.

I am getting authentication error:

> Status : Failure -Test failed: ORA-01017: invalid username/password; logon denied.

[![enter image description here][2]][2]

The surprising part in this problem is, if I explicitly bring up the container using following docker run command then, the DB login works properly with the SQL Developer tool, but it fails while running the container using compose file and docker compose up command.

Below the docker command which I am using to bring up the container and I am able to login to the DB using username "SYS" and password "secret".

docker run --name devdb -p 1521:1521 -p 5500:5500 -e ORACLE_PWD=secret container-registry.oracle.com/database/express:21.3.0-xe

And, below the docker-compose.yaml file which is causing database login problem.

version: '3'
services:
  oracle:
    image: container-registry.oracle.com/database/express:21.3.0-xe
    hostname: oracle
    container_name: oracle
    ports:
      - 1521:1521
      - 5500:5500
    environment:
      - ORACLE_PWD:secret
    volumes:
      - ./scripts/startup:/opt/oracle/scripts/startup

Below are the oracle server start up logs, where you can see the database server started successfully without any errors:

[+] Running 1/1
 ⠿ Container oracle  Created                                                                                                                           0.1s
Attaching to oracle
oracle  | Starting Oracle Net Listener.
oracle  | Oracle Net Listener started.
oracle  | Starting Oracle Database instance XE.
oracle  | Oracle Database instance XE started.
oracle  |
oracle  | The Oracle base remains unchanged with value /opt/oracle
oracle  | #########################
oracle  | DATABASE IS READY TO USE!
oracle  | #########################
oracle  |
oracle  | Executing user defined scripts
oracle  | /opt/oracle/runUserScripts.sh: running /opt/oracle/scripts/startup/ddl.sql
oracle  |
oracle  | Table created.
oracle  |
oracle  |
oracle  | 0 rows deleted.
oracle  |
oracle  |
oracle  | 1 row created.
oracle  |
oracle  | DONE: Executing user defined scripts
oracle  |
oracle  | The following output is now a tail of the alert.log:
oracle  | Starting background process CJQ0
oracle  | 2023-04-03T19:29:19.672431+00:00
oracle  | CJQ0 started with pid=63, OS id=424
oracle  | Completed: ALTER DATABASE OPEN
oracle  | 2023-04-03T19:29:21.170374+00:00
oracle  | ===========================================================
oracle  | Dumping current patch information
oracle  | ===========================================================
oracle  | No patches have been applied
oracle  | ===========================================================
oracle  | 2023-04-03T19:29:36.087762+00:00
oracle  | System State dumped to trace file /opt/oracle/diag/rdbms/xe/XE/trace/XE_cjq0_424.trc
oracle  | 2023-04-03T19:30:03.688697+00:00
oracle  | XEPDB1(3):TABLE AUDSYS.AUD$UNIFIED: ADDED INTERVAL PARTITION SYS_P360 (3199) VALUES LESS THAN (TIMESTAMP' 2023-04-04 00:00:00')

I tried removing the hostname, containerName and custom start up script configuration, but it did not help. I also tried the default password "CHANGE_ON_INSTALL" with SYS username but it did not work.

What is causing the authentication failure?

Do I need to explicitly provide tnsnames.ora or any other configuration while using docker-compose commands?

答案1

得分: 0

由于我能够在使用 docker run 命令运行容器时登录到数据库,而无需提供 SID 名称。因此,我假设在使用 docker-compose 时也无需提供 SID 名称。

但是,这正是登录问题的主要根本原因。我在 docker-compose 文件中提供了如下所示的 SID 名称,现在我能够使用 用户名: SYS密码: secretSID: XE 登录到数据库。

请参考以下 docker compose 文件。

英文:

As I was able to login to the database while running the container with docker run command, without providing the SID name. So, I assumed, there is no need to provide SID name with docker-compose as well.

But, that was the main root cause behind the login issue. I provided the SID name in docker-compose file as mentioned below, and I am able to login the the database using username : SYS, password : secret and SID : XE.

Please refer below docker compose file for your reference.

oracle:
    image: container-registry.oracle.com/database/express:21.3.0-xe
    hostname: oracle
    container_name: oracle
    environment:
      - ORACLE_SID=XE
      - ORACLE_PWD=secret
    ports:
      - "1521:1521"
      - "5500:5500"
    volumes:
      - ./scripts/startup:/opt/oracle/scripts/startup

huangapple
  • 本文由 发表于 2023年4月6日 19:56:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/75949242.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定