简体   繁体   中英

Problem in connecting with oracle database

I have created one connection in Oracle with name Oracle18c . Whenever I am trying to open Tables section then below pop-up is coming. My Oracle server is running in Docker container. I tried to find the solution in the internet but I couldn't find it. I am new to the Oracle database. 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. 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 .

My container was built from scratch Oracle 18 xe source: 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 exec -it --user=oracle xedb  bash
[oracle@13afebdbdbdc /]$

If that doesn't work as a Oracle user exclude --user parameter,use bash command

$ 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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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