Oracle Autonomous Database and DevOps: A Simple Approach to Utilization - Part 5

This article is the fifth and final part of the Oracle Autonomous Database and DevOps article series. For a better understanding, I recommend to read the articles “Oracle Autonomous Database and DevOps: A Simple Approach to Use – Part 1”, “Part 2”, “Part 3” and “Part 4” before proceeding with the steps in this article.

 

As the previous article dealt with the creation of the Linux application server within Oracle Cloud, in this article we will proceed with the creation of microservices using Docker and connecting a JAVA application to the cloud database. To start let’s get some concepts:

 

 

What are microservices?

 

According to Chris Richardson, “is a style of architecture that structures an application as a collection of services that are:

 

  • Highly sustainable and testable
  • Frankly coupled
  • Independently deployable
  • Organized around business resources. ”
 
What is node.js?

 

According to the manufacturer’s official website, “Node.js is an open source, cross-platform JavaScript execution environment.”

 

PS: This article will not show the coding of the application, but only the loading of it.

 

Now that we have a brief description of micricroservices and node.js, let’s proceed with the creation of our microservices:
 
 
Creating node.js microservices: Make sure Docker is running on your machine (For more information on Docker see the first article of this series):

 

[root@techdatatechdatabasketblogblog /]# systemctl status  docker
  • docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)

   Active: active (running) since Wed 2019-04-24 20:03:28 CEST; 7s ago

     Docs: http://docs.docker.com

 Main PID: 27946 (dockerd-current)

    Tasks: 20

   CGroup: /system.slice/docker.service

           ├─27946 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=...

           └─27952 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/co...




Apr 24 20:03:27 techdatatechdatabasketblogblog.tech.com dockerd-current[27946]: time="2019-04-24T20:03:27.250219328+02:00" level=warning msg="failed to cleanup ipc mounts:\nfailed to umount /var/lib/docker/co...id argument"

Apr 24 20:03:27 techdatatechdatabasketblogblog.tech.com dockerd-current[27946]: time="2019-04-24T20:03:27.250885514+02:00" level=warning msg="8172d6ebc0303d372883143207467260cd2ea708b300ba23c736b36777be0d3b c...id argument"

Apr 24 20:03:27 techdatatechdatabasketblogblog.tech.com dockerd-current[27946]: time="2019-04-24T20:03:27.350320351+02:00" level=info msg="Firewalld running: true"

Apr 24 20:03:28 techdatatechdatabasketblogblog.tech.com dockerd-current[27946]: time="2019-04-24T20:03:28.063094521+02:00" level=info msg="Removing stale sandbox f98e8fe2671acc61090bbed5f985266ded27adf2e19e27...6777be0d3b)"

Apr 24 20:03:28 techdatatechdatabasketblogblog.tech.com dockerd-current[27946]: time="2019-04-24T20:03:28.466076919+02:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16... IP address"

Apr 24 20:03:28 techdatatechdatabasketblogblog.tech.com dockerd-current[27946]: time="2019-04-24T20:03:28.627644418+02:00" level=info msg="Loading containers: done."

Apr 24 20:03:28 techdatatechdatabasketblogblog.tech.com dockerd-current[27946]: time="2019-04-24T20:03:28.687620173+02:00" level=info msg="Daemon has completed initialization"

Apr 24 20:03:28 techdatatechdatabasketblogblog.tech.com dockerd-current[27946]: time="2019-04-24T20:03:28.687645914+02:00" level=info msg="Docker daemon" commit="8633870/1.13.1" graphdriver=overlay2 version=1.13.1

Apr 24 20:03:28 techdatatechdatabasketblogblog.tech.com dockerd-current[27946]: time="2019-04-24T20:03:28.691636427+02:00" level=info msg="API listen on /var/run/docker.sock"

Apr 24 20:03:28 techdatatechdatabasketblogblog.tech.com systemd[1]: Started Docker Application Container Engine.

 

 

At this moment you can pull your app image at https://github.com  as in the example below:







[root@oc8226237722 /]# git clone https://github.com/brunors/appte.git  ((link will not be available after  this article is published))




Cloning into 'appte'...

remote: Enumerating objects: 1045, done.

remote: Total 1045 (delta 0), reused 0 (delta 0), pack-reused 1045

Receiving objects: 100% (1045/1045), 3.49 MiB | 1.95 MiB/s, done.

Resolving deltas: 100% (173/173), done.




Open the port on your computer for the application to start. As we chose in the previous article will be port 3055:




[root@techdatabasketblog /]# firewall-cmd --zone=public --permanent --add-port=3055/tcp

success

 

 

Install Oracle Client on your computer, you can find it on the OTN website and download it:

 

 

Copy the wallet used in previous articles to create the secure connection to a directory that will be used for the container image:
 
