1

I am trying to get an Oracle XE docker image to run on my Redhat 7 machine but Oracle fails during startup and I can see in its alert log the following:

Exception [type: SIGSEGV, Address not mapped to object] [ADDR:0x7F80083C5FF8] [PC:0x20CB441, ksmem_free()+31] [flags: 0x0, count: 1]

I can run the image fine elsewhere but it fails on the Redhat server.

Initially I thought it may have been due to trying to run an Ubuntu based image on Redhat but I have tried with different images based on Ubuntu 14, Ubuntu 16, Centos 6, and Centos 7 and all have the same problem.

This is the output of 'docker version':

Client:
 Version:      1.10.3
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   20f81dd
 Built:        Thu Mar 10 21:49:11 2016
 OS/Arch:      darwin/amd64

Server:
 Version:      1.10.3
 API version:  1.22
 Go version:   go1.6.2
 Git commit:   5206701-unsupported
 Built:        Mon Aug 29 14:00:01 2016
 OS/Arch:      linux/amd64

I don't really know where to go next from here. Unfortunately I have no choice but to run RHEL7 on my server so that is not an option.

If anyone has any ideas I would be grateful.

2 Answers2

1

I managed to get things to work by uninstalling the Redhat provided docker (which was version 1.10) and installing the latest 1.12 RPMs provided by Docker themselves.

I don't know if the fix is due to running a later Docker or because Redhat has made some changes to the Docker binaries that they supply.

1

