DBA
Oracle Database
2016.09.12 - JPOUG in 15 minutes #1
Michitoshi Yoshida
(@miyosh0008)
• (@miyosh0008)
• Engineered Systems
Exadata, Exalogic, Exalytics, etc..
• 

etc..
Oracle Database
DB
+ RAC
+ PDB
Oracle DB
1.
2.
3.
4.
•
Chef
-
-
- Recipe Ruby
Puppet
- 2005
- Chef
- Puppet Enterprise
•
Ansible
- Python 2.4
- YAML
- 2015 RedHat
Itamae
- Chef
- Chef Ruby
-
• 

Serverspec
-
- RSpec Ruby
-
Testinfra
- Serverspec Python
- pytest Python
- Serverspec
• 

Infrataster
- Serverspec RSpec
-
: WEB URL HTTP
200 etc..
- Serverspec
1.
2.
Ansible Galaxy
→ Ansible
Python
SSH OK
3.
→ alter
ShellScript OK Ansible
#
: Hello,module! 15 Ansible Bash
4.
→ OS Serverspec 

SQL
SQL
Infrataster
→
Infrataster-plugin-oracledb
• 



• 

- 

- REDO 

- SQL
Infrataster-plugin-oracledb
• Infrataster Gem 

gem bundler 

# 

