Automate to avoid database cloning disasters.

“Accidentally destroyed production database on first day of a job”

Wow, that headline grabbed my attention.

Earlier this week you may have seen an article reported by The Register about a post in  reddit from a junior software developer going by the name of  “cscareerthrowaway567”, who on his/her first day destroyed a Production database and lost their job.

I was basically given a document detailing how to setup my local development environment. Which involves run a small script to create my own personal DB instance from some test data. After running the command i was supposed to copy the database url/password/username outputted by the command and configure my dev environment to point to that database. Unfortunately instead of copying the values outputted by the tool, i instead for whatever reason used the values the document had.

Unfortunately apparently those values were actually for the production database (why they are documented in the dev setup guide i have no idea). Then from my understanding that the tests add fake data, and clear existing data between test runs which basically cleared all the data from the production database. Honestly i had no idea what i did and it wasn’t about 30 or so minutes after did someone actually figure out/realize what i did.

Now, we can not be sure if the story by “cscareerthrowaway567” is true or not but it does provide an great example of the potential dangers of manual database cloning.

The story raises many issues around process, security, change management, training and not least why someone thought it was a good idea to include Production account details in a database cloning document ?

However, this could have easily been avoided through the use of Automation or a CDM (Copy Data Management) tools e.g. Catalogic, Actifio, Delphix etc..

Many modern All-Flash Arrays (AFA) provide powerful REST API’s which can be called from various programming and scripting languages e.g. Python, Java, Perl, PowerShell etc… to create custom solutions.

AFA Storage API’s can also be consumed by DevOPS Automation and Provisioning software e.g. Ansible, Chef, Puppet etc.. to provide full-stack or end-to-end Automation of Database Cloning, improving security and also removing the chance of human error.

Check out the Pure Storage Developer Community area for code examples.

Oracle 12c Online Database Move Datafile

After watching an Oracle R12c new features presentation at a recent conference somebody asked me what was my favourite Oracle R12c database feature, for me it was easy has to be ‘ALTER DATABASE MOVE DATAFILE’

Prior to Oracle 12c moving non-ASM data files required taking data files ‘offline’ and negotiating an outage with the business, with Oracle 12c this is no longer the case.

Storage Maintenance

You can use the ALTER DATABASE MOVE DATAFILE to move a data file to different location, disk or storage system. This provides a simple Online method of migrating to a new storage platform.

Online_Data_Move

The Oracle ALTER DATABASE MOVE DATAFILE does all the hard work for you including renaming or relocating the data file at operating system level and changing pointers in the Control Files.

Oracle also provide a way of monitor progress by using the V$SESSION_LONGOPS view, the reported bytes done will increment until the move is completed.

SQL> select file_name, tablespace_name from dba_data_files;

TABLESPACE_NAME      FILE_NAME
——————– ———————————————————–

TEST                /u01/app/oracle/oradata/PSTG/datafile/test.dbf

SQL> ALTER DATABASE MOVE DATAFILE ‘/u01/app/oracle/oradata/PSTG/datafile/test.dbf’ TO ‘/u01/app/oracle/oradata/PSTG/datafile/tester.dbf’;

SQL> select to_char(start_time,’DD-MON-YY hh24:mi:ss’),  timestamp, time_remaining, elapsed_seconds, message from V$SESSION_LONGOPS;

02-JUN-17 10:51:44   0 158
Online data file move: data file 4: 10737418240 out of 10737418240 bytes done

SQL>  select tablespace_name, file_name from dba_data_files;

TABLESPACE_NAME      FILE_NAME
——————– ———————————————————–

TEST               /u01/app/oracle/oradata/PSTG/datafile/tester.dbf

Please note before you begin make sure you have enough space on the source and target storage platforms as Oracle will allocate the required storage space on the target system and will not free any space up on the source until the move is complete.

If you specify the ‘KEEP’ parameter Oracle will copy the data file to the new location and retain the old datafile in the original location, it will be no longer reference in the control files and can be removed when no longer required.

SQL>  select tablespace_name, file_name from dba_data_files;

TABLESPACE_NAME      FILE_NAME
——————– ———————————————————–

TEST     /u01/app/oracle/oradata/PSTG/datafile/tester.dbf

SQL> ALTER DATABASE MOVE DATAFILE ‘/u01/app/oracle/oradata/PSTG/datafile/tester.dbf’ TO ‘/u01/app/oracle/oradata/PSTG/datafile/test.dbf’ KEEP;

