Posts Tagged Database
Virtual Development Server: Provide Docker images in docker registry for Oracle XE Database and others
For later creation of containers as needed in the deployment process we have first to build docker images whenever we do not find suitable one in docker hub.
For most of my development I need a oracle database. On the internet you can find a lot of Dockerfile’s for this, but no ready image. This is because for running a database you have to accept a license and this happens when you download the installation software. For private testing this license often is free.
The basic cycle for all of this images is the same on my side:
- Find a Docker image
- If not found download required Software and build a Docker image
- Build the Docker image
- Push the images to private docker registry or the public registry DockerHub
Following you find an example for building Oracle XE 184.108.40.206 Image.
First you have to clone the git repository to a directory of you choice, I choose C:\shared\scmlocal\docker-images.
Put the downloaded installation source oracle-xe-11.2.0-1.0.x86_64.rpm.zip in the subdirectory C:\shared\scmlocal\docker-images\OracleDatabase\dockerfiles\220.127.116.11 as described in GitHub.
Next we have to map this directory to our virtualbox via following vagrant instructions. Additional we prepare port forwarding for accessing later the database from our host system.
... # Port Forwardings for: # - Oracle database port config.vm.network "forwarded_port", guest: 1521, host: 1521 # Oracle Application Express (APEX) config.vm.network "forwarded_port", guest: 8080, host: 8080 ... # map Oracle Docker Images installation path config.vm.synced_folder "C:\\shared\\scmlocal\\docker-images", "/docker-images", :mount_options => ["dmode=777","fmode=777"] ...
After that restart the virtualbox and connect to it via
vagrant halt vagrant up vagrant ssh
In the output you can see this mapping.
... default: 1521 (guest) => 1521 (host) (adapter 1) default: 5000 (guest) => 5000 (host) (adapter 1) default: 8080 (guest) => 8080 (host) (adapter 1) ... default: /docker-images => C:/shared/scmlocal/docker-images ...
Now you create build the image with the Oracle XE (-x) database version (-v) 18.104.22.168 via the provided scripts from oracle. -i skips the MD5 checksum check, as the checksums are not checked in as UNIX text format and so does not work in our vagrant on windows / oel virtualbox combination.
cd /docker-images/OracleDatabase/dockerfiles ./buildDockerImage.sh -v 22.214.171.124 -x -i
Now you have to wait some time. When the process is ready, you get at the time of this writing an image with the binaries installed.
docker images REPOSITORY TAG IMAGE ID CREATED SIZE oracle/database 126.96.36.199-xe 624d78c89ccb About a minute ago 1.203 GB registry latest c6c14b3960bd 5 weeks ago 33.28 MB oraclelinux latest 1988eb5b3fc6 6 weeks ago 278.2 MB
Next we tag this image for pushing to the local docker repository, which we have created in the first blog of this series and is up with every vagrant up of our virtualbox. After that we push it to the registry.
docker tag oracle/database:188.8.131.52-xe localhost:5000/oracle/database:184.108.40.206-xe docker push localhost:5000/oracle/database:220.127.116.11-xe
In the output we see the succesful push.
The push refers to a repository [localhost:5000/oracle/database] 345dfbce8859: Pushed dd4b46d40894: Pushed 11327e04fac0: Pushed 18.104.22.168-xe: digest: sha256:82058ca2c5c201ff46471a8db4d9569da9869d420727595884050f94dad0ec85 size: 955
Now we will check, if we can create a Docker container from our image in the registry and the database is working in it. Therefore at first we delete the oracle/database and oraclelinux images from our virtualbox. Then we create the container.
docker rmi 624d78c89ccb -f docker rmi 1988eb5b3fc6 sudo docker run --shm-size=1g -p 1521:1521 -p 8080:8080 --name="db22.214.171.124-xe" --restart unless-stopped localhost:5000/oracle/database:126.96.36.199-xe
In line 3 we pull the image from the local registry, start a container, open the ports 1521 and 8080 to the virtualbox and give the container a name.
Unable to find image 'localhost:5000/oracle/database:188.8.131.52-xe' locally 184.108.40.206-xe: Pulling from oracle/database 10ec637c060c: Pull complete 1902f66bc90b: Pull complete dd8942200fe1: Pull complete Digest: sha256:41ce1015c8f68ce063e855e7afa96000ededeef1e197e2181bc04c9577d73a1b Status: Downloaded newer image for localhost:5000/oracle/database:220.127.116.11-xe ORACLE AUTO GENERATED PASSWORD FOR SYS AND SYSTEM: 9f4e9a733e7983bc Oracle Database 11g Express Edition Configuration ------------------------------------------------- This will configure on-boot properties of Oracle Database 11g Express Edition. The following questions will determine whether the database should be starting upon system boot, the ports it will use, and the passwords that will be used for database accounts. Press <Enter> to accept the defaults. Ctrl-C will abort. Specify the HTTP port that will be used for Oracle Application Express : Specify a port that will be used for the database listener : Specify a password to be used for database accounts. Note that the same password will be used for SYS and SYSTEM. Oracle recommends the use of different passwords for each database account. This can be done after initial configuration: Confirm the password: Do you want Oracle Database 11g Express Edition to be started on boot (y/n) [y]: Starting Oracle Net Listener...Done Configuring database...Done Starting Oracle Database 11g Express Edition instance...Done Installation completed successfully. SQL*Plus: Release 18.104.22.168.0 Production on Tue Sep 6 09:41:22 2016 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle Database 11g Express Edition Release 22.214.171.124.0 - 64bit Production SQL> PL/SQL procedure successfully completed. SQL> Disconnected from Oracle Database 11g Express Edition Release 126.96.36.199.0 - 64bit Production ######################### DATABASE IS READY TO USE! ######################### db_recovery_file_dest_size of 10240 MB is 0.98% used. This is a user-specified limit on the amount of space that will be used by this database for recovery-related files, and does not reflect the amount of space available in the underlying filesystem or ASM diskgroup. Starting background process CJQ0 Tue Sep 06 09:41:19 2016 CJQ0 started with pid=26, OS id=759 Tue Sep 06 09:41:24 2016 XDB installed. XDB initialized.
In line 9 you can see the autogenerated passwords.
When line 46 appears, you can connect to the database.
With following command you can change the passwords of SYS and SYSTEM:
sudo docker exec db188.8.131.52-xe /u01/app/oracle/setPassword.sh LetsDocker
You see following output:
SQL*Plus: Release 184.108.40.206.0 Production on Tue Sep 6 15:49:34 2016 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle Database 11g Express Edition Release 220.127.116.11.0 - 64bit Production SQL> User altered. SQL> User altered.
As long as you not remove or manually stop the container, it restarts with the virtualbox now via:
vagrant halt vagrant up
At the moment you cannot make your database instance data persistent for this container, I have opened an issue for this, but Gerald Venzl has promised to to implement this later.
Here you find the source code for this blog.
Here you find more about the topic “Virtual Development Server”.
This was my second day:
Michael Tamm (optivo GmbH): Feature Toggles on Steroids
Very good summary off all topic’s covering feature toggles. Wish I had this summary 2 years before, were we have evaluated this. Unfortunately furthermore no solutions for declarative frameworks like Oracle ADF with it’s wizards and xml configurations, which later generated code. Ironic answer to my question: “Don’t use frameworks – use Java”
Alexander Casall (Saxonia Systems AG): User Experience for techies
Now comes someting completely different. As least I had expected. No techniques etc.. There are really german standards “Ergonomics of human-system interaction” in ISO 9241 – 110 (Dialogue principles) and ISO 9241 – 210 (Ergonomics of human-system interaction). I have to read this, if it really would help in development, or the presenter interprets this on its own. Nice and surprising presentation.
Adam Gowdiak (Security Explorations): Java (in)security (Keynote)
The presenter is really angry about Oracle and co. and the security in Java. Nevertheless it seems he has specialized only on this topic and earn this money on this. So I doesn’t know, if somebody or another product is better. What about security in OpenJDK? And what are now my alternatives? A little depressing keynote.
Lars Röwekamp (open knowledge GmbH): Courage to professionalism
I don’t know, what I had expected here, but this was a nice surprise too. The talk was about to find a common language between customer, analyst, developer and other roles. The patterns “Rich Entities” and “Value Objects” helps to find a way out of the helper, util and manager class hell and seems to improve the readability of the code for all stakeholders. But how will this fit in declarative Frameworks like Oracle ADF and it’s generated classes? Have to think about it. Very good speaker!
Unfortunately the worst presentation comes from Oracle itself. To be fair: this presentation should be held by Bruno Borges, which was prevented to come to Javaland. Tip: Never hold a presentation, which is created by another person, if you don’t know, what he know about the subject. But I’m not sure if I had understood more, if Bruno had held the presentation. I didn’t find a red thread in the slides. And I must add, I didn’t really find an alternative presentation in this time slot.
Alexander Heusingfeld, Tammo van Lessen (innoQ Deutschland GmbH): When Microservices Meet Real-World Projects: Lessons Learned
Interesting presentation but the topic was missed. This had little to do with Microservice, more what a consultant or any person has to learn on his way from Junior to Senior: communicate, communicate, communicate. Especially when you want to change something.
Stephan Kaps (Bundesversicherungsamt): Flyway vs. LiquiBase – Battle of the database migration tools
I wanted to do this comparison several times before, but had never enough time. Now I’m relative sure that I will start with Liquibase in my next private project before I develop the application. This was the subjective winner of the battle too. I’m overwhelmed by the mass of features of both tools. Very good summary!
This was a nice workshop to plan the application and technical architecture of a given small set of requirements. Result for me: the many participants from a lot of other companies comes to very similar architecture depending on the assumption they made. In real life you have to communicate again and again with your stakeholders to get answered all of the questions and get quick feedback from them. I have urgently to refresh my knowledge of tools for UML diagramming and graphical presentations. And for structured proceeding maybe I should look for TOGAF training?
This was inspiring conference, which gives me a lot of fresh ideas and reminders for some spilled goals for my private and company projects. I think we’ll see us next year!