wnameless / docker-oracle-xe-11g

Dockerfile of Oracle Database Express Edition 11g Release 2
Apache License 2.0
1.35k stars 800 forks source link

Persisting Data with Volumes #119

Open mjdavies opened 5 years ago

mjdavies commented 5 years ago

HI Everyone

I'm on mac, docker versions are

Server: Docker Engine - Community Engine: Version: 18.09.2

Client: Docker Engine - Community Version: 18.09.2

I've tried what seems to be every conceivable way of persisting data, using -v, or --mount, but nothing seems to be working. I think I must be getting the path to where the data exists inside the container wrong or something.

Is persisting data possible with my versions above and this image? I've got a saved image prior to the image being pulled from docker hub, which was very sad btw, not your fault I know. :-(

Thanks for any tips or suggestions.

mjdavies commented 5 years ago

Bit more information

Whenever I try to use --mount, when I exec into the container I can't access the database, constantly says it's shutting down or starting up

ORA-01033: ORACLE initialization or shutdown in progress

Here's the alert log

Enter user-name: root@d1956113a860:/# cat /u01/app/oracle/diag/rdbms/xe/XE/trace/alert_XE.log /u01/app/oracle/diag/rdbms/xe/XE/trace/alert_XE.log: line 1: Tue: command not found /u01/app/oracle/diag/rdbms/xe/XE/trace/alert_XE.log: line 2: syntax error near unexpected token (' /u01/app/oracle/diag/rdbms/xe/XE/trace/alert_XE.log: line 2:Starting ORACLE instance (normal)'

Whenever I try to use the -v option, it will work first time, so I import some data, stop and remove the container, run it again mapping to the volume, and then I see similar errors, and the database always either shutting down or starting up making it unusable.

mjdavies commented 5 years ago

I've now tried this within a docker-compose context

version: '2'
services:
  oracle-db:
    build:
      context: .
      dockerfile: oracle.Dockerfile
    container_name: oracle-db
    environment:
      - ORACLE_ALLOW_REMOTE=true
    volumes:
      - oracle:/u01/app/oracle/oradata/XE/
    ports:
      - 49161:1521
volumes:
  oracle:

docker-compose up works beautifully, and I docker exec into the container, and import some data with imp.

Then I run docker-compose down, and docker-compose up again, and this error pops up in the output from the compose command

oracle-db    | Starting Oracle Net Listener.
oracle-db    | Starting Oracle Database 11g Express Edition instance.
oracle-db    |
oracle-db    | ERROR:
oracle-db    | ORA-01033: ORACLE initialization or shutdown in progress
oracle-db    | Process ID: 0
oracle-db    | Session ID: 0 Serial number: 0
oracle-db    |
oracle-db    |
oracle-db    | SP2-0306: Invalid option.
oracle-db    | Usage: CONN[ECT] [{logon|/|proxy} [AS {SYSDBA|SYSOPER|SYSASM}] [edition=value]]
oracle-db    | where <logon> ::= <username>[/<password>][@<connect_identifier>]
oracle-db    |       <proxy> ::= <proxyuser>[<username>][/<password>][@<connect_identifier>]
oracle-db    | /usr/sbin/startup.sh: ignoring /docker-entrypoint-initdb.d/*
bjpirt commented 5 years ago

I've run into the same problem - adding a mounted volume over the oradata directory works first time but then after a restart Oracle won't start properly - any ideas @wnameless ?

NicolasCailotto commented 5 years ago

Hi everyone i found a fix for this problem. Instead of setting the volume path to /u01/app/oracle/XE/oradata set it to /u01/app/oracle and will work. That solutions works for me.

lda2000 commented 4 years ago

Hi everyone i found a fix for this problem. Instead of setting the volume path to /u01/app/oracle/XE/oradata set it to /u01/app/oracle and will work. That solutions works for me.

It works for me as well. Thanks!!

koryovip commented 4 years ago

Hi everyone i found a fix for this problem. Instead of setting the volume path to /u01/app/oracle/XE/oradata set it to /u01/app/oracle and will work. That solutions works for me.

It works for me as well. Thanks!!

VanadiumJade commented 3 years ago

how did you get this to work exactly? Im struggling. would rather data not stored in the container.

lda2000 commented 3 years ago

Hi, This is the command I wrote:

docker run -d -p 1521:1521 -e ORACLE_ALLOW_REMOTE=true -v oracle:/u01/app/oracle wnameless/oracle-xe-11g-r2

kennychennetman commented 2 months ago

Hi, is there anyone fix this issue? I'd just like to share a work around using k8s environment:

  1. create a pvc and define a mount point for a temporary folder (e.g. /tmp/app) in the yaml at the first running
  2. apply the yaml and finish your setups, for example creating DB, tables and account, etc.
  3. execute inside the pod to copy the entire directory of /u01/app/oracle to /tmp/app/oracle with archive mode: cp -a /u01/app/oracle /tmp/app
  4. delete the pod using kubectl delete -f file.yaml
  5. modify the yaml to change the mount point back to /u01/app, and apply it again

okay, now will be the tricky part:

  1. check the logs of the server pod to find the line 'Starting Oracle Net Listener' straight after a Stopping, ignore all the ERRORs
  2. if not found, then delete the pod directly using 'kubectl delete pod' command (not via -f file.yaml), and check the log again. (note: the pod name may varied if the pod is handled by a deployment)
    • repeat these two steps till to find the Starting line exists

I know this is not a proper way to solve this issue, just a work around as I mentioned. I really keen to hear a final solution from you guys!