Database altered.

SQL> select tablespace_name, file_name from dba_data_files;

TABLESPACE_NAME      FILE_NAME
——————– ———————————————————–

TEST     /u01/app/oracle/oradata/PSTG/datafile/test.dbf

[oracle@ol72-oraclepub datafile]$ ls -lh

-rw-r—–. 1 oracle oinstall  11G Jun  2 11:49 test.dbf
-rw-r—–. 1 oracle oinstall  11G Jun  2 11:49 tester.dbf

Please consult the Oracle R12.2 Docs for further details.

Code examples:

Rename:

ALTER DATABASE MOVE DATAFILE ‘/u01/app/oracle/oradata/PSTG/datafile/test.dbf’ TO ‘/u01/app/oracle/oradata/PSTG/datafile/tester.dbf’;

Relocate:

ALTER DATABASE MOVE DATAFILE ‘/u01/app/oracle/oradata/PSTG/datafile/test.dbf’ TO ‘/u02/app/oracle/oradata/PSTG/datafile/test.dbf’;

Copy:

ALTER DATABASE MOVE DATAFILE ‘/u01/app/oracle/oradata/PSTG/datafile/test.dbf’ TO ‘/u01/app/oracle/oradata/PSTG/datafile/test.dbf’ KEEP;

Move into ASM:

ALTER DATABASE MOVE DATAFILE ‘/u01/app/oracle/oradata/PSTG/datafile/test.dbf’ TO ‘+DATA/data/datafile/test.dbf’;

REUSE: overwrite data file with the same name
KEEP: copies the data file to a new location and retains original data file in old location

Oracle 12c on Docker

Getting the Image

Great news, during DockerCon 2017 Oracle announced support for Oracle 12.1 Database Docker images. Press release: Oracle Brings Oracle’s Flagship Databases and Developer Tools to the Docker Store

Previously to run an Oracle Database in a Docker container you needed to create your own Docker image, I actually Blogged on this earlier in the year, if you interested you can read about it here.

However, you can now obtain an official Oracle 12.1 Database Docker images from the Docker Store

Before you can ‘pull’ the new Docker image you will need to login to the Docker Store and click on the ‘Get Content’ button and then complete the form, providing your name, company, phone number and then accepting the Oracle license agreement.

Docker_Store

The ‘Setup’ button provides details on how ‘pull’ the image and also how to set-up the your Oracle database within Docker.

docker pull store/oracle/database-enterprise:12.1.0.2

pull
The Docker image includes all the required Oracle files so is pretty large coming in at ~4.87GB, so it may take a while to download.

Running the Container

The environment file allows for customisation of the Database name, password, domain and feature bundle.

The command for creating a database container is:

$ docker run -d –env-file -p :1521 -p :5500 -it –name –shm-size=”4g”

Parameters:
<path_to_env_file> is the path to the environment file you created using above example.
<listener_port> is the port on host machine to map the container’s 1521 port (listener port).
<http_port> is the port on host machine to map the container’s 5500 port (http service port).
<container_name> is the container name you want to create.
<shared_memory_size> is the memory size for the container to run. The minimum requirement is 4GB (–shm-size=”4g”).
<image_name> is the image that you use to create a container.

In this example our environment file is called db_env.dat and our container is going to be called dockerDB

docker run -d –env-file ./db_env.dat -p 1527:1521 -p 5507:5500 -it –name dockerDB –shm-size=”8g” store/oracle/database-enterprise:12.1.0.2

We should now be able to see our new Oracle 12.1 image and running container using:

docker image ls
docker container ls

images

From my MacBook Pro we check the progress of the build using the Docker logs option e.g.

docker logs -f dockerDB

ready

We can also connect to the running container using the Docker exec command e.g.

docker exec -it dockerDB /bin/bash

oracle.png
From here we can see the Oracle Docker is using Oracle Linux 7.3 and the database is called ‘OraDoc’ as per our environment file.

As you can see from the above we are connected as root, if you want to use the oracle account then type ‘su – oracle’ and from there try out sqlplus inside your container.

database

Oracle 12c on an MBP Done!

Running Oracle 12.2.0.1 on Docker

Docker Installation

Before you can consider creating an Oracle Database docker container you need to install Docker. If you yet to install Docker you can visit one of my previous posts Docker installation on Oracle Linux 7.2  to get started.

Oracle on Docker

Since last year Oracle have provided build files to assist in the creation of Oracle Database Docker images. Gerald Venzl produced an excellent Blog post Creating an Oracle Database Docker Image for Oracle 12.1.0.2, however now that Oracle 12.2.0.1 is available for on-premises I thought I would try and and create an Oracle 12.2.0.1 container.

Please note, before you start deploying Oracle on Docker it’s probably advisable to check the latest Oracle support position for running Oracle on Docker (see below)
Oracle Support Document 2216342.1 (Oracle Support for Database Running on Docker)

Applies To:
Oracle Database – Enterprise Edition – Version 12.1.0.2 and later
Oracle Database – Standard Edition – Version 12.1.0.2 and later
Linux OS – Version Oracle Linux 7.3 to Oracle Linux 7.3 [Release OL7U3]
Linux x86-64
Details
Oracle will support customers running Oracle Database (single instance) in Docker containers. Oracle will only provide support when running the database in Docker containers running on Oracle Linux and Red Hat RHEL.  Supported versions of these Linux distributions are

  • Oracle Linux 7
  • Red Hat Enterprise Linux 7 (RHEL)

Oracle does not support Oracle Database running in a Real Application Clusters (RAC) configuration in Docker containers.

If your satisfied with your support position you will need the following:

The Oracle Database 12.2.0.1 zip file, which you can get from Oracle Technology Network and the Oracle Docker build files which you can download or clone from GitHub

For this Blog I am using my Vagrant managed Oracle Linux 7.3 Server

[vagrant@localhost ~]$ uname -r
4.1.12-61.1.28.el7uek.x86_64

[vagrant@localhost ~]$ cat /etc/oracle-release
Oracle Linux Server release 7.3

[vagrant@localhost ~]$ docker –version
Docker version 1.12.6, build ac13b2b

Preparation

If you plan to run the docker container out of an Oracle OS account you can use the oracle-database-server-12cR2-preinstall package to create your OS accounts and groups if missing.

I then edited the /etc/sysconfig/docker-storage file adding the following entry to increase the storage space available to my container.

DOCKER_STORAGE_OPTIONS=–storage-opt dm.basesize=20G

As my Vagrant VirtualBox OL73 server had a small root file system I added another 40G disk via VirtualBox for my Docker image via the loopback storage mounting at /var/lib/docker as this is where Docker will create the container file systems.

e.g.
service docker stop
fdisk /dev/sdb
mkfs.xfs /dev/sdb1
cd /var/lib
rm -Rf docker
mkdir docker
mount /dev/sdb1 /var/lib/docker
service docker start

To allow to Oracle to sudo and run docker commands I then added oracle to the /etc/sudoers file.

e.g.
visudo 
oracle ALL = NOPASSWD: ALL

You can now switch user to oracle (su – oracle) and download the Oracle build files and database zip file if you have not already obtained them

[oracle@localhost ~]$ wget https://github.com/oracle/docker-images/archive/master.zip
[oracle@localhost ~]$ unzip master.zip
[oracle@localhost ~]$ cd docker-images-master/OracleDatabase/dockerfiles/12.2.0.1/

Now copy linuxx64_12201_database.zip from its download location to the 12.2.0.1 directory.

Oracle Docker image creation

Usage: buildDockerImage.sh -v [version] [-e | -s | -x] [-i]
Builds a Docker Image for Oracle Database.

Parameters:
-v: version to build
Choose one of: 11.2.0.2  12.1.0.2  12.2.0.1
-e: creates image based on ‘Enterprise Edition’
-s: creates image based on ‘Standard Edition 2’
-x: creates image based on ‘Express Edition’
-i: ignores the MD5 checksums

* select one edition only: -e, -s, or -x

[oracle@localhost 12.2.0.1]$ cd ..
[oracle@localhost dockerfiles]$ sudo ./buildDockerImage.sh -v 12.2.0.1 -e
Checking if required packages are present and valid…
linuxx64_12201_database.zip: OK
==========================
DOCKER info:
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 6
Server Version: 1.12.6
Storage Driver: devicemapper
Pool Name: docker-8:17-134299776-pool
Pool Blocksize: 65.54 kB
Base Device Size: 21.47 GB
Backing Filesystem: xfs
Data file: /dev/loop0
Metadata file: /dev/loop1
Data Space Used: 3.62 GB
Data Space Total: 107.4 GB
Data Space Available: 35.81 GB
Metadata Space Used: 2.535 MB
Metadata Space Total: 2.147 GB
Metadata Space Available: 2.145 GB
Thin Pool Minimum Free Space: 10.74 GB
Udev Sync Supported: true
Deferred Removal Enabled: false
Deferred Deletion Enabled: false
Deferred Deleted Device Count: 0
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
WARNING: Usage of loopback devices is strongly discouraged for production use. Use `–storage-opt dm.thinpooldev` to specify a custom block storage device.
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
Library Version: 1.02.135-RHEL7 (2016-09-28)
Logging Driver: json-file

==========================
Building image ‘oracle/database:12.2.0.1-ee’ …
Sending build context to Docker daemon 3.454 GB
Step 1 : FROM oraclelinux:7-slim
7-slim: Pulling from library/oraclelinux
33a3a5e469a8: Pull complete
Digest: sha256:f3a78afd456061bb897b9f2b54b568dec3973efccf2b086d602fabb94069fb6d
Status: Downloaded newer image for oraclelinux:7-slim
—> f005b5220b05
Step 2 : MAINTAINER Gerald Venzl <gerald.venzl@oracle.com>
—> Running in 64041116d1b3
—> 7cf919c3ab70
Removing intermediate container 64041116d1b3
Step 3 : ENV ORACLE_BASE /opt/oracle ORACLE_HOME /opt/oracle/product/12.2.0.1/dbhome_1 INSTALL_FILE_1 “linuxx64_12201_database.zip” INSTALL_RSP “db_inst.rsp” CONFIG_RSP “dbca.rsp.tmpl” PWD_FILE “setPassword.sh” PERL_INSTALL_FILE “installPerl.sh” RUN_FILE “runOracle.sh” START_FILE “startDB.sh” CREATE_DB_FILE “createDB.sh” SETUP_LINUX_FILE “setupLinuxEnv.sh” CHECK_SPACE_FILE “checkSpace.sh” INSTALL_DB_BINARIES_FILE “installDBBinaries.sh”
—> Running in 25142567c49e
—> 35ff7ea319fa
Removing intermediate container 25142567c49e
Step 4 : ENV INSTALL_DIR $ORACLE_BASE/install PATH $ORACLE_HOME/bin:$ORACLE_HOME/OPatch/:/usr/sbin:$PATH LD_LIBRARY_PATH $ORACLE_HOME/lib:/usr/lib CLASSPATH $ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
—> Running in 2b0c17414781
—> 1eb28b0769f2
Removing intermediate container 2b0c17414781
Step 5 : COPY $INSTALL_FILE_1 $INSTALL_RSP $PERL_INSTALL_FILE $SETUP_LINUX_FILE $CHECK_SPACE_FILE $INSTALL_DB_BINARIES_FILE $INSTALL_DIR/
—> aff425e9295c
Removing intermediate container 8f310fa167cf
Step 6 : COPY $RUN_FILE $START_FILE $CREATE_DB_FILE $CONFIG_RSP $PWD_FILE $ORACLE_BASE/
—> 30a46bcfb092
Removing intermediate container 392cda966aaf
Step 7 : RUN chmod ug+x $INSTALL_DIR/*.sh && sync && $INSTALL_DIR/$CHECK_SPACE_FILE && $INSTALL_DIR/$SETUP_LINUX_FILE
—> Running in ce2d69a6fc72
Loaded plugins: ovl
Resolving Dependencies

Complete!
Loaded plugins: ovl
Cleaning repos: ol7_UEKR4 ol7_latest
Cleaning up everything
—> 4cc34d72a3be
Removing intermediate container ce2d69a6fc72
Step 8 : USER oracle
—> Running in 012bc240b15c
—> 90c7fd83f732
Removing intermediate container 012bc240b15c
Step 9 : RUN $INSTALL_DIR/$INSTALL_DB_BINARIES_FILE EE
—> Running in a669bd56a701
Archive: linuxx64_12201_database.zip
creating: database/

inflating: database/runInstaller
Starting Oracle Universal Installer…

Checking Temp space: must be greater than 500 MB. Actual 16493 MB Passed
Checking swap space: must be greater than 150 MB. Actual 4095 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2017-03-27_03-55-03PM. Please wait …[WARNING] [INS-32055] The Central Inventory is located in the Oracle base.
ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory.
You can find the log of this install session at:
/opt/oracle/oraInventory/logs/installActions2017-03-27_03-55-03PM.log
The installation of Oracle Database 12c was successful.
Please check ‘/opt/oracle/oraInventory/logs/silentInstall2017-03-27_03-55-03PM.log’ for more details.

As a root user, execute the following script(s):
1. /opt/oracle/oraInventory/orainstRoot.sh
2. /opt/oracle/product/12.2.0.1/dbhome_1/root.sh

Successfully Setup Software.

This is perl 5, version 22, subversion 0 (v5.22.0) built for x86_64-linux-thread-multi

Copyright 1987-2015, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using “man perl” or “perldoc perl”. If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

—> 0902cfc62543
Removing intermediate container a669bd56a701
Step 10 : USER root
—> Running in 29796c72580a
—> 09b24f80b740
Removing intermediate container 29796c72580a
Step 11 : RUN $ORACLE_BASE/oraInventory/orainstRoot.sh && $ORACLE_HOME/root.sh && rm -rf $INSTALL_DIR
—> Running in b4e812ee2e1b
Changing permissions of /opt/oracle/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /opt/oracle/oraInventory to dba.
The execution of the script is complete.
Check /opt/oracle/product/12.2.0.1/dbhome_1/install/root_d301de87c50a_2017-03-27_16-01-04-445406140.log for the output of root script
—> afc8f9ef0a10
Removing intermediate container b4e812ee2e1b
Step 12 : USER oracle
—> Running in 6244a9a22dec
—> 8a41f54d71ae
Removing intermediate container 6244a9a22dec
Step 13 : WORKDIR /home/oracle
—> Running in c52fa2e4164f
—> b9daa3897d15
Removing intermediate container c52fa2e4164f
Step 14 : VOLUME $ORACLE_BASE/oradata
—> Running in 847ca5208e7f
—> 2f897f1adbda
Removing intermediate container 847ca5208e7f
Step 15 : EXPOSE 1521 5500
—> Running in d73768c39961
—> 9fd63d1fd413
Removing intermediate container d73768c39961
Step 16 : CMD exec $ORACLE_BASE/$RUN_FILE
—> Running in 34d6f31bb5b7
—> efa2e9d7cc87
Removing intermediate container 34d6f31bb5b7
Successfully built efa2e9d7cc87

Oracle Database Docker Image for ‘ee’ version 12.2.0.1 is ready to be extended:

–> oracle/database:12.2.0.1-ee

Build completed in 840 seconds.

Starting Oracle Docker instance

We are now ready to start the Oracle databases inside a Docker container. To do this we use the docker run command passing the required parameters.

e.g.
-p Port
–name Docker container name, note this is not the database name.

[oracle@localhost dockerfiles]$ sudo docker run -p 1521:1521 –name pure oracle/database:12.2.0.1-ee
ORACLE AUTO GENERATED PASSWORD FOR SYS, SYSTEM AND PDBAMIN: FH0EoJP7dYo=1

LSNRCTL for Linux: Version 12.2.0.1.0 – Production on 27-MAR-2017 16:10:45

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

Starting /opt/oracle/product/12.2.0.1/dbhome_1/bin/tnslsnr: please wait…

TNSLSNR for Linux: Version 12.2.0.1.0 – Production
System parameter file is /opt/oracle/product/12.2.0.1/dbhome_1/network/admin/listener.ora
Log messages written to /opt/oracle/diag/tnslsnr/f4c614207382/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
————————
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 – Production
Start Date                27-MAR-2017 16:10:45
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /opt/oracle/product/12.2.0.1/dbhome_1/network/admin/listener.ora
Listener Log File         /opt/oracle/diag/tnslsnr/f4c614207382/listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
The listener supports no services
The command completed successfully
[WARNING] [DBT-10102] The listener configuration is not selected for the database. EM DB Express URL will not be accessible.
CAUSE: The database should be registered with a listener in order to access the EM DB Express URL.
ACTION: Select a listener to be registered or created with the database.
Copying database files
1% complete
13% complete
25% complete
Creating and starting Oracle instance
26% complete
30% complete
31% complete
35% complete
38% complete
39% complete
41% complete
Completing Database Creation
42% complete
43% complete
44% complete
46% complete
47% complete
50% complete
Creating Pluggable Databases
55% complete
75% complete
Executing Post Configuration Actions
100% complete
Look at the log file “/opt/oracle/cfgtoollogs/dbca/ORCLCDB/ORCLCDB.log” for further details.

SQL*Plus: Release 12.2.0.1.0 Production on Mon Mar 27 16:17:18 2017

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

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 – 64bit Production

SQL>
System altered.

SQL>
Pluggable database altered.

SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 – 64bit Production
#########################
DATABASE IS READY TO USE!
#########################
Completed: alter pluggable database ORCLPDB1 open
2017-03-27T16:17:17.923085+00:00
ORCLPDB1(3):CREATE SMALLFILE TABLESPACE “USERS” LOGGING DATAFILE ‘/opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf’ SIZE 5M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO
ORCLPDB1(3):Completed: CREATE SMALLFILE TABLESPACE “USERS” LOGGING DATAFILE ‘/opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf’ SIZE 5M REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO
ORCLPDB1(3):ALTER DATABASE DEFAULT TABLESPACE “USERS”
ORCLPDB1(3):Completed: ALTER DATABASE DEFAULT TABLESPACE “USERS”
2017-03-27T16:17:18.753847+00:00
ALTER SYSTEM SET control_files=’/opt/oracle/oradata/ORCLCDB/control01.ctl’ SCOPE=SPFILE;
ALTER PLUGGABLE DATABASE ORCLPDB1 SAVE STATE
Completed: ALTER PLUGGABLE DATABASE ORCLPDB1 SAVE STATE
2017-03-27T16:27:02.711804+00:00
ORCLPDB1(3):Resize operation completed for file# 10, old size 337920K, new size 358400K

Resetting the Oracle Database passwords

During the build a default password was allocated, however it’s a good idea to update the passwords now, fortunately the build includes a utility to update the Oracle SYS, SYSYEM & PDBADMIN.

[oracle@localhost dockerfiles]$ sudo docker exec pure ./setPassword.sh Docker
The Oracle base remains unchanged with value /opt/oracle

SQL*Plus: Release 12.2.0.1.0 Production on Tue Mar 28 14:56:13 2017

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

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 – 64bit Production

SQL>
User altered.

SQL>
User altered.

SQL>
Session altered.

SQL>
User altered.

SQL> Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 – 64bit Production

Stopping the Oracle Database Docker

[oracle@localhost dockerfiles]$ sudo docker stop pure
pure

[oracle@localhost dockerfiles]$ sudo docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

Restarting the Oracle Database Docker

[oracle@localhost dockerfiles]$ sudo docker ps
CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS              PORTS                              NAMES

f4c614207382        oracle/database:12.2.0.1-ee   “/bin/sh -c ‘exec $OR”   22 hours ago        Up 2 seconds        0.0.0.0:1521->1521/tcp, 5500/tcp   pure

[oracle@localhost bin]$ ./sql system/Docker@//localhost:1521/ORCLPDB1

SQLcl: Release 4.2.0 Production on Tue Mar 28 15:20:02 2017

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

Last Successful login time: Tue Mar 28 2017 15:20:03 +00:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 – 64bit Production

SQL> select name from v$database;

NAME
———
ORCLCDB

SQL>

Using the Docker Log

The docker logs command will perform a tail -f of /opt/oracle/diag/rdbms/orclcdb/ORCLCDB/trace/alert_ORCLCDB.log which can be useful to diagnose problems or just to review status.

[oracle@localhost ~]$ sudo docker logs -f pure
ORACLE AUTO GENERATED PASSWORD FOR SYS, SYSTEM AND PDBAMIN: FH0EoJP7dYo=1

LSNRCTL for Linux: Version 12.2.0.1.0 – Production on 27-MAR-2017 16:10:45

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

Starting /opt/oracle/product/12.2.0.1/dbhome_1/bin/tnslsnr: please wait…

TNSLSNR for Linux: Version 12.2.0.1.0 – Production
System parameter file is /opt/oracle/product/12.2.0.1/dbhome_1/network/admin/listener.ora
Log messages written to /opt/oracle/diag/tnslsnr/f4c614207382/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
————————
Alias LISTENER
Version TNSLSNR for Linux: Version 12.2.0.1.0 – Production
Start Date 27-MAR-2017 16:10:45
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/product/12.2.0.1/dbhome_1/network/admin/listener.ora
Listener Log File /opt/oracle/diag/tnslsnr/f4c614207382/listener/alert/log.xml
Listening Endpoints Summary…
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
The listener supports no services
The command completed successfully
The docker start command runs the container automatically into the background.