Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script to create Oracle XE slim images #1534

Closed
wants to merge 35 commits into from

Conversation

marcelo-ochoa
Copy link
Contributor

The idea is to provide an slim version of latest Oracle XE Docker image image only with binaries and the ability to recreate a fresh Oracle instance from golden images in RMAN compressed full backup format.
Once of mainly motivation of smaller image size and faster creation time is to have a Docker image ready to be used in CI/CD pipelines which requires a fresh RDBMS for unit testing, also an slim image will reduce the network traffic between the CI/CD testing server and the private/public registry hosting the slim image.
Comparison results using this new image:
Image size: 30% of the original (8.52Gb -> 2.61Gb)
DB Creation time, 3x faster:

dbca : 8".8s (traditional way)
init-db.tar.gz : 3".5s
rman comp. : 2".59s

Docker image creation process uses multi-stage build and a modified script shared by Gerald Venzl and Jacek Gebal to cleanup non necessary stuff.
To get a golden image file either in format tar, tar.gz an RMAN directory with a setup script could be used in conjunction with oracle:18.4.0 image as:

$ docker run -ti --rm --name freshdb -v /home/setup:/opt/oracle/scripts/setup -v /run/shm:/dev/shm oracle/database:18.4.0-xe

directory /home/setup having:

$ ll /home/setup/
total 20
drwxr-xr-x 2 oracle oinstall  4096 feb 26 16:29 ./
drwxr-xr-x 8 mochoa mochoa   12288 feb 26 16:29 ../
-rwxr-xr-x 1 oracle oinstall   330 feb 26 16:29 zz-backup-full.sh*
$ cat /home/setup/zz-backup-full.sh
#!/bin/bash
su -p oracle -c "rman target /<<EOF
shutdown immediate;
startup mount;
backup as compressed backupset database format '/opt/oracle/scripts/setup/%U';
backup current controlfile format '/opt/oracle/scripts/setup/control.bks';
backup spfile format '/opt/oracle/scripts/setup/spfile.bks';
alter database open;
exit;
EOF"

once the log output shows "DATABASE IS READY TO USE!" setup directory will have a golden image DB as RMAN format which will be passed as setup directory for oracle/database:18.4.0-xe-slim image or packaged as .tar or .tar.gz file format, here the content of full backup directory:

$ ll /home/setup/
total 699436
drwxr-xr-x 2 oracle oinstall      4096 feb 26 16:53 ./
drwxr-xr-x 8 mochoa mochoa       12288 feb 26 16:29 ../
-rw-r----- 1 oracle oinstall 347537408 feb 26 16:52 01uphaqd_1_1
-rw-r----- 1 oracle oinstall 175022080 feb 26 16:52 02upharq_1_1
-rw-r----- 1 oracle oinstall 174718976 feb 26 16:53 03uphasj_1_1
-rw-r----- 1 oracle oinstall  18808832 feb 26 16:53 control.bks
-rw-r----- 1 oracle oinstall    114688 feb 26 16:53 spfile.bks
-rwxr-xr-x 1 oracle oinstall       330 feb 26 16:29 zz-backup-full.sh*

Make sure that /home/setup is owned by Oracle (54321:54321) in order to get RMAN working.
To pack RMAN content as init-db.tar.gz just use:

$ sudo tar cvfz /tmp/init-db.tar.gz control.bks spfile.bks 0*
control.bks
spfile.bks
01uphaqd_1_1
02upharq_1_1
03uphasj_1_1

PD: This PR also included Dockerfile.nfs files as example of how to use Oracle dNFS backup file-system for datafiles.

Marcelo Ochoa and others added 30 commits March 24, 2018 17:23
Co-Authored-By: marcelo-ochoa <marcelo.ochoa@gmail.com>
@Djelibeybi Djelibeybi added the oca-verified The OCA has been signed and processed label Feb 26, 2020
@Djelibeybi
Copy link
Member

I notice you called this PR "Oracle XE slim image" but the actual Dockerfile is for Enterprise 18.3. Can you clarify that?

@marcelo-ochoa
Copy link
Contributor Author

Avi:
[18.3.0|19.3.0]/Dockerfile.nfs are samples for using Oracle dNFS multi-path access to the datafiles.
https://medium.com/oracledevs/oracle-dnfs-with-docker-8a3e35c0b558
Docker slim image is mainly located at 18.4.0 directory which is XE version.
Marcelo.

@Djelibeybi
Copy link
Member

I would suggest splitting this PR into two: one for the Oracle XE slim image and another one for dNFS support for Oracle EE 18.3/19.3.

@Djelibeybi
Copy link
Member

I would also highly recommend creating a branch for each of these and squashing your commits for each feature prior to submitting the separated PRs.

@marcelo-ochoa
Copy link
Contributor Author

Ready, dNFS samples in other PR soon

@Djelibeybi
Copy link
Member

Included in #1666

@Djelibeybi Djelibeybi closed this Jul 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
oca-verified The OCA has been signed and processed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants