无法在Red Hat

时间:2015-12-27 21:08:51

标签: oracle docker

我可以在Mac OS上启动Oracle Docker容器,但我无法在Red Hat上启动它。当我在Mac上运行以下内容时......

run -it --name oracleofac -p 49160:22 -p 49161:1521 -p 49162:8080 pdevoasas30l:5000/oracleofac /bin/bash

容器启动。我可以通过输入...来启动oracle。

service oracle-xe start

我看到以下消息

Starting Oracle Net Listener.
Starting Oracle Database 11g Express Edition instance.

然后我就可以连接到Oracle和查询表了。一切都很棒。没问题。

但是,当我尝试使用此命令在Red Hat上加载相同的Docker镜像时......

sudo docker run -it --name oracleofac -p 49160:22 -p 49161:1521 -p 49162:8080 localhost:5000/oracleofac /bin/bash

容器启动。但是当我尝试使用这个命令启动oracle时......

service oracle-xe start

我得到以下内容......

Starting Oracle Net Listener.
Starting Oracle Database 11g Express Edition instance.
Failed to start Oracle Net Listener using /u01/app/oracle/product/11.2.0/xe/bin/tnslsnr and Oracle Express Database using /u01/app/oracle/product/11.2.0/xe/bin/sqlplus.

当我输入此内容时......

lsnrctl status

我看到了......

LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 27-DEC-2015 20:33:59

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=0.0.0.0)(PORT=1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused

当我输入这个......

lsnrctl start

我得到以下内容......

LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 27-DEC-2015 20:35:02

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

Starting /u01/app/oracle/product/11.2.0/xe/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.2.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora
Log messages written to /u01/app/oracle/product/11.2.0/xe/log/diag/tnslsnr/c98964cdfa69/listener/alert/log.xml
Error listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC_FOR_XE)))
TNS-12555: TNS:permission denied
 TNS-12560: TNS:protocol adapter error
  TNS-00525: Insufficient privilege for operation
   Linux Error: 1: Operation not permitted

Listener failed to start. See the error message(s) above...

这是docker文件......

FROM wnameless/oracle-xe-11g

COPY initOFAC.sql /app/initOFAC.sql

ENV ORACLE_HOME /u01/app/oracle/product/11.2.0/xe
ENV ORACLE_SID XE

RUN sed -i -E "s/HOST = [^)]+/HOST = 0.0.0.0/g" /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora && service oracle-xe start && su -m oracle -c "$ORACLE_HOME/bin/sqlplus '/ as sysdba' @/app/initOFAC.sql"

CMD service oracle-xe start; \
    /usr/sbin/sshd -D

1 个答案:

答案 0 :(得分:4)

一位同事能够帮我解决这个问题。如果你运行

stat /

在Mac上的docker容器中,您将看到此

  File: '/'
  Size: 4096      Blocks: 8          IO Block: 4096  directory
Device: 20h/32d Inode: 2          Links: 46
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)  Gid: (    0/    root)
Access: 2015-12-28 19:43:47.111212548 +0000
Modify: 2015-12-28 19:43:47.281211325 +0000
Change: 2015-12-28 19:43:47.281211325 +0000
Birth: -

但是如果你在Red Hat上运行它,你会看到

  File: '/'
  Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: fd03h/64771d    Inode: 131073      Links: 23
Access: (0750/drwxr-x---)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2015-12-27 22:03:18.043696658 +0000
Modify: 2015-12-27 20:32:44.659975560 +0000
Change: 2015-12-27 20:32:44.659975560 +0000
Birth: -

请注意,Mac上的访问权限为755,Red Hat上的访问权限为750。为了解决这个问题,我添加了

usermod -G root oracle

到Dockerfile。我的Dockerfile的最终版本现在是

FROM wnameless/oracle-xe-11g

COPY initOFAC.sql /app/initOFAC.sql

ENV ORACLE_HOME /u01/app/oracle/product/11.2.0/xe
ENV ORACLE_SID XE

RUN sed -i -E "s/HOST = [^)]+/HOST = 0.0.0.0/g" /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora && service oracle-xe start && su -m oracle -c "$ORACLE_HOME/bin/sqlplus '/ as sysdba' @/app/initOFAC.sql"

CMD usermod -G root oracle; service oracle-xe start; /usr/sbin/sshd -d

现在这个docker镜像可以在Mac和Red Hat环境中运行。