[root@techdatabasketblog wallet_APPtechdatabasket]# unzip /tmp/wallet/Wallet_techdatabasket.zip -d /wallet_APPtechdatabasket/

Archive:  /tmp/wallet/Wallet_techdatabasket.zip

  inflating: /wallet_APPtechdatabasket/cwallet.sso 

  inflating: /wallet_APPtechdatabasket/tnsnames.ora 

  inflating: /wallet_APPtechdatabasket/truststore.jks 

  inflating: /wallet_APPtechdatabasket/ojdbc.properties 

  inflating: /wallet_APPtechdatabasket/sqlnet.ora 

  inflating: /wallet_APPtechdatabasket/ewallet.p12 

  inflating: /wallet_APPtechdatabasket/keystore.jks 

[root@techdatabasketblog wallet_APPtechdatabasket]#


Change the sqlnet.ora values ​​to:

 

WALLET_LOCATION = (SOURCE = (METHOD = file) (METHOD_DATA =

(DIRECTORY=$TNS_ADMIN)))

 

Be in the directory containing the wallet, the Oracle Client and start Docker with the image name (in this article  is appte):

 

$ docker build -t appte   .




Check the image:

 

[root@techdatabasketblog]# docker images -a

REPOSITORY                                      TAG                 IMAGE ID            CREATED             SIZE

<none>                                          <none>              d9369bacadb8        14 minutes ago      562 MB

<none>                                          <none>              d9d8bb9b0d49        14 minutes ago      562 MB

<none>                                          <none>              7e7286d50f76        14 minutes ago      550 MB

<none>                                          <none>              6746bf7618ac        14 minutes ago      173 MB

<none>                                          <none>              6c6022e9f288        14 minutes ago      110 MB

<none>                                          <none>              05c85eda1ac8        14 minutes ago      110 MB

<none>                                          <none>              6c628092a5a8        14 minutes ago      110 MB

<none>                                          <none>              f24dfd98c67a        15 minutes ago      14.9 MB

appte                                           latest              65463ysdbe26       3 weeks ago         171 MB

 

 

Start the image on port 3055 as we chose:

 

docker run -i -p 3055:3055 -t appte  sh

/ #

 

Change your user credentials, password and connection string in the application.

 

Run the server.js script:

 

node server.js &

 

The results will be something like this:

 

appte listening on port 3055




You can see your application in a web browser as http://{SEUIP}:3055

 

 

Now that we have created the  microservices, let’s make a connection of a JAVA application to the ATP:

 

Connect to the provisioned server and as root install java:

 

[root@techdatabasketblog ATPDocker]# ssh [email protected]

Enter passphrase for key '/root/.ssh/id_rsa':

Please login as the user "opc" rather than the user "root".




Connection to 129.146.128.2 closed.

[root@techdatabasketblog ATPDocker]# ssh [email protected]

Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

[root@techdatabasketblog ATPDocker]# ssh [email protected]

Enter passphrase for key '/root/.ssh/id_rsa':

Enter passphrase for key '/root/.ssh/id_rsa':

Last login: Wed Apr 24 19:27:11 2019 from ua-85-226-141-154.bbcust.telenor.se

[opc@vmlinuxmachine ~]$ su - root

[root@vmlinuxmachine ~]#yum install java




 

Loaded plugins: langpacks, ulninfo

ol7_UEKR5                                                                                                                                                                            | 2.5 kB  00:00:00    

ol7_addons                                                                                                                                                                           | 2.5 kB  00:00:00    

ol7_developer                                                                                                                                                                        | 2.5 kB  00:00:00    

ol7_developer_EPEL                                                                                                                                                                   | 2.5 kB  00:00:00    

ol7_ksplice                                                                                                                                                                          | 2.5 kB  00:00:00    

ol7_latest                                                                                                                                                                           | 3.0 kB  00:00:00    

ol7_optional_latest                                                                                                                                                                  | 2.5 kB  00:00:00    

ol7_software_collections                                                                                                                                                             | 2.5 kB  00:00:00    

(1/6): ol7_ksplice/primary_db                                                                                                                                                        | 131 kB  00:00:00    

(2/6): ol7_optional_latest/x86_64/updateinfo                                                                                                                                         | 688 kB  00:00:00    

(3/6): ol7_latest/x86_64/updateinfo                                                                                                                                                  | 899 kB  00:00:00    

(4/6): ol7_developer_EPEL/x86_64/primary_db                                                                                                                                          |  10 MB  00:00:00    

(5/6): ol7_latest/x86_64/primary_db                                                                                                                                                  |  16 MB  00:00:00    

(6/6): ol7_optional_latest/x86_64/primary_db                                                                                                                                         | 3.5 MB  00:00:00    

Resolving Dependencies

--> Running transaction check












Installed:

  java-1.8.0-openjdk.x86_64 1:1.8.0.212.b04-0.el7_6                                                                                                                                                         




Dependency Installed:

  alsa-lib.x86_64 0:1.1.6-2.el7                 atk.x86_64 0:2.28.1-1.el7                         avahi-libs.x86_64 0:0.6.31-19.el7                             cairo.x86_64 0:1.15.12-3.el7               

  copy-jdk-configs.noarch 0:3.3-10.el7_5        cups-libs.x86_64 1:1.6.3-35.el7                   dejavu-fonts-common.noarch 0:2.33-6.el7                       dejavu-sans-fonts.noarch 0:2.33-6.el7      

  fontconfig.x86_64 0:2.13.0-4.3.el7            fribidi.x86_64 0:1.0.2-1.el7                      gdk-pixbuf2.x86_64 0:2.36.12-3.el7                            giflib.x86_64 0:4.1.6-9.el7                

  graphite2.x86_64 0:1.3.10-1.el7_3             gtk-update-icon-cache.x86_64 0:3.22.30-3.el7      gtk2.x86_64 0:2.24.31-1.el7                                   harfbuzz.x86_64 0:1.7.5-2.el7              

  hicolor-icon-theme.noarch 0:0.12-7.el7        jasper-libs.x86_64 0:1.900.1-33.el7               java-1.8.0-openjdk-headless.x86_64 1:1.8.0.212.b04-0.el7_6    javapackages-tools.noarch 0:3.4.1-11.el7   

  jbigkit-libs.x86_64 0:2.0-11.el7              libICE.x86_64 0:1.0.9-9.el7                       libSM.x86_64 0:1.2.2-2.el7                                    libX11.x86_64 0:1.6.5-2.el7                

  libX11-common.noarch 0:1.6.5-2.el7            libXau.x86_64 0:1.0.8-2.1.el7                     libXcomposite.x86_64 0:0.4.4-4.1.el7                          libXcursor.x86_64 0:1.1.15-1.el7           

  libXdamage.x86_64 0:1.1.4-4.1.el7             libXext.x86_64 0:1.3.3-3.el7                      libXfixes.x86_64 0:5.0.3-1.el7                                libXft.x86_64 0:2.3.2-2.el7                

  libXi.x86_64 0:1.7.9-1.el7                    libXinerama.x86_64 0:1.1.3-2.1.el7                libXrandr.x86_64 0:1.5.1-2.el7                                libXrender.x86_64 0:0.9.10-1.el7           

  libXtst.x86_64 0:1.2.3-1.el7                  libXxf86vm.x86_64 0:1.1.4-1.el7                   libdrm.x86_64 0:2.4.91-3.el7                                  libfontenc.x86_64 0:1.1.3-3.el7            

  libglvnd.x86_64 1:1.0.1-0.8.git5baa1e5.el7    libglvnd-egl.x86_64 1:1.0.1-0.8.git5baa1e5.el7    libglvnd-glx.x86_64 1:1.0.1-0.8.git5baa1e5.el7                libjpeg-turbo.x86_64 0:1.2.90-6.el7        

  libpciaccess.x86_64 0:0.14-1.el7              libthai.x86_64 0:0.1.14-9.el7                     libtiff.x86_64 0:4.0.3-27.el7_3                               libwayland-client.x86_64 0:1.15.0-1.el7    

  libwayland-server.x86_64 0:1.15.0-1.el7       libxcb.x86_64 0:1.13-1.el7                        libxshmfence.x86_64 0:1.2-1.el7                               libxslt.x86_64 0:1.1.28-5.0.1.el7          

  lksctp-tools.x86_64 0:1.0.17-2.el7            mesa-libEGL.x86_64 0:18.0.5-4.el7_6               mesa-libGL.x86_64 0:18.0.5-4.el7_6                            mesa-libgbm.x86_64 0:18.0.5-4.el7_6        

  mesa-libglapi.x86_64 0:18.0.5-4.el7_6         pango.x86_64 0:1.42.4-2.el7_6                     pcsc-lite-libs.x86_64 0:1.8.8-8.el7                           python-javapackages.noarch 0:3.4.1-11.el7  

  python-lxml.x86_64 0:3.2.1-4.el7              ttmkfdir.x86_64 0:3.0.9-42.el7                    tzdata-java.noarch 0:2019a-1.el7                              xorg-x11-font-utils.x86_64 1:7.5-21.el7    

  xorg-x11-fonts-Type1.noarch 0:7.5-9.el7     




Complete!

 

 

Create a directory and copy the application:

 

cd ~




[root@vmlinuxmachine opc]# mkdir javaBLOG




[root@vmlinuxmachine opc]# git clone  https://github.com/brunors/appte.git/javaBLOG.git





 

 

Download and install JDBC drives in your provisioned environment:

 

[root@vmlinuxmachine lib]# tar xzfv ojdbc8-full.tar.gz

ojdbc8-full/

ojdbc8-full/ojdbc8.jar

ojdbc8-full/oraclepki.jar

ojdbc8-full/osdt_core.jar

ojdbc8-full/xdb6.jar

ojdbc8-full/ons.jar

ojdbc8-full/ojdbc.policy

ojdbc8-full/orai18n.jar

ojdbc8-full/osdt_cert.jar

ojdbc8-full/README.txt

ojdbc8-full/ucp.jar

ojdbc8-full/simplefan.jar

 

 

 

[root@techdatabasketblog]# sudo ssh -i /path_to/sshkeys/id_rsa [email protected]

Enter passphrase for key '/root/.ssh/id_rsa':

[opc@vmlinuxmachine ~]$ cd javaBLOG

[opc@vmlinuxmachine javaBLOG]$

 
Copy and unzip your database wallet to the application directory on the server:
 

 

[opc@vmlinuxmachine ~]$unzip /tmp/wallet/Wallet_techdatabasket.zip -d /wallet_APPtechdatabasket/

Archive:  /tmp/wallet/Wallet_techdatabasket.zip

  inflating: /wallet_APPtechdatabasket/cwallet.sso 

  inflating: /wallet_APPtechdatabasket/tnsnames.ora 

  inflating: /wallet_APPtechdatabasket/truststore.jks 

  inflating: /wallet_APPtechdatabasket/ojdbc.properties 

  inflating: /wallet_APPtechdatabasket/sqlnet.ora 

  inflating: /wallet_APPtechdatabasket/ewallet.p12 

  inflating: /wallet_APPtechdatabasket/keystore.jks 

[root@techdatabasketblog wallet_APPtechdatabasket]#

 
Change the sqlnet.ora file values ​​to the following:
 
WALLET_LOCATION = (SOURCE = (METHOD = file) (METHOD_DATA = (DIRECTORY=$TNS_ADMIN)))

SSL_SERVER_DN_MATCH=yes

 
Set the TNS_ADMIN variable to the wallet path:
 
export TNS_ADMIN=/home/opc/javaBLOG

 
 
Compile the java application:

 

cd /home/opc/javaBLOG/src

 

 Execute the java application and connect to the ATP database:

 

java -cp .:/home/opc/javaBLOG/lib/ojdbc8-full/ojdbc8.jar javaAPP

 

This finished  the series of articles on the simple approach of Oracle Autonomous Database and DevOps. The idea for this series of articles came from my participation in Oracle Code Rome 2019 in Italy, where I got a lot of knowledge that made me explore this DevOps field further with the ATP database and as mentioned in the first article we started with the Docker setup and later in the following articles on Oracle Cloud database and server provisioning on Oracle Cloud and we end with a brief representation of microservices and java with the ATP database. However, there are a number of features that can still be explored within Oracle Cloud, so create your account and explore the Oracle Cloud world.

 

 

References:
 
https://www.oracle.com/technetwork/database/availability/trn5515-microserviceswithoracle-5187372.pdf
 
https://microservices.io/
https://nodejs.dev/
 
https://blogs.oracle.com/dbcs/building-microservices-on-oracle-autonomous-transaction-processing-service-v2
 
https://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
 
https://github.com/cloudsolutionhubs
 
https://www.oracle.com/technetwork/database/application-development/jdbc/documentation/atp-5073445.html
 
https://www.oracle.com/webfolder/technetwork/tutorials/obe/cloud/apaas/java/getting-started-java-accs/getting-started-java-accs.html

 

 

Bruno Reis da Silva is a Database Cloud Support Engineer and professionally Certified Oracle Database Administrator who has worked on the South American continent and is now working on the European continent. He was awarded the first Oracle Ace Associate of Hungary in 2017. His interests are in RDBMS, mainly Oracle, operating systems (Linux, AIX, HPUX and Solaris) and High Availability Solutions implementations. In his free time he enjoys playing sports , going to the gym and traveling. His blog www.techdatabasket.com is dedicated to his sister Laura Vitoria and the main reason for blogging is because he believes in the quote “giving back to get back” . He also enjoys continuous learning and the interaction with others who share his interest.

 

Carlos Magno de Andrade Júnior is an  Database Architect at eProseed Europe, with more than 15 years of experience in Oracle database on complex projects in countries such as Brazil , India , the Netherlands, Luxembourg , France and Italy, having worked in companies such as Oracle Corporation, IBM, HSBC, among others. Also share information on your blog ezdba.wordpress.com. Certifications : OCM 12c OCP 10g , 11g OCP , OCP 12c, OCE RAC , Exadata , ITIL and OEM 12c Cloud Control Implementation Specialist.