Post on 23-Jan-2018
BASLE BERN BRUGG DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. GENEVA
HAMBURG COPENHAGEN LAUSANNE MUNICH STUTTGART VIENNA ZURICH
With the CLI through the Oracle Cloud Or: Why only Dummies use the Web Interface
Martin Berger
KESTENHOLZ
martinberger_ch
www. martinberger.com
About me
With the CLI through the Oracle Cloud
Martin Berger – 4703 Kestenholz / Jurasüdfuss / Switzerland / non-EU
Senior Consultant – @Trivadis AG Bern
2 Junior DBAs, Firefighter / Firefighter Trainer
Trainer for Trivadis Architecture and Cloud Trainings
martinberger_ch
www. martinberger.com
Agenda
With the CLI through the Oracle Cloud
1. Welcome...
2. CLI Tool 1-n
3. Summary
With the CLI through the Oracle Cloud
Welcome...
With the CLI through the Oracle Cloud
The oracle-dbcs-cli Utility
PaaS Service Manager Command Line Interface
Oracle Public Cloud Command-Line Interface (opccli)
Oracle Public Cloud - Compute Cloud Service - opc-init utility
REST APIdbaascli
raccli
dbpatchmdg
The Oracle Public Cloud Jungle
With the CLI through the Oracle Cloud
8 Tools which are doing almost the same job:
– Create, manage and delete Oracle Public Cloud Instances
– Lifecyle Management
– Access Control
– Backup ad recovery
Now let’s take a look how we find out of that Jungle..
With the CLI through the Oracle Cloud
The oracle-dbcs-cli Utility
Overview
With the CLI through the Oracle Cloud
Oracle Database Service
Linux based CLI utility for the Oracle Cloud
Perform lifecycle and administration operations
Can use templates
Easy to handle
Where to get the oracle-dbcs-cli Utility
With the CLI through the Oracle Cloud
The tool is available on the Oracle Technology Network
– http://www.oracle.com/technetwork/database/database-
cloud/public/downloads/index.html
Not really up to date… but it works
Do not use the tool in a program to manufacture nuclerar, chemical or bilological
weapons of mass destruction…
Installation
With the CLI through the Oracle Cloud
oracle@neuendorf:/u01/app/oracle/cloud/ [rdbms12201] ll
total 6184
drwxr-xr-x. 2 oracle oinstall 4096 Sep 7 22:07 .
drwxr-xr-x. 13 oracle oinstall 4096 Sep 7 22:06 ..
lrwxrwxrwx. 1 oracle oinstall 16 Oct 17 2015 dboplan.dat.external.tmpl ->
dboplan.dat.tmpl
-r-xr-xr-x. 1 oracle oinstall 6556 Oct 16 2015 dboplan.dat.tmpl
-rw-r--r--. 1 oracle oinstall 3329598 Oct 17 2015 dborch.jar
-r-xr-xr-x. 1 oracle oinstall 11372 Jun 29 2015 oracle-dbcs-cli
-rw-r--r--. 1 oracle oinstall 2964193 Sep 7 22:07 oracle-dbcs-cli_15.4.2.tar.gz
-r-xr-xr-x. 1 oracle oinstall 6438 Jun 10 2015 readme.txt
Content of tar xvfz oracle-dbcs-cli_15.4.2.tar.gz
Template
With the CLI through the Oracle Cloud
#-------------------------------------------------------------------------------
# Specify the SM related info
#-------------------------------------------------------------------------------
sm_url= https://dbcs.emea.oraclecloud.com/paas/service/dbcs/api/v1.1/instances
user_name= martin.berger@trivadis.com
password= Ben2014Tim2012
identity_domain= a420942
subscriptionType= hourly
The file dboplan.dat.tmpl is a template for all oracle-dbcs-cli functions
It is the base for the orchestration in the background
Java Error
With the CLI through the Oracle Cloud
lrwxrwxrwx. 1 root root 22 Apr 27 06:24 /usr/bin/java -> /etc/alternatives/java
root@neuendorf:/usr/bin/ [rdbms12201] mv java java_orig
root@neuendorf:/usr/bin/ [rdbms12201] ln -s
/u01/app/oracle/product/jdk1.8.0_131/bin/java
Solution: install JDK (and relink it)
oracle@neuendorf:/u01/app/oracle/cloud/ [rdbms12201] ./oracle-dbcs-cli
Error: Could not get java version.
The OL7 included Java (OpenJDK) is not accepted
Status of my Identity Domain
With the CLI through the Oracle Cloud
$ ./oracle-dbcs-cli list -cfg opc_a420942_db01.tmpl
Database Cloud Orchestration Tool:Release 2.0.289.15.52 on Sun Sep 10
19:19:38 CEST 2017
Copyright ©2014,2015, Oracle. All rights reserved.
OPCSE01
OCPUs: 1
Version: 12.2.0.1 Date Created: 2017-09-
10T15:17:48.838+0000 Memory: 7.5 GB
Edition: Standard Edition
DBOrch execution ended.
The connection configuration is in the file
With the CLI through the Oracle Cloud
PaaS Service Manager Command
Line Interface (psm)
Overview
With the CLI through the Oracle Cloud
A PaaS REST API Wrapper
Oracle Java Cloud Service
Oracle Database Cloud Service instances
Oracle MySQL Cloud Service
Oracle Application Container Cloud Service
Prerequisites
With the CLI through the Oracle Cloud
# curl -O https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz
# tar xfz Python-3.5.0.tgz
# cd Python-3.5.0
# ./configure --prefix=/u01/python
# make
# make install
Python 3.5 or later – btw, PSM work on Windows
– openssl-devel & gcc
root@neuendorf:/u01/app/oracle/cloud/oracle-dbcs-cli/ [rdbms12201] curl --version
curl 7.29.0 (x86_64-redhat-linux-gnu)
cURL command-line tool.
Download via Account
With the CLI through the Oracle Cloud
oracle@neuendorf:/u01/app/oracle/cloud/psmcli/psmcli-1.1.16/ [rdbms12201] ll
drwxr-xr-x. 4 oracle oinstall 4096 Sep 7 23:05 opaascli
-rwxr-xr-x. 1 oracle oinstall 870 Aug 21 18:46 psm
-rw-r--r--. 1 oracle oinstall 1300 Aug 21 18:46 psm.cmd
-rw-r--r--. 1 oracle oinstall 82 Aug 21 18:48 setup.cfg
-rwxr-xr-x. 1 oracle oinstall 1662 Aug 21 18:46 setup.py
Content of the file
$ curl -X GET -u martin.berger@trivadis.com:Tim12#Ben14 -H X-ID-TENANT-NAME:a420942
https://psm.europe.oraclecloud.com/paas/core/api/v1.1/cli/a420942/client -o
psmcli.zip
Example curl
Download via Dashboard
With the CLI through the Oracle Cloud
PIP
With the CLI through the Oracle Cloud
[root@neuendorf psmcli]# psm --version
PSM CLI Client - version 1.1.16
Verification
root@neuendorf:/u01/app/oracle/cloud/psmcli/ [rdbms12201] pip3
install -U psmcli.zip
The PaaS CLI is a Python package
Installation has to be done as OS user root
PSM Setup
With the CLI through the Oracle Cloud
[root@neuendorf ~]# psm setup
Username: martin.berger@trivadis.com
Password:
Retype Password:
Identity domain: a420942
Region [us]: emea
Output format [short]:
----------------------------------------------------
'psm setup' was successful. Available services are:
...
o dbcs : Oracle Database Cloud Service
...
----------------------------------------------------
Help
With the CLI through the Oracle Cloud
[root@neuendorf ~]# psm dbcs create-service help
DESCRIPTIONCreate an Oracle Database Cloud Service instance
SYNOPSISpsm dbcs create-service [parameters]
-c, --config-payload <value>[-of, --output-format <value>]
AVAILABLE PARAMETERS-c, --config-payload (file)
Path to JSON file containing Oracle Database Cloud Service provisioningconfiguration parameters
-of, --output-format (string)Desired output format. Valid values are [short, json, html]
EXAMPLESpsm dbcs create-service -c /home/templates/create-dbcs-service.json
Detailled description of the possibilities
Create Service
With the CLI through the Oracle Cloud
[root@neuendorf ~]# psm dbcs create-service --config-payload
create_db12c-ee.json
Job ID : 7588836
[root@neuendorf ~]# psm dbcs services
Service Status
db12c-ee In Progress
The JSON file contains the database service specification
Statusanzeige
With the CLI through the Oracle Cloud
[root@neuendorf ~]# psm dbcs service --service-name db12c-ee
Service: db12c-ee
Status: In Progress
Version: 12.1.0.2
Edition: EE
Shape: oc3
Connect String: N/A
Backup Destination: NONE
Cloud Storage Container: N/A
PDB Name: PDB1
Created On: 2017-09-07T21:50:46.053+0000
psm dbcs service --service-name
Start / Stop / Recover
With the CLI through the Oracle Cloud
$ psm dbcs recover --service-name db12c-ee --config-payload
recover.json
Database Recovery – the JSON file contains the RMAN backup
{
"tag" : "TAG20160719T230330"
}
$ psm dbcs start --service-name db12c-ee
$ psm dbcs stop --service-name db12c-ee
Start / Stop
Restore
With the CLI through the Oracle Cloud
$ psm dbcs recover --service-name db12c-ee --config-payload
recover.json
Database Recovery – the JSON file contains the RMAN backup tag
{
"tag" : "TAG20160719T230330"
}
$ psm dbcs view-backups --service-name db12c-ee
Get list of backups
With the CLI through the Oracle Cloud
REST API
Overview
With the CLI through the Oracle Cloud
For all Oracle Cloud Services
REST stands for Representational State Transfer, API means Application
Programming Interface, a stateless, client-server, cacheable communications
protocol - and in virtually all cases, the HTTP protocol is used
Example: Supported Methods for the Oracle Database Cloud Service
Method Description
DELETE Delete a Database Cloud Service instance.
GET Retrieve information about all Database Cloud Service instances, a specific instance, or
an operation affecting an instance.
POST Create, stop, start or restart a Database Cloud Service instance.
PUT Scale a Database Cloud Service instance.
Create an Instance
With the CLI through the Oracle Cloud
oracle@neuendorf:/u01/app/oracle/cloud/curl/ [rdbms12201] curl
--include --request POST --user
martin.berger@trivadis.com:Tim12#Ben14 --header "X-ID-TENANT-
NAME:a420942" --header "Content-Type:application/json" --data
@create_db12c-se.json
https://dbcs.emea.oraclecloud.com/paas/service/dbcs/api/v1.1/in
stances/a420942
HTTP/1.1 202 Accepted
The JSON File containst the database configuration (Shape, Storage, Editions etc.)
REST
With the CLI through the Oracle Cloud
oracle@neuendorf:/u01/app/oracle/cloud/curl/ [rdbms12201] curl -s --include --
request GET --cacert /u01/app/oracle/cloud/curl/cacert.pem --user
martin.berger@trivadis.com:Tim12#Ben14 --header "X-ID-TENANT-NAME:a420942"
https://dbcs.emea.oraclecloud.com/paas/service/dbcs/api/v1.1/instances/a420942
...
{"uri":"https:\/\/dbcs.emea.oraclecloud.com:443\/paas\/service\/dbcs\/api\/v1.1
\/instances\/a420942","service_type":"dbaas","implementation_version":"1.0","se
rvices":[{"service_name":"db12c-ee","version":"12.1.0.2","status":"In
Progress","description":"db12c-
ee","identity_domain":"a420942","creation_time":"2017-09-
07T21:50:46.053+0000","last_modified_time":"2017-09-
07T21:50:45.987+0000","created_by":"martin.berger@trivadis.com","sm_plugin_vers
ion":"17.3.5-539","tools_version":"17.3.5-
539","service_uri":"https:\/\/dbcs.emea.oraclecloud.com:443\/paas\/service\/dbc
s\/api\/v1.1\/instances\/a420942\/db12c-ee"}],"subscriptions":[]}
Verify Status
Rest Interaction – LaMetric
With the CLI through the Oracle Cloud
With the CLI through the Oracle Cloud
Oracle Public Cloud Command-Line
Interface (opccli)
Overview
With the CLI through the Oracle Cloud
Oracle Compute Cloud
Manager Compute, Storage and Network Services
Relationships between the Compute Cloud Resources
With the CLI through the Oracle Cloud
Download
With the CLI through the Oracle Cloud
oracle@neuendorf:/u01/app/oracle/cloud/iaas/ [rdbms12201] ll
total 10120
drwxr-xr-x. 3 oracle oinstall 4096 Sep 8 20:31 .
drwxr-xr-x. 6 oracle oinstall 63 Sep 8 00:12 ..
-rw-r--r--. 1 oracle oinstall 5053 May 24 23:23 README.txt
drwxr-xr-x. 2 oracle oinstall 16 May 11 22:07 linux
-rw-r--r--. 1 oracle oinstall 2876448 May 17 17:12 opc-cli-17.2.2.x86_64.rpm
-rw-r--r--. 1 oracle oinstall 7464541 Sep 8 20:31 opc-cli.17.2.2.zip
-rw-------. 1 oracle oinstall 250 May 24 23:24 sample-profile
http://www.oracle.com/technetwork/topics/cloud/downloads/index.html#opccli
Installation
With the CLI through the Oracle Cloud
$ yum install -y ./opc-cli-17.2.2.x86_64.rpm
…
Installed:
opc-cli.x86_64 0:17.2.2-1
Complete!
Install the rpm manually – example for OL7
Configuration
With the CLI through the Oracle Cloud
$ vi profile-a425046
> add proile data here
$ chmod 600 profile-a425046
You have to create a profile file with the OPC account details and set permission to
600
$ vi my_opc_password.txt
> add password here
$ chmod 600 my_opc_password.tx
You have to store your OPC account password in a file and set permission to 600
Profile File
With the CLI through the Oracle Cloud
{
"global": {
"format": "text",
"debug-requests": false
},
"compute": {
"user": "/Compute-a425046/martin.berger@trivadis.com",
"password-file":
"/u01/app/oracle/cloud/iaas/opc/my_opc_password.txt",
"endpoint": "api-z16.compute.em2.oraclecloud.com"
}
}
It contains the connect information and the endpoint URL
Create a Disk - Example
With the CLI through the Oracle Cloud
$ opc compute storage-volumes add /Compute-
a425046/martin.berger@trivadis.com/MyVolume /oracle/public/storage/default 10G
--description 'My first storage volume'
…
snapshot_account
status Initializing
status_detail The storage volume is currently being initialized.
status_timestamp 2017-09-08T18:46:44Z
storage_pool
…
One disk a 10GB will be created
Verification
With the CLI through the Oracle Cloud
List available Images
With the CLI through the Oracle Cloud
oracle@neuendorf:/u01/app/oracle/cloud/iaas/opc/ [rdbms12201] opc -f table compute image-lists get
/oracle/public/OL_7.2_UEKR4_x86_64
+-------------------------+-------------------------------------------------------------------------------------------------+
default | 1
description | Oracle Linux 7.2 UEKR4 x86_64
| (64 bit)
entries/0/imagelist |
entries/0/machineimages | ["/oracle/public/OL_7.2_UEKR4_x86_64-17.2.2-20170405-211209"]
entries/0/uri | https://api-z16.compute.em2.oraclecloud.com/imagelist/oracle/public/OL_7.2_UEKR4_x86_64/entry/1
entries/0/version | 1
name | /oracle/public/OL_7.2_UEKR4_x86_64
uri | https://api-z16.compute.em2.oraclecloud.com/imagelist/oracle/public/OL_7.2_UEKR4_x86_64
+-------------------------+-------------------------------------------------------------------------------------------------+
Show image detail
Available Shapes
With the CLI through the Oracle Cloud
oracle@neuendorf:/u01/app/oracle/cloud/iaas/opc/ [rdbms12201] opc -f table -F name,ram
compute shapes list
+------+--------+
NAME | RAM
+------+--------+
oc4m | 122880
oc7 | 122880
oc3m | 61440
oc5m | 245760
oc3 | 7680
oc5 | 30720
oc4 | 15360
oc1m | 15360
oc2m | 30720
oc6 | 61440
+------+--------+
List all OPC Shapes
The Way to a new Compute Cloud Instance
With the CLI through the Oracle Cloud
1. Add SSH Key
2. Add Storage
3. Add Boot Disk
4. (Add Seclist)
5. Reserve IP
6. Create Orchestration File
7. Upload Orchestration
8. Start Orchestration
9. Monitor
Orchestration V2
With the CLI through the Oracle Cloud
https://docs.oracle.com/en/cloud/iaas/compute-iaas-cloud/stcsg/building-your-first-
orchestration-v2.html
You can define all your cloud resources in a single orchestration and manage the
resources individually
With the CLI through the Oracle Cloud
Oracle Public Cloud - Compute
Cloud Service - opc-init utility
(opcinit)
Overview
With the CLI through the Oracle Cloud
Oracle Compute Cloud Service
Automated instance initializing
Works with Chef-Solo
Brings you the full stack of provisiong like build and instance & configure the
webserver
Download
With the CLI through the Oracle Cloud
root@neuendorf:/u01/app/oracle/cloud/iaas/opcinit/ [rdbms12201] ll
total 300
-rw-r--r--. 1 oracle oinstall 138465 Sep 10 20:40 opc-init-16.4.2.zip
-rw-r--r--. 1 oracle oinstall 80472 Oct 20 2016 opc-init-py2.6-16.4.2.noarch.rpm
-rw-r--r--. 1 oracle oinstall 80124 Oct 20 2016 opc-init-py2.7-16.4.2.noarch.rpm
-rw-r--r--. 1 oracle oinstall 1449 Oct 20 2016 README
http://www.oracle.com/technetwork/topics/cloud/downloads/opc-init-3096035.html
Installation
With the CLI through the Oracle Cloud
$ yum install -y ./opc-init-py2.7-16.4.2.noarch.rpm
…
Installed:
opc-init-py2.7.noarch 0:16.4.2-1
Complete!
Install the rpm manually – example for OL7
Other settings are according opccli
With the CLI through the Oracle Cloud
dbaascli
Overview
With the CLI through the Oracle Cloud
Oracle Database Service
dbaascli is the CLI which is provided within the Oracle Database Service instances
It has several functions like
– database start/stop
– Listener start/stop
– Patch verficiation and apply
– Backup and restore
dbaascli commands are executed as OS user root
[opc@OPCSE01 ~]$ sudo su -
[root@OPCSE01 ~]#
Some Examples (1)
With the CLI through the Oracle Cloud
[root@OPCSE01 ~]# dbaascli dbpatchm --run -list_patches
List patches
[root@OPCSE01 ~]# dbaascli database bounce
Bounce the database
Some Examples (2)
With the CLI through the Oracle Cloud
[root@OPCSE01 ~]# dbaascli netsec status encryption
Displaying configuration for network encryption:
server encryption status: [enabled]type = requiredmethods = AES256,AES192,AES128
Verify security settings
Some Examples – Data Guard
With the CLI through the Oracle Cloud
[root@OPCEE01-dg01 ~]# dbaascli dataguard switchover
Data Guard Switchover
[root@OPCEE01-dg01 ~]# dbaascli dataguard status
SUCCESS : Dataguard is up and running
Data Guard Status
[root@OPCEE01-dg01 ~]# dbaascli dataguard failover
Data Guard Failover
With the CLI through the Oracle Cloud
Other CLIs
raccli
With the CLI through the Oracle Cloud
Oracle Database Service
raccli is the CLI which is provided within the Oracle Database Service instances with
Real Application Cluster RAC (EE & Extreme Performance)
Database backup, database recovery, backup configuration change
Patching the Oracle Database, Grid Infrastructure and cloud tooling software
Security features changes
dbpatchmdg
With the CLI through the Oracle Cloud
Oracle Database Service
For patching Oracle Data Guard environments
– List patches
– Readiness check
– Apply patches
– Rollback patches
With the CLI through the Oracle Cloud
Summary
Finally...
With the CLI through the Oracle Cloud
There are a lot of tools
They do almost the same, on-premises or in the cloud
MERCI VÖUMOUTrivadis AG
Martin Berger
Senior Consultant
martin.berger@trivadis.com
With the CLI through the Oracle Cloud