How to resize an XFS filesystem

A question which I frequently get asked is, how do I a resize my Oracle XFS file system ?

As I needed to resize an Oracle FRA area today, I thought this would make a great topic for a Blog post.

Ok, lets start be checking the current size and geometry using the Linux df -h and xfs_growfs -n commands.

[root@z-oracle ~]# df -h
Filesystem                Size  Used Avail Use% Mounted on
..
/dev/mapper/psta-orafra   1.0T   33M  1.0T   1% /u04/app/oracle/fast_recovery_area
..

[root@z-oracle ~]# xfs_growfs /dev/mapper/psta-orafra -n
meta-data=/dev/mapper/psta-orafra isize=256 agcount=4, agsize=67108864 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0 spinodes=0
data = bsize=4096 blocks=268435456, imaxpct=5
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=131072, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0

Now run the multipath command to check the current size of the LUN,  look for the friendly device name within the list of devices.

[root@z-oracle ~]# multipath -ll

psta-orafra (3624a937050c939582b0f46c0000a8f84) dm-17 PURE ,FlashArray
size=1.0T features=’0′ hwhandler=’0′ wp=rw
`-+- policy=’queue-length 0′ prio=1 status=active
|- 10:0:3:20 sdgl 132:16 active ready running
|- 10:0:4:20 sdiq 135:160 active ready running
|- 10:0:5:20 sdkq 66:480 active ready running
|- 10:0:6:20 sdmo 70:256 active ready running
|- 10:0:7:20 sdom 129:288 active ready running
|- 1:0:0:20 sdai 66:32 active ready running
|- 1:0:1:20 sdcr 69:240 active ready running
|- 1:0:2:20 sder 129:48 active ready running
|- 1:0:3:20 sdgr 132:112 active ready running
|- 1:0:4:20 sdil 135:80 active ready running
|- 1:0:5:20 sdkk 66:384 active ready running
|- 1:0:6:20 sdmk 69:448 active ready running
|- 1:0:7:20 sdop 129:336 active ready running
|- 10:0:0:20 sdau 66:224 active ready running
|- 10:0:1:20 sdck 69:128 active ready running
`- 10:0:2:20 sdel 128:208 active ready running

Now resize the volume using the Pure FlashArray UI, command line or REST API.

Screen Shot 2017-05-11 at 10.44.03

We now need to perform a rescan of the SCSI devices on our Linux server to identify any LUNS which have been resized.

[root@z-oracle ~]# rescan-scsi-bus.sh -s
Scanning SCSI subsystem for new devices
Searching for resized LUNs

We can now resize the multipath device using the following command:

[root@z-oracle mapper]# multipathd -k’resize map /dev/dm-17
ok

Great, ok now use the Linux command xfs_growfs to extend the file system, note if you do not specify -D xfs_growfs will grow to use all available space.

[root@z-oracle ~]# xfs_growfs /dev/mapper/psta-orafra
meta-data=/dev/mapper/psta-orafra isize=256 agcount=4, agsize=67108864 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0 spinodes=0
data = bsize=4096 blocks=268435456, imaxpct=5
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=131072, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 268435456 to 536870912

Ok, lets check the results

[root@z-oracle ~]# df -h
Filesystem Size Used Avail Use% Mounted on

/dev/mapper/psta-orafra 2.0T 33M 2.0T 1% /u04/app/oracle/fast_recovery_area
..

As you see from above, within a few minutes I have been able to increase my Oracle fast_recovery_area from 1TB to 2TB.

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.

Getting started with Ansible and Oracle

Introduction

In my previous post An introduction to Ansible I shared some reasons why companies are adopting Ansible and described some of the advantages of using Ansible over other configuration management tools.

Now we know what Ansible is, let’s start using it.

Setting up an Ansible Control Machine

The simplest and quickest way to get up and running with Ansible is to use Vagrant to create a virtual machine. Vagrant ships with out of the box support for VirtualBox, Hyper-V and Docker. Vagrant supports other providers e.g. VMware but these are licenceable

So even though I mainly use VMware Fusion on my MacBook I used the links above to install Vagrant and the excellent Oracle VirtualBox to avoid any licensing requirements.

Using Vagrant

Run the following commands to create a Vagrantfile for an Ubuntu Vagrant machine.
$ mkdir ansible_oracle
$ cd ansible_oracle
$ vagrant init ubuntu/trusty64

A `Vagrantfile` has been placed in this directory. You are now ready to `vagrant up` your first virtual environment! Please read the comments in the Vagrantfile as well as documentation on `vagrantup.com` for more information on using Vagrant.

$ vagrant up
You should now be able to SSH into your Ubuntu VM using ‘vagrant ssh’, however before we try and connect to our new VM let’s check the status of all the local Vagrant machines using the following:
$ vagrant global-status

id       name    provider   state    directory
————————————————————————-
a1995ac  default virtualbox running  /Users/ronekins/ansible_oracle