# m(_ _)m
# zip
$ unzip /tmp/instantclient-basic-linux.x64-12.1.0.2.0.zip -d /opt/
oracle/instantclient/
$ unzip /tmp/instantclient-sdk-linux.x64-12.1.0.2.0.zip -d /opt/
oracle/instantclient/
#
$ cd /opt/oracle/instantclient/instantclient_12_1
$ ln -s libclntsh.so.12.1 libclntsh.so
$ ln -s libocci.so.12.1 libocci.so
$ echo "/opt/oracle/instantclient/instantclient_12_1" >/etc/
ld.so.conf.d/oracle.conf
# .bash_profile
export ORACLE_HOME=/opt/oracle/instantclient/instantclient_12_1
export LD_LIBRARY_PATH=$ORACLE_HOME
Step1: Oracle Instant Client
Basic SDK
#
$ mkdir oracle_test
$ cd oracle_test
# Gemfile
$ cat Gemfile
source 'https://rubygems.org'
gem 'infrataster'
gem ‘infrataster-plugin-oracledb'
#
# : ruby bundler
$ bundle install
$ bundle show | grep infrataster
* infrataster (0.3.2)
* infrataster-plugin-oracledb (0.1.0) # ← OK
Step2: infrataster infrataster-plugin-
oracledb
# spec
$ cp -r $(bundle show infrataster-plugin-oracledb)/spec ./
# spec_helper.rb
$ vi spec/spec_helper.rb
# spec_helper.rb
... ...
Infrataster::Server.define(
:orcl, # ←
‘192.168.56.101', # ←
oracledb: { user: 'system', password: 'oracle',
service_name: 'orcl'},
)
... ...
Step3:
# oracledb_query_spec.rb
$ vi spec/oracledb_query_spec.rb
# oracledb_query_spec.rb
# coding: utf-8
require 'spec_helper'
describe server(:orcl) do
describe oracledb_query('select name,display_value from v
$parameter') do
# check db_block_size
it "initialization parameter 'db_block_size' should equal 8192" do
row = results.find { |r| r['NAME'] == 'db_block_size' }
expect(row['DISPLAY_VALUE'].to_i).to eq 8192
end
end
end
Step4:
: db_block_size 8192
$ bundle exec rspec
Warning: NLS_LANG is not set. fallback to US7ASCII.
Run options: include {:focus=>true}
All examples were filtered out; ignoring {:focus=>true}
Randomized with seed 28464
.
Finished in 0.06133 seconds (files took 0.4652 seconds to load)
1 example, 0 failures
Randomized with seed 28464
Step5:
1 0
# .rspec
$ cat .rspec
--color
--format documentation
$ export NLS_LANG=JAPANESE_JAPAN.AL32UTF8
$ bundle exec rspec
... ...
server 'orcl'
oracledb_query 'select name,display_value from v$parameter'
initialization parameter 'db_block_size' should equal 8192
Finished in 0.0545 seconds (files took 0.41626 seconds to load)
1 example, 0 failures
... ...
Step6:
RSpec

DBA だってもっと効率化したい!〜最近の自動化事情とOracle Database〜

  • 1.
    DBA Oracle Database 2016.09.12 -JPOUG in 15 minutes #1 Michitoshi Yoshida (@miyosh0008)
  • 2.
    • (@miyosh0008) • EngineeredSystems Exadata, Exalogic, Exalytics, etc.. • 
 etc..
  • 4.
  • 5.
  • 6.
  • 8.
  • 9.
    • Chef - - - Recipe Ruby Puppet -2005 - Chef - Puppet Enterprise
  • 10.
    • Ansible - Python 2.4 -YAML - 2015 RedHat Itamae - Chef - Chef Ruby -
  • 11.
    • 
 Serverspec - - RSpecRuby - Testinfra - Serverspec Python - pytest Python - Serverspec
  • 12.
    • 
 Infrataster - ServerspecRSpec - : WEB URL HTTP 200 etc.. - Serverspec
  • 13.
  • 14.
    3. → alter ShellScript OKAnsible # : Hello,module! 15 Ansible Bash
  • 15.
    4. → OS Serverspec
 SQL SQL Infrataster →
  • 16.
  • 17.
    Infrataster-plugin-oracledb • Infrataster Gem
 gem bundler 
 # 
 # m(_ _)m
  • 20.
    # zip $ unzip/tmp/instantclient-basic-linux.x64-12.1.0.2.0.zip -d /opt/ oracle/instantclient/ $ unzip /tmp/instantclient-sdk-linux.x64-12.1.0.2.0.zip -d /opt/ oracle/instantclient/ # $ cd /opt/oracle/instantclient/instantclient_12_1 $ ln -s libclntsh.so.12.1 libclntsh.so $ ln -s libocci.so.12.1 libocci.so $ echo "/opt/oracle/instantclient/instantclient_12_1" >/etc/ ld.so.conf.d/oracle.conf # .bash_profile export ORACLE_HOME=/opt/oracle/instantclient/instantclient_12_1 export LD_LIBRARY_PATH=$ORACLE_HOME Step1: Oracle Instant Client Basic SDK
  • 21.
    # $ mkdir oracle_test $cd oracle_test # Gemfile $ cat Gemfile source 'https://rubygems.org' gem 'infrataster' gem ‘infrataster-plugin-oracledb' # # : ruby bundler $ bundle install $ bundle show | grep infrataster * infrataster (0.3.2) * infrataster-plugin-oracledb (0.1.0) # ← OK Step2: infrataster infrataster-plugin- oracledb
  • 22.
    # spec $ cp-r $(bundle show infrataster-plugin-oracledb)/spec ./ # spec_helper.rb $ vi spec/spec_helper.rb # spec_helper.rb ... ... Infrataster::Server.define( :orcl, # ← ‘192.168.56.101', # ← oracledb: { user: 'system', password: 'oracle', service_name: 'orcl'}, ) ... ... Step3:
  • 23.
    # oracledb_query_spec.rb $ vispec/oracledb_query_spec.rb # oracledb_query_spec.rb # coding: utf-8 require 'spec_helper' describe server(:orcl) do describe oracledb_query('select name,display_value from v $parameter') do # check db_block_size it "initialization parameter 'db_block_size' should equal 8192" do row = results.find { |r| r['NAME'] == 'db_block_size' } expect(row['DISPLAY_VALUE'].to_i).to eq 8192 end end end Step4: : db_block_size 8192
  • 24.
    $ bundle execrspec Warning: NLS_LANG is not set. fallback to US7ASCII. Run options: include {:focus=>true} All examples were filtered out; ignoring {:focus=>true} Randomized with seed 28464 . Finished in 0.06133 seconds (files took 0.4652 seconds to load) 1 example, 0 failures Randomized with seed 28464 Step5: 1 0
  • 25.
    # .rspec $ cat.rspec --color --format documentation $ export NLS_LANG=JAPANESE_JAPAN.AL32UTF8 $ bundle exec rspec ... ... server 'orcl' oracledb_query 'select name,display_value from v$parameter' initialization parameter 'db_block_size' should equal 8192 Finished in 0.0545 seconds (files took 0.41626 seconds to load) 1 example, 0 failures ... ... Step6: RSpec