I have not done this with RHEL but I was able to do this using CentOS 7 minimal installed directly onto a host (close enough). The host was then set up for ssh, update & upgrade, vsftp ftp/tls, selinux, docker etc. After I had a decent baseline of things I knew I needed the host to support I made a base image using mkimage-yum.sh (https://github.com/moby/moby/blob/master/contrib/mkimage-yum.sh). This is what produced the image referenced in the Dockerfile below (centos-base-image:7.3.1611).

uname -a
Linux CentOS7 3.10.0-514.16.1.el7.x86_64 #1 SMP Wed Apr 12 15:04:24 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

docker version
Client:
 Version:         1.12.6
 API version:     1.24
 Package version: docker-common-1.12.6-16.el7.centos.x86_64
 Go version:      go1.7.4
 Git commit:      3a094bd/1.12.6
 Built:           Fri Apr 14 13:46:13 2017
 OS/Arch:         linux/amd64

Server:
 Version:         1.12.6
 API version:     1.24
 Pack age version: docker-common-1.12.6-16.el7.centos.x86_64
 Go version:      go1.7.4
 Git commit:      3a094bd/1.12.6
 Built:           Fri Apr 14 13:46:13 2017
 OS/Arch:         linux/amd64

From this point I created a Dockerfile and an assets directory which are adjacent on the file system. In the assets dir I unzipped a copy of Oracle Database Express Edition 11g Release 2 for Linux x64 and created a setOracleEvn.sh file which will set a few environment variables. Now that the contents of the xe tar are uncompressed, update the Disk1/response/xe.rsp file to configure the default ports and password.

At this point you should be able to create a Dockerfile which ADDs the asserts directory to the container and invokes rpm and installs XE. I used the extracted Disk1/response/xe.rsp file to configure the default ports and password as this was the simplest solution (avoiding sed commands). If you wanted a pure scripted installation you could add whatever zip software you wanted to the yum install phase and perform the operations.

I ran into a few hurdles:

  1. Docker's /dev/shm default of 64MB is to small to run the oracle configuration.
  2. An issue with selinux policy stopping the /etc/init.d/oracle-xe configure < response/xe.rsp from executing successfully.
  3. RPM -h (hash) option breaking the configure process.
  4. Container tends to stop after everything in CMD is executed.

The following is the directory structure and file information:

ls -la from parent directory

drwxr-xr--. 3 user group ... assets
-rwxr-xr--. 1 xxx xxx ...  1 11:22 Dockerfile

ls -la assets/

-rwxr-xr--. 1 xxx xxx ... exportOracleEnv.sh
drwxr-xr--. 3 xxx xxx ... oracle-xe-11.2.0-1.0x86_64

ls -la assets/oracle-xe-11.2.0-1.0x86_64

drwxr-xr--. 4 xxx xxx ... Disk1

ls -la assets/oracle-xe-11.2.0-1.0x86_64/Disk1

-rwxr-xr--. 1 xxx xxx ... oracle-xe-11.2.0-1.0.x86_64.rpm
drwxr-xr--. 2 xxx xxx ... response
drwxr-xr--. 2 xxx xxx ... upgrade

vi response/xe.rsp - ensure its void of anything but the http port, tns listener port, password and y/n for start on boot (things break if comments are left in the file).

8080
1521
welcome1
welcome1
y

vi assets/exportOracleEnv.sh - sets oracle vars for every bash

#!/bin/sh

echo 'export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe' >> ~/.bashrc
echo 'export PATH=$ORACLE_HOME/bin:$PATH' >> ~/.bashrc
echo 'export ORACLE_SID=XE' >> ~/.bashrc
echo 'export LISTENERS_ORA=/u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora' >> ~/.bashrc

The Dockerfile is a little busy but this is how I was able to get things working. I have been using docker now for a few days and linux for all of two weeks so forgive me for not having the most elegant solution to this.

FROM centos-base-image:7.3.1611

#do not use $ in ENV: https://github.com/moby/moby/issues/25099
ENV _rpmLocation /assets/oracle-xe-11.2.0-1.0x86_64/Disk1

#installing epel because its required to resolve net-tools, your milage may very depending on what image your starting with.
RUN yum -y install epel-release libaio bc flex && yum -y install net-tools kernel-devel

#oracle uncompressed zip file provided in assets directory, also provides preconfigured response file
ADD assets /assets

WORKDIR ${_rpmLocation}

# echo $ORACLE_HOME just because I like to know the process worked as I expect. The environment variables must be in place before running configure.
RUN rpm -i oracle-xe-11.2.0-1.0.x86_64.rpm && /assets/exportOracleEnv.sh && echo $ORACLE_HOME

# execute oracle-xe configure with response file
RUN  /etc/init.d/oracle-xe configure < response/xe.rsp

WORKDIR /

#clean up temp files, create ssh key and ensure known root password.
#Finally set the final hostname to listen to all interfaces in tnsnames/listeners.ora otherwise the files will have the incorrect host name (it changes with every layer).
RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' && systemctl enable sshd && echo "root:admin" | chpasswd && rm -rf ${_ASSETS} && \
    sed -i -E "s/HOST = [^)]+/HOST = 0.0.0.0/g" /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora && \
    sed -i -E "s/HOST = [^)]+/HOST = 0.0.0.0/g" /u01/app/oracle/product/11.2.0/xe/network/admin/tnsnames.ora

#start sshd first (allows immediate connections via ssh) then db. leave tail running in forground
CMD /sbin/sshd && /etc/init.d/oracle-xe start && tail -f /dev/null

Make sure when you build you specify --shm-size (running from the Dockerfile dir)

docker build --shm-size=2g -t centos-oracle:7.3.1611 .

And again (--shm-size) when you run the container, ensure -dti options to keep the CentOS 7 container running after the CMD executes

docker run --shm-size=2g --name oracle-db -d -t -i -p 5022:22 -p 5080:8080 -p 1521:1521 centos-oracle:7.3.1611

Finally you should be able to connect via ssh make sure ssh has started, you can use docker logs -f oracle-db to watch for the ssh output about the ecdsa keys missing. Note: as your building over and over again fixing things, after you accept a ssh cert from your client and you issue a new docker build command you will need to remove the old cert rm: remove regular file ‘/root/.ssh/known_hosts’? yes. The password is set in the Dockerfile to admin

ssh -p 5022 root@127.0.0.1
...
root@127.0.0.1's password: 
Authenticated to 127.0.0.1 ([127.0.0.1]:5022).

Once ssh is established you can now execute sqlplus, login as system:welcome1

[root@390856ad3b30 ~]# sqlplus

SQL*Plus: Release 11.2.0.2.0 Production on Mon May 1 17:22:55 2017

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

Enter user-name: system
Enter password: 

Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE    11.2.0.2.0      Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production

If anyone can come up with a solution to the selinux policy stopping the configuration process with oracle-xe it would be awesome to finally have that resolved.

Community
  • 1
  • 1
steven87vt
  • 500
  • 7
  • 6