SlideShare a Scribd company logo
The Pythonic Way crosses
Oracle‘s Exadata
by rainer schuettengruber
about me
• IT employee since 1998
• main focus on Oracle databases
• various positions as Oracle DBA(DMA), developer, devops
• currently employed as Exadata Administrator
itinerary
continous integration
• version control
• automated build
• unit tests
• automated unit tests
• automated deployment
pre python era
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
• heterogeneous environment
• Oracle on AIX, Linux on VMware, Exadata
• Oracle Version 10.2.0.4, 11.2.0.1,11.2.0.2, 11.2.0.3, 11.2.0.4
• Oracle Cloud Control 11g on Linux
• Oracle Cloud Control 12c on AIX
• backup based on Cloud Control jobs
• backup based on TSM scheduler
• backup based on ksh scripts
• .. to take arms against a sea of troubles ..
pre python era
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
• automation and standardisation are siamese twins
• standardisation by migrating all databases to Exadata
• migrated on database after the other
• took almost a year
• set the stage for automation
the game is on
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
oracle@disguised:misc (TEST1) > ./tracemaint.sh -h
usage: tracemaint [-h] -d DAYS -m MAXLOGSIZE [-s SID] [-k] [--debug]
tidy up database trace and log files
optional arguments:
-h, --help show this help message and exit
-d DAYS, --days DAYS number of days that logs/traces need to be kept
-m MAXLOGSIZE, --maxlogsize MAXLOGSIZE
threshold in MB, specifying if a log files needs
rotation
-s SID, --sid SID database SID, if omitted all databases configured in
/etc/oratab are considered
-k, --keeptempfiles keep files generated during logrotation, use this for
debugging purposes only
--debug log debug output
the game is on
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
• Python comes with Linux, however
• versions, depending on the distribution, between 2.4 – 2.7
• changing installation might do harm, especially on Exadata
• dedicated installation under /opt in accord with FHS
• moreover Exadata does not support customized RPM‘s
• building from source and installation via tarball
the game is on
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
disguised:/root/svnRepo/scripts/bash/osSetup>./build_python.sh
usage : build_python.sh -p <python source tarball> -r -c
-r .. remove existing installation
-c .. create tarball from the installation
disguised:/root/svnRepo/scripts/bash/osSetup>
disguised:/root/svnRepo/scripts/bash/osSetup>./install_python.sh
usage : install_python.sh -t <python tarball>
disguised:/root/svnRepo/scripts/bash/osSetup>
the game is on
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
• SVN rather obvious
• used for deployments in combination with make files
• installation under /opt requires command line wrappers
• which comes in handy for cx_Oracle
the game is on
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
[root@disguised traceMaintenance]# cat Makefile
INSTALL_DIR = /home/oracle/scripts/misc
wrapperScripts = $(INSTALL_DIR)/tracemaint.sh
all: $(wrapperScripts)
$(INSTALL_DIR)/%.sh: %.sh
install -o oracle -g oinstall -m 755 $? $@
[root@disguised traceMaintenance]# cat tracemaint.sh
#!/bin/bash
export LD_LIBRARY_PATH=/opt/oracle/product/12.2.0.1/instantclient
unset NLS_LANG
/opt/python/bin/tracemaint "$@"
[root@disguised traceMaintenance]#
the game is on
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
import logging
from logging.handlers import RotatingFileHandler
import argparse
import sys
import os
import subprocess
import glob
import re
from datetime import datetime
import cx_Oracle
OOP appears on the stage
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
• SAP requires a dedicated toolset for database maintenance
• basically 4 compenents
• separate for each database
• installation and patching rather tedious for 20+ databases
• implementation reminiscent of the DRY principle
OOP appears on the stage
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
OOP appears on the stage
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
• one python file per class, used modules without recognizing it
• patching became a matter of minutes as opposed to hours
• off the beaten script track
• peer cluster nodes taken into consideration
OOP appears on the stage
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
import shutil
from pwd import getpwuid
from pexpect import pxssh
import paramiko
from paramiko import SSHClient
from scp import SCPClient
the master‘s class
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
• became aware of python‘s modul concept
• formed the idea of bundling modules in a package that provides console
scripts
• amongst improving python skills, set the stage for a clean and reusable code
base
• good riddance bash
• well established principles in software development won‘t do harm in
operations
the helping hand
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
• Cloud Control migration/consilidation had become inevitable
• upgrade path for only one of the two systems available
• implies that 50 per cent of the monitored databases need to be configured
manually, tedious and prone to error
• further use of configuration scripts justify the effort and contribute to
standardisation
• in essence a wrapper for Cloud Control‘s python based emcli utility
• migration/consolidation a matter of hours
• adding a database became a matter of seconds
exadata migration on steriods
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
• existing Exadata systems had done their duty
• essentially the same migration path as for the migration from AIX to Exadata
• however, due to strigent licence terms only a parallel phase of 3 months in
sharp contrast to 1 year
• further cut down to 4 weekends due to staff availability
• no reason to despair since python is around ...
• built on top of Oracle‘s dataguard, cutting down downtime to a couple of
minutes
exadata migration on steriods
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
• typed python code instead of oracle commands on the weekends
• structured code into modules
• created a package to ease deployment
• manual build with python setup.py bdist_wheel
• implemented console scripts
• toyed with the idea to use ant as build tool
exadata migration on steriods
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
disguised:/root/svnRepo/scripts/python>find rlb -maxdepth 1
rlb
rlb/common
rlb/__init__.py
rlb/__pycache__
rlb/occ
rlb/sap
rlb/tsm
rlb/db
rlb/dg
rlb/dp
rlb/occut
rlb/dput
rlb/commonut
rlb/exa
rlb/tmut
rlb/dbut
rlb/dgut
rlb/tm
exadata migration on steriods
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
from setuptools import setup
from setuptools import find_packages
setup(
name='rlb',
version='6.8.1',
author='rainer schuettengruber',
author_email='rainer.schuettengruber@rrz.co.at',
packages=find_packages(),
package_data={
'': ['*.template'],
},
entry_points={
'console_scripts': [
'massdeploy=rlb.common.massdeploy:main_for_script',
'tracemaint=rlb.tm.tracemaint:main_for_script',
automatisation of the automatisation
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
• automated database setup
• build and deployment appeared to be rather tedious
• opted for ant
• faced the same issues as already discussed for the pyhton installation
• addressed by installing ant under /opt
• build specific environment variables by means of the build.env script
automatisation of the automatisation
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
[root@disguised python]# source build.env
PATH :
/opt/python/bin:/opt/ant/bin:/u01/app/12.1.0.2/grid/bin:/usr/local/sbin:/usr/local/bin:/sbi
n:/bin:/usr/sbin:/usr/bin:/root/bin
LD_LIBRARY_PATH : /opt/oracle/product/12.2.0.1/instantclient
ANT_ARGS : -emacs -logger org.apache.tools.ant.NoBannerLogger
PYTHON_PATH : /root/svnRepo/scripts/python
[root@disguised python]# ant -p
Buildfile: /root/svnRepo/scripts/python/build.xml
Build and deploy rlb's pyhton modules
Main targets:
clean clean up all files created by either dist or docs target
dist build wheel
distclean clean up files created by the dist target
install install wheel on this host
Default target: usage
[root@disguised python]#
prose meets code
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
• given a SLOC of 3600, documentation became a necessisty
• opted for sphinx
• created UML diagrams with pyreverse which is part of the pylint package
• added ant target docs
prose meets code
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
<target name="docs"
description="generate sphinx documentation, including pylint and pyreverse
output"
depends="clean">
<!-- create sphinx-apidoc -->
<exec executable="${python.binpath}/sphinx-apidoc">
<arg value="-f" />
<arg value="-o" />
<arg value="${doc.sphinx.source.dir}" />
<arg value="${package.dir}" />
</exec>
<!-- creating UML diagrams -->
<exec executable="${python}" >
<arg value="builduml.py" />
</exec>
<!-- render html docu -->
<exec executable="/usr/bin/make">
<env key="LD_LIBRARY_PATH" path="/opt/oracle/product/12.2.0.1/instantclient" />
<arg value="html" />
</exec>
prose meets code
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
<!-- create pylint output -->
<mkdir dir="${doc.pylint.dir}" />
<echo message="writing pylint's output to ${doc.pylint.dir}/packages_pylint.txt" />
<exec executable="${pylint}"
dir="${package.dir}"
output="${doc.pylint.dir}/packages_pylint.txt" >
<arg value="--rcfile=pylint.rc" />
<arg value="-f" />
<arg value="text" />
<arg value="rlb" />
</exec>
<!-- deploy documentation -->
<delete>
<fileset dir="${doc.deploy.dir}" includes="**/*.*" />
</delete>
<echo message="deploying docu to ${doc.deploy.dir} ..." />
<copy todir="${doc.deploy.dir}">
<fileset dir="${doc.sphinx.build.dir}/html">
<include name="**/*" />
</fileset>
</copy>
</target>
prose meets code
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
prose meets code
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
a giant leap towards CI
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
• functionality shared by all modules has been refactored into the common sub
package
• breaking functionality within the common sub package results in breaking the
whole code base
• unit tests absolutely vital
• additional sub package with suffix ut
• one test file for each module, prefixed with test_
a giant leap towards CI
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
[root@disguised rlb]# find common* -name '*.py'
common/os.py
common/template.py
common/__init__.py
common/oradb.py
common/massdeploy.py
commonut/test_oradb.py
commonut/__init__.py
commonut/test_template.py
commonut/test_os.py
commonut/test_massdeploy.py
[root@disguised rlb]#
a giant leap towards CI
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
• version control, ant build and unit tests have been implemented
• which sets the stage for a decent jenkins installation
• Subversion plugin for obvious reasons
• Cobertura plugin aimed at automatic unit tests
• SLOCCount plugin in case somebody asks
• Violations plugin since pylint reports are already in place
• Static analysis collector plugin-in as a dependency
a giant leap towards CI
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
disguised:/root/svnRepo/scripts/python>cat requirements_test.txt
astroid>=1.5.3
autopep8>=1.3.2
coverage>=4.4.1
idna>=2.1
isort>=4.2.5
lazy_object_proxy>=1.2.2
logilab_common>=1.3.0
mccabe>=0.5.2
pep8>=1.7.0
py>=1.4.34
pyenchant>=1.6.8
pygount>=0.9
pylint>=1.7.2
pytest>=3.2.1
pytest-cov>=2.5.1
sphinx_pyreverse>=0.0.12
wrapt>=1.10.8
Pygments>=2.2
a giant leap towards CI
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
<target name="code-metrics" description="gather code metrics">
<!-- obtain source code lines by using pygount -->
<echo message="writing pygount's output to cloc.xml" />
<exec executable="${pygount}" dir="../..">
<arg value="--format=cloc-xml" />
<arg value="--suffix=py,sh,sql,xml,pks,pkb,php,java" />
<arg value="--out=cloc.xml" />
</exec>
<!-- assess code quality with pylint -->
.
.
<!-- evaluate code quality with pep8 -->
<echo message="writing pep8's output to pep8.out" />
<exec executable="${pep8}"
dir="${package.dir}"
output="../../pep8.out">
<arg value="--filename=*.py" />
<arg value="--max-line-length=99" />
<arg value="." />
</exec>
</target>
a giant leap towards CI
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
disguised:/root/svnRepo/scripts/python>ant -p
Buildfile: /root/svnRepo/scripts/python/build.xml
Build and deploy rlb's pyhton modules
Main targets:
all build wheel and documentation
clean clean up all files created by either dist or docs target
code-metrics gather code metrics
dist build wheel
distclean clean up files created by the dist target
docs generate sphinx documentation, including pylint and pyreverse output
install install wheel on this host
jenkins build targets required by continuous integration
Default target: usage
disguised:/root/svnRepo/scripts/python>
<target name="jenkins" description="build targets required by continuous integration"
depends="clean, code-metrics, dist" />
a giant leap towards CI
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
a giant leap towards CI
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
a giant leap towards CI
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
a bit quality
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
• given that jenkins and unit tests are in place, test automatisation appears to
be quite obvious
• isolated build by means of venv
• documented required modules, which comes in handy when
upgrading/installing python
• run test suite by means of pytest
• added coverage reports
a bit quality
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
<target name="test" description="run test suite" depends="venv">
<exec executable="${venv.python}" failonerror="true">
<arg value="setup.py" />
<arg value="install" />
</exec>
<exec executable="/home/jenkins/scripts/pre_unittest.sh" />
<exec executable="${venv.pytest}">
<!-- No failonerror="true" because on failed tests, pytest exits with 1. -->
<env key="LD_LIBRARY_PATH" path="/opt/oracle/product/12.2.0.1/instantclient" />
<arg value="--junit-xml=unittest.xml" />
<arg value="--cov=${package.dir}" />
<arg value="--cov-report=html" />
<arg value="--cov-report=xml" />
<arg value="--ignore=${venv.dir}" />
<arg value="--ignore=./rlb/commonut/test_cp1252_encoding.txt" />
<arg file="${package.dir}" />
</exec>
<exec executable="/home/jenkins/scripts/post_unittest.sh" />
</target>
a bit quality
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
a bit quality
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
a bit quality
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
• complete test coverage would imply a dedicated exadata environment
• a case for unittest.mock
• as a precondition Exadata/database related calls need to be separated, which
has not been considered in the initial design
• might be subject to another talk
• however, the foundations are laid
• played a vital role during the upgrade vom python 3.5 to 3.6
the finishing touch
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
• due to stringent security policies no access to pypi.python.org
• has been circumvented by using pip install http://...
• however, resolving dependencies appeared to be a bit tedious
• so pypiserver it is
• enables continous deployment
the finishing touch
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
[Unit]
Description=pypi-server
After=network.target
[Service]
Type=simple
ExecStart=/opt/python/bin/pypi-server -p 8081 --disable-fallback -v --log-file
/var/log/pypi-server.log -u /var/www/html/pypi
[Install]
WantedBy=multi-user.target
the finishing touch
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
disguised:/root/svnRepo/scripts/python>ant -p
Buildfile: /root/svnRepo/scripts/python/build.xml
Build and deploy rlb's pyhton modules
Main targets:
all build wheel and documentation
clean clean up all files created by either dist or docs target
code-metrics gather code metrics
deploy install wheel on production hosts
dist build wheel
distclean clean up files created by the dist target
docs generate sphinx documentation, including pylint and pyreverse output
install install wheel on this host
jenkins build targets required by continuous integration
test run test suite
venv setup virtual Python environment
Default target: usage
disguised:/root/svnRepo/scripts/python>
where do we go now?
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17
• deal with testing issues
• become proactive by forecasting capacity and load with appropriate models
• tweak pylint/pep8
• improve on documentation
questions and answers
07/14
07/15
09/15
02/16
05/16
07/16
10/16
11/16
01/17
03/17
07/17

More Related Content

PPTX
Part1 of SQL Tuning Workshop - Understanding the Optimizer
PPTX
Adapting and adopting spm v04
DOCX
Oracle forms and reports 11g installation on linux
PDF
My First 100 days with an Exadata (PPT)
PPTX
Tanel Poder Oracle Scripts and Tools (2010)
PDF
MAA Best Practices for Oracle Database 19c
PDF
Oracle Real Application Clusters (RAC) 12c Rel. 2 - Operational Best Practices
PDF
Rman Presentation
Part1 of SQL Tuning Workshop - Understanding the Optimizer
Adapting and adopting spm v04
Oracle forms and reports 11g installation on linux
My First 100 days with an Exadata (PPT)
Tanel Poder Oracle Scripts and Tools (2010)
MAA Best Practices for Oracle Database 19c
Oracle Real Application Clusters (RAC) 12c Rel. 2 - Operational Best Practices
Rman Presentation

What's hot (20)

PDF
"It can always get worse!" – Lessons Learned in over 20 years working with Or...
PDF
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
PDF
Oracle statistics by example
PDF
Nabil Nawaz Oracle Oracle 12c Data Guard Deep Dive Presentation
PPT
Dataguard presentation
PDF
Free Load Testing Tools for Oracle Database – Which One Do I Use?
PPTX
Oracle AWR Data mining
PPT
Using AWR for IO Subsystem Analysis
PDF
Backup and recovery in oracle
PPTX
AWR and ASH Deep Dive
PDF
Understanding oracle rac internals part 1 - slides
PDF
Understanding oracle rac internals part 2 - slides
PPTX
Christo kutrovsky oracle, memory & linux
PDF
Chasing the optimizer
PDF
Mastering PostgreSQL Administration
 
PPTX
What to Expect From Oracle database 19c
PDF
Oracle Performance Tuning Fundamentals
PPTX
An Introduction To Oracle Database
PDF
MySQL Group Replication - Ready For Production? (2018-04)
PPTX
Oracle Database Exadata Cloud Service Conference
"It can always get worse!" – Lessons Learned in over 20 years working with Or...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Oracle statistics by example
Nabil Nawaz Oracle Oracle 12c Data Guard Deep Dive Presentation
Dataguard presentation
Free Load Testing Tools for Oracle Database – Which One Do I Use?
Oracle AWR Data mining
Using AWR for IO Subsystem Analysis
Backup and recovery in oracle
AWR and ASH Deep Dive
Understanding oracle rac internals part 1 - slides
Understanding oracle rac internals part 2 - slides
Christo kutrovsky oracle, memory & linux
Chasing the optimizer
Mastering PostgreSQL Administration
 
What to Expect From Oracle database 19c
Oracle Performance Tuning Fundamentals
An Introduction To Oracle Database
MySQL Group Replication - Ready For Production? (2018-04)
Oracle Database Exadata Cloud Service Conference
Ad

Similar to Python on exadata (20)

PPTX
Open source tools for optimizing your peering infrastructure @ DE-CIX TechMee...
ODP
Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...
PPTX
Docker for Development
PDF
Beyond Puppet
PPTX
Five Real-World Strategies for Perforce Streams
PPTX
Dockerizing the Hard Services: Neutron and Nova
KEY
Ruby and Rails Packaging to Production
PDF
Install FD.IO VPP On Intel(r) Architecture & Test with Trex*
PDF
Kubernetes vs dockers swarm supporting onap oom on multi-cloud multi-stack en...
PDF
Making Spinnaker Go @ Stitch Fix
PPTX
Your Inner Sysadmin - Tutorial (SunshinePHP 2015)
PDF
All in one
PDF
Develop QNAP NAS App by Docker
PDF
Linux Foundation Mentorship Sessions - Kernel Livepatch: An Introduction
PDF
9 steps to install and configure postgre sql from source on linux
PDF
nouka inventry manager
KEY
Deploying and maintaining your software with RPM/APT
PPTX
Using R on High Performance Computers
PDF
Large-scaled Deploy Over 100 Servers in 3 Minutes
PDF
Network Stack in Userspace (NUSE)
Open source tools for optimizing your peering infrastructure @ DE-CIX TechMee...
Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...
Docker for Development
Beyond Puppet
Five Real-World Strategies for Perforce Streams
Dockerizing the Hard Services: Neutron and Nova
Ruby and Rails Packaging to Production
Install FD.IO VPP On Intel(r) Architecture & Test with Trex*
Kubernetes vs dockers swarm supporting onap oom on multi-cloud multi-stack en...
Making Spinnaker Go @ Stitch Fix
Your Inner Sysadmin - Tutorial (SunshinePHP 2015)
All in one
Develop QNAP NAS App by Docker
Linux Foundation Mentorship Sessions - Kernel Livepatch: An Introduction
9 steps to install and configure postgre sql from source on linux
nouka inventry manager
Deploying and maintaining your software with RPM/APT
Using R on High Performance Computers
Large-scaled Deploy Over 100 Servers in 3 Minutes
Network Stack in Userspace (NUSE)
Ad

Recently uploaded (20)

PPTX
ai tools demonstartion for schools and inter college
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
history of c programming in notes for students .pptx
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Digital Strategies for Manufacturing Companies
ai tools demonstartion for schools and inter college
VVF-Customer-Presentation2025-Ver1.9.pptx
PTS Company Brochure 2025 (1).pdf.......
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
How to Migrate SBCGlobal Email to Yahoo Easily
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Computer Software and OS of computer science of grade 11.pptx
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Design an Analysis of Algorithms I-SECS-1021-03
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Softaken Excel to vCard Converter Software.pdf
Adobe Illustrator 28.6 Crack My Vision of Vector Design
history of c programming in notes for students .pptx
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
wealthsignaloriginal-com-DS-text-... (1).pdf
Digital Strategies for Manufacturing Companies

Python on exadata

  • 1. The Pythonic Way crosses Oracle‘s Exadata by rainer schuettengruber
  • 2. about me • IT employee since 1998 • main focus on Oracle databases • various positions as Oracle DBA(DMA), developer, devops • currently employed as Exadata Administrator
  • 4. continous integration • version control • automated build • unit tests • automated unit tests • automated deployment
  • 5. pre python era 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 • heterogeneous environment • Oracle on AIX, Linux on VMware, Exadata • Oracle Version 10.2.0.4, 11.2.0.1,11.2.0.2, 11.2.0.3, 11.2.0.4 • Oracle Cloud Control 11g on Linux • Oracle Cloud Control 12c on AIX • backup based on Cloud Control jobs • backup based on TSM scheduler • backup based on ksh scripts • .. to take arms against a sea of troubles ..
  • 6. pre python era 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 • automation and standardisation are siamese twins • standardisation by migrating all databases to Exadata • migrated on database after the other • took almost a year • set the stage for automation
  • 7. the game is on 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 oracle@disguised:misc (TEST1) > ./tracemaint.sh -h usage: tracemaint [-h] -d DAYS -m MAXLOGSIZE [-s SID] [-k] [--debug] tidy up database trace and log files optional arguments: -h, --help show this help message and exit -d DAYS, --days DAYS number of days that logs/traces need to be kept -m MAXLOGSIZE, --maxlogsize MAXLOGSIZE threshold in MB, specifying if a log files needs rotation -s SID, --sid SID database SID, if omitted all databases configured in /etc/oratab are considered -k, --keeptempfiles keep files generated during logrotation, use this for debugging purposes only --debug log debug output
  • 8. the game is on 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 • Python comes with Linux, however • versions, depending on the distribution, between 2.4 – 2.7 • changing installation might do harm, especially on Exadata • dedicated installation under /opt in accord with FHS • moreover Exadata does not support customized RPM‘s • building from source and installation via tarball
  • 9. the game is on 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 disguised:/root/svnRepo/scripts/bash/osSetup>./build_python.sh usage : build_python.sh -p <python source tarball> -r -c -r .. remove existing installation -c .. create tarball from the installation disguised:/root/svnRepo/scripts/bash/osSetup> disguised:/root/svnRepo/scripts/bash/osSetup>./install_python.sh usage : install_python.sh -t <python tarball> disguised:/root/svnRepo/scripts/bash/osSetup>
  • 10. the game is on 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 • SVN rather obvious • used for deployments in combination with make files • installation under /opt requires command line wrappers • which comes in handy for cx_Oracle
  • 11. the game is on 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 [root@disguised traceMaintenance]# cat Makefile INSTALL_DIR = /home/oracle/scripts/misc wrapperScripts = $(INSTALL_DIR)/tracemaint.sh all: $(wrapperScripts) $(INSTALL_DIR)/%.sh: %.sh install -o oracle -g oinstall -m 755 $? $@ [root@disguised traceMaintenance]# cat tracemaint.sh #!/bin/bash export LD_LIBRARY_PATH=/opt/oracle/product/12.2.0.1/instantclient unset NLS_LANG /opt/python/bin/tracemaint "$@" [root@disguised traceMaintenance]#
  • 12. the game is on 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 import logging from logging.handlers import RotatingFileHandler import argparse import sys import os import subprocess import glob import re from datetime import datetime import cx_Oracle
  • 13. OOP appears on the stage 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 • SAP requires a dedicated toolset for database maintenance • basically 4 compenents • separate for each database • installation and patching rather tedious for 20+ databases • implementation reminiscent of the DRY principle
  • 14. OOP appears on the stage 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17
  • 15. OOP appears on the stage 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 • one python file per class, used modules without recognizing it • patching became a matter of minutes as opposed to hours • off the beaten script track • peer cluster nodes taken into consideration
  • 16. OOP appears on the stage 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 import shutil from pwd import getpwuid from pexpect import pxssh import paramiko from paramiko import SSHClient from scp import SCPClient
  • 17. the master‘s class 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 • became aware of python‘s modul concept • formed the idea of bundling modules in a package that provides console scripts • amongst improving python skills, set the stage for a clean and reusable code base • good riddance bash • well established principles in software development won‘t do harm in operations
  • 18. the helping hand 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 • Cloud Control migration/consilidation had become inevitable • upgrade path for only one of the two systems available • implies that 50 per cent of the monitored databases need to be configured manually, tedious and prone to error • further use of configuration scripts justify the effort and contribute to standardisation • in essence a wrapper for Cloud Control‘s python based emcli utility • migration/consolidation a matter of hours • adding a database became a matter of seconds
  • 19. exadata migration on steriods 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 • existing Exadata systems had done their duty • essentially the same migration path as for the migration from AIX to Exadata • however, due to strigent licence terms only a parallel phase of 3 months in sharp contrast to 1 year • further cut down to 4 weekends due to staff availability • no reason to despair since python is around ... • built on top of Oracle‘s dataguard, cutting down downtime to a couple of minutes
  • 20. exadata migration on steriods 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 • typed python code instead of oracle commands on the weekends • structured code into modules • created a package to ease deployment • manual build with python setup.py bdist_wheel • implemented console scripts • toyed with the idea to use ant as build tool
  • 21. exadata migration on steriods 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 disguised:/root/svnRepo/scripts/python>find rlb -maxdepth 1 rlb rlb/common rlb/__init__.py rlb/__pycache__ rlb/occ rlb/sap rlb/tsm rlb/db rlb/dg rlb/dp rlb/occut rlb/dput rlb/commonut rlb/exa rlb/tmut rlb/dbut rlb/dgut rlb/tm
  • 22. exadata migration on steriods 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 from setuptools import setup from setuptools import find_packages setup( name='rlb', version='6.8.1', author='rainer schuettengruber', author_email='[email protected]', packages=find_packages(), package_data={ '': ['*.template'], }, entry_points={ 'console_scripts': [ 'massdeploy=rlb.common.massdeploy:main_for_script', 'tracemaint=rlb.tm.tracemaint:main_for_script',
  • 23. automatisation of the automatisation 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 • automated database setup • build and deployment appeared to be rather tedious • opted for ant • faced the same issues as already discussed for the pyhton installation • addressed by installing ant under /opt • build specific environment variables by means of the build.env script
  • 24. automatisation of the automatisation 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 [root@disguised python]# source build.env PATH : /opt/python/bin:/opt/ant/bin:/u01/app/12.1.0.2/grid/bin:/usr/local/sbin:/usr/local/bin:/sbi n:/bin:/usr/sbin:/usr/bin:/root/bin LD_LIBRARY_PATH : /opt/oracle/product/12.2.0.1/instantclient ANT_ARGS : -emacs -logger org.apache.tools.ant.NoBannerLogger PYTHON_PATH : /root/svnRepo/scripts/python [root@disguised python]# ant -p Buildfile: /root/svnRepo/scripts/python/build.xml Build and deploy rlb's pyhton modules Main targets: clean clean up all files created by either dist or docs target dist build wheel distclean clean up files created by the dist target install install wheel on this host Default target: usage [root@disguised python]#
  • 25. prose meets code 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 • given a SLOC of 3600, documentation became a necessisty • opted for sphinx • created UML diagrams with pyreverse which is part of the pylint package • added ant target docs
  • 26. prose meets code 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 <target name="docs" description="generate sphinx documentation, including pylint and pyreverse output" depends="clean"> <!-- create sphinx-apidoc --> <exec executable="${python.binpath}/sphinx-apidoc"> <arg value="-f" /> <arg value="-o" /> <arg value="${doc.sphinx.source.dir}" /> <arg value="${package.dir}" /> </exec> <!-- creating UML diagrams --> <exec executable="${python}" > <arg value="builduml.py" /> </exec> <!-- render html docu --> <exec executable="/usr/bin/make"> <env key="LD_LIBRARY_PATH" path="/opt/oracle/product/12.2.0.1/instantclient" /> <arg value="html" /> </exec>
  • 27. prose meets code 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 <!-- create pylint output --> <mkdir dir="${doc.pylint.dir}" /> <echo message="writing pylint's output to ${doc.pylint.dir}/packages_pylint.txt" /> <exec executable="${pylint}" dir="${package.dir}" output="${doc.pylint.dir}/packages_pylint.txt" > <arg value="--rcfile=pylint.rc" /> <arg value="-f" /> <arg value="text" /> <arg value="rlb" /> </exec> <!-- deploy documentation --> <delete> <fileset dir="${doc.deploy.dir}" includes="**/*.*" /> </delete> <echo message="deploying docu to ${doc.deploy.dir} ..." /> <copy todir="${doc.deploy.dir}"> <fileset dir="${doc.sphinx.build.dir}/html"> <include name="**/*" /> </fileset> </copy> </target>
  • 30. a giant leap towards CI 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 • functionality shared by all modules has been refactored into the common sub package • breaking functionality within the common sub package results in breaking the whole code base • unit tests absolutely vital • additional sub package with suffix ut • one test file for each module, prefixed with test_
  • 31. a giant leap towards CI 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 [root@disguised rlb]# find common* -name '*.py' common/os.py common/template.py common/__init__.py common/oradb.py common/massdeploy.py commonut/test_oradb.py commonut/__init__.py commonut/test_template.py commonut/test_os.py commonut/test_massdeploy.py [root@disguised rlb]#
  • 32. a giant leap towards CI 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 • version control, ant build and unit tests have been implemented • which sets the stage for a decent jenkins installation • Subversion plugin for obvious reasons • Cobertura plugin aimed at automatic unit tests • SLOCCount plugin in case somebody asks • Violations plugin since pylint reports are already in place • Static analysis collector plugin-in as a dependency
  • 33. a giant leap towards CI 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 disguised:/root/svnRepo/scripts/python>cat requirements_test.txt astroid>=1.5.3 autopep8>=1.3.2 coverage>=4.4.1 idna>=2.1 isort>=4.2.5 lazy_object_proxy>=1.2.2 logilab_common>=1.3.0 mccabe>=0.5.2 pep8>=1.7.0 py>=1.4.34 pyenchant>=1.6.8 pygount>=0.9 pylint>=1.7.2 pytest>=3.2.1 pytest-cov>=2.5.1 sphinx_pyreverse>=0.0.12 wrapt>=1.10.8 Pygments>=2.2
  • 34. a giant leap towards CI 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 <target name="code-metrics" description="gather code metrics"> <!-- obtain source code lines by using pygount --> <echo message="writing pygount's output to cloc.xml" /> <exec executable="${pygount}" dir="../.."> <arg value="--format=cloc-xml" /> <arg value="--suffix=py,sh,sql,xml,pks,pkb,php,java" /> <arg value="--out=cloc.xml" /> </exec> <!-- assess code quality with pylint --> . . <!-- evaluate code quality with pep8 --> <echo message="writing pep8's output to pep8.out" /> <exec executable="${pep8}" dir="${package.dir}" output="../../pep8.out"> <arg value="--filename=*.py" /> <arg value="--max-line-length=99" /> <arg value="." /> </exec> </target>
  • 35. a giant leap towards CI 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 disguised:/root/svnRepo/scripts/python>ant -p Buildfile: /root/svnRepo/scripts/python/build.xml Build and deploy rlb's pyhton modules Main targets: all build wheel and documentation clean clean up all files created by either dist or docs target code-metrics gather code metrics dist build wheel distclean clean up files created by the dist target docs generate sphinx documentation, including pylint and pyreverse output install install wheel on this host jenkins build targets required by continuous integration Default target: usage disguised:/root/svnRepo/scripts/python> <target name="jenkins" description="build targets required by continuous integration" depends="clean, code-metrics, dist" />
  • 36. a giant leap towards CI 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17
  • 37. a giant leap towards CI 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17
  • 38. a giant leap towards CI 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17
  • 39. a bit quality 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 • given that jenkins and unit tests are in place, test automatisation appears to be quite obvious • isolated build by means of venv • documented required modules, which comes in handy when upgrading/installing python • run test suite by means of pytest • added coverage reports
  • 40. a bit quality 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 <target name="test" description="run test suite" depends="venv"> <exec executable="${venv.python}" failonerror="true"> <arg value="setup.py" /> <arg value="install" /> </exec> <exec executable="/home/jenkins/scripts/pre_unittest.sh" /> <exec executable="${venv.pytest}"> <!-- No failonerror="true" because on failed tests, pytest exits with 1. --> <env key="LD_LIBRARY_PATH" path="/opt/oracle/product/12.2.0.1/instantclient" /> <arg value="--junit-xml=unittest.xml" /> <arg value="--cov=${package.dir}" /> <arg value="--cov-report=html" /> <arg value="--cov-report=xml" /> <arg value="--ignore=${venv.dir}" /> <arg value="--ignore=./rlb/commonut/test_cp1252_encoding.txt" /> <arg file="${package.dir}" /> </exec> <exec executable="/home/jenkins/scripts/post_unittest.sh" /> </target>
  • 43. a bit quality 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 • complete test coverage would imply a dedicated exadata environment • a case for unittest.mock • as a precondition Exadata/database related calls need to be separated, which has not been considered in the initial design • might be subject to another talk • however, the foundations are laid • played a vital role during the upgrade vom python 3.5 to 3.6
  • 44. the finishing touch 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 • due to stringent security policies no access to pypi.python.org • has been circumvented by using pip install http://... • however, resolving dependencies appeared to be a bit tedious • so pypiserver it is • enables continous deployment
  • 46. the finishing touch 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 disguised:/root/svnRepo/scripts/python>ant -p Buildfile: /root/svnRepo/scripts/python/build.xml Build and deploy rlb's pyhton modules Main targets: all build wheel and documentation clean clean up all files created by either dist or docs target code-metrics gather code metrics deploy install wheel on production hosts dist build wheel distclean clean up files created by the dist target docs generate sphinx documentation, including pylint and pyreverse output install install wheel on this host jenkins build targets required by continuous integration test run test suite venv setup virtual Python environment Default target: usage disguised:/root/svnRepo/scripts/python>
  • 47. where do we go now? 07/14 07/15 09/15 02/16 05/16 07/16 10/16 11/16 01/17 03/17 07/17 • deal with testing issues • become proactive by forecasting capacity and load with appropriate models • tweak pylint/pep8 • improve on documentation