The above shows information about all known Vagrant environments
on this machine. This data is cached and may not be completely
up-to-date. To interact with any of the machines, you can go to
that directory and run Vagrant, or you can use the ID directly
with Vagrant commands from any directory. For example:
“vagrant destroy 1a2b3c4d”

$ vagrant status a1995ac
Current machine states:

default running (virtualbox)

The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down forcefully, or you can run `vagrant suspend` to simply
suspend the virtual machine. In either case, to restart it again,
simply run `vagrant up`.

$ vagrant ssh
If all has gone well you should be presented with your Ubuntu virtual machine.

Useful vagrant machine (vm) commands

destroy       : stops and deletes all traces of the vm 
global-status : outputs status Vagrant env's for this user 
halt          : stops the vm 
init          : initialises a new Vagrant environment 
provision     : provisions the vm 
reload        : restarts vm, loads new Vagrantfile config 
resume        : resume a suspended vm 
snapshot      : manages snapshots, saving, restoring, etc. 
ssh           : connects to vm via SSH 
status        : outputs status of the vm 
suspend       : suspends the vm 
up            : starts and provisions the vm

Ansible Installation

$ sudo apt-get install software-properties-common
$ sudo apt-add-repository ppa:ansible/ansible
$ sudo apt-get update
$ sudo apt-get install ansible

Update local host file

Add the IP address and database server names to your local host file.
$ sudo vi /etc/hosts

Getting Started

Create Ansible configuration file

$ vi ansible.cfg
[defaults]
hostfile = hosts
ansible_private_key_file=~/.ssh/id_rsa

Create Ansible host file

In the host file we can specify that we want ansible to default to the ‘oracle’ user, the first entry is a server alias, in the example below I have kept it the same as the server name but it can be useful if you have cryptic host names or want to refer to the server by it’s database or application name.
$ vi hosts
[dbservers]
z-oracle         ansible_host=z-oracle        ansible_user=oracle
z-oracle-dr  ansible_host=z-oracle-dr  ansible_user=oracle

Ansible Ping Test

Now let’s try using the Ansible ping module to try to connect to our database server and verify a usable version of python, the ping module will return ‘pong’ on success.
$ ansible all -m ping

Both servers will fail returning UNREACHABLE! as the ssh connection failed, to fix this add a public key to the database servers ‘authorized_keys’file.

Generating RSA Keys

Before we can use password-less SSH we need to create a pair of private and public RSA keys for our Ansible control machine.

$ cd ~/.ssh
$ ssh-keygen -t rsa
$ cat id_rsa.pub

‘Copy’ the id_rsa.pub into your client buffer and ssh onto the database servers as the ‘oracle’, cd to the .ssh directory and ‘paste’ the public key into the ‘authorized_keys’ file.

$ cd ~/.ssh
$ vi authorised_keys

Now return to your Ansible control machine to repeat the Ansible Ping Tests.

Ansible Ping Part II

Ok, now we are ready to check connectivity, first lets trying using the database server names individually.
ping_each
That was great, but as we defined a group ‘dbservers’ we can also perform a ‘ping’ test using the group name as we may want to perform an ansible play against a group of servers e.g. Production, Development, Test etc..

ping_group
Very cool, if required you can use the ‘all’ option to run against all entries in the host file.

ping_all
In my next blog post we will start to use our Ubuntu Ansible control machine to interact with our database servers.

Resizing Oracle ASM disks

Today I though I would share with how easy it is to resize Oracle ASM volumes with Pure Storage.

Ok, lets first check the Oracle ASM disk sizes using ‘asmcmd -p’

asmcli_pre.png

As you can see from the above, I have 3 volumes each of 100GB, for this test let’s increase them all to 1TB using the purevol command from with the CLI.

Pure_resize.png

Great, my volumes have now al been resized, I could have achieved the same results with the Pure UI or Web Services, but that’s something for another day.

Linux device rescan

Ok, we now need to let Linux and Oracle know about our resized volumes.

As root rescan the SCSI devices to identify which volumes which have been resized using:

rescan-scsi-bus.sh -s

Use ‘multipathd -k ‘resize map ‘ to resize the multipath devices e.g.

multipathd -k'resize map slob-data'

Before you moving onto resizing the Oracle ASM disk groups check your updated multi path configuration with ‘multipath -ll’, look for your device name and size e.g.

slob-data (3624a937050c939582b0f46c000059779) dm-5 PURE,FlashArray      size=1.0T features='0' hwhandler='0' wp=rw
`-+- policy='queue-length 0' prio=1 status=active
...

Oracle ASM resize

As your ‘grid’ user connect as sysasm from sqlplus e.g. sqlplus / as sysasm and perform ‘alter disk group <dg_name> resize all’

sqlplus_resize

Great, job done, but before we more on let’s check out work first using sqlplus as sysasm

SQL>  select name, total_mb/(1024) "Total GiB" from v$asm_diskgroup;
NAME                           Total GiB
------------------------------ ----------
CONTROL_REDO                   1024
FRA                            1024
DATA                           1024

And, now with the ASM command line utility ‘asmcmd’

asmcli_post.png

Or if you prefer the ASM UI ‘asmca’.

asmca.png