简体   繁体   English

与 oracle 数据库连接时出现问题

[英]Problem in connecting with oracle database

I have created one connection in Oracle with name Oracle18c .我在Oracle中创建了一个名为Oracle18c连接 Whenever I am trying to open Tables section then below pop-up is coming.每当我试图打开表格部分时,就会出现下面的弹出窗口。 My Oracle server is running in Docker container.我的Oracle 服务器Docker容器中运行。 I tried to find the solution in the internet but I couldn't find it.我试图在互联网上找到解决方案,但找不到。 I am new to the Oracle database.我是Oracle数据库的新手。 Please help me.请帮我。

在此处输入图像描述

By default, pluggable databases do not open automatically when their container database starts up.默认情况下,可插拔数据库不会在其容器数据库启动时自动打开。 A sysdba user needs to issue the command "alter pluggable database all open" to put them into read-write mode. sysdba 用户需要发出命令“alter pluggable database all open”以使其进入读写模式。 Your error suggests that that hasn't happened here.您的错误表明这里没有发生这种情况。 Check this link for details on how to do that: https://oracle-base.com/articles/12c/multitenant-startup-and-shutdown-cdb-and-pdb-12cr1#:~:text=Pluggable%20Database%20(PDB)%20Automatic%20Startup,-The%2012.1.&text=Prior%20to%2012.1.,or%20all%20of%20the%20PDBs .查看此链接以获取有关如何执行此操作的详细信息: https://oracle-base.com/articles/12c/multitenant-startup-and-shutdown-cdb-and-pdb-12cr1#:~:text=Pluggable%20Database% 20(PDB)%20Automatic%20Startup,-%2012.1.&text=Prior%20to%2012.1.,或%20all%20of%20the%20PDBs

My container was built from scratch Oracle 18 xe source: github .我的容器是从头开始构建的 Oracle 18 xe 来源: github

$ docker ps
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS                 PORTS                                                                          NAMES
13afebdbdbdc        oracle/database:18.4.0-xe   "/bin/sh -c 'exec $O…"   8 hours ago         Up 7 hours (healthy)   



   $ docker exec -it xedb  ps -ef | grep xe
    oracle    1736     1  0 09:42 ?        00:00:01 xe_pmon_XE
    oracle    1738     1  0 09:42 ?        00:00:00 xe_clmn_XE
    ------------------------
    59 lines......
$ docker exec -it --user=oracle xedb sqlplus / as sysdba

SQL*Plus: Release 18.0.0.0.0 - Production on Thu Jun 18 15:45:11 2020
Version 18.4.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.


Connected to:
Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0

SQL> show con_name   -- container name

NAME
------------------------------
CDB$ROOT



 SQL> show pdbs

        CON_ID CON_NAME                       OPEN MODE  RESTRICTED
    ---------- ------------------------------ ---------- ----------
             2 PDB$SEED                       READ ONLY  NO
             3 XEPDB1                         READ WRITE NO
    SQL>

Instance is up and running as well as pluggable database实例已启动并运行以及可插拔数据库

If you're unable to login as sysdba from docker terminal.You can try with bash command如果您无法从 docker 终端以 sysdba 身份登录。您可以尝试使用 bash 命令

$ docker exec -it --user=oracle xedb  bash
[oracle@13afebdbdbdc /]$

If that doesn't work as a Oracle user exclude --user parameter,use bash command如果这不能作为 Oracle 用户排除--user参数,请使用 bash 命令

$ docker exec -it xedb  bash
bash-4.2# su oracle   -- switch oracle user 
[oracle@13afebdbdbdc /]$ echo $ORACLE_HOME   -- verify environment
/opt/oracle/product/18c/dbhomeXE
[oracle@13afebdbdbdc /]$ echo $ORACLE_SID
 XE

If your environment returns nothing you can set environment with the command below如果您的环境没有返回任何内容,您可以使用以下命令设置环境

    [oracle@13afebdbdbdc /]$ . oraenv   -- dot space oraenv
    ORACLE_SID = [XE] ?
    The Oracle base remains unchanged with value /opt/oracle
    [oracle@13afebdbdbdc /]$ rlwrap sqlplus / as sysdba

    SQL*Plus: Release 18.0.0.0.0 - Production on Thu Jun 18 15:58:39 2020
    Version 18.4.0.0.0

    Copyright (c) 1982, 2018, Oracle.  All rights reserved.

    Connected to an idle instance

     SQL> startup    -- start the database
    ORACLE instance started.

     Total System Global Area 1610609288 bytes
     Fixed Size                  8897160 bytes
     Variable Size             620756992 bytes
     Database Buffers          973078528 bytes
     Redo Buffers                7876608 bytes
     Database mounted.
     Database opened.
SQL> select open_mode from v$database;  -- check database status 

OPEN_MODE
--------------------
READ WRITE


SQL> show pdbs     -- check pdb open mode is read write

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 XEPDB1                         READ WRITE NO

If you happen to see Pluggable database in mount state如果您碰巧在安装 state 中看到 Pluggable 数据库

SQL> show pdbs      -- pdb xepdb1 is in mount state 

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 XEPDB1                         MOUNTED
SQL> alter pluggable database xepdb1 open;   -- open pdb 


Pluggable database altered.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 XEPDB1                         READ WRITE NO

SQL> alter pluggable database xepdb1 save state ; --------next restart pdb will be opened automagically 


Pluggable database altered.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM