Monday, March 31, 2014

Snapshotting - Preserving Moments in Time

So, now that you have your virtual machines, you are feeling empowered to go and do lots and lots of changes! Maybe take a crack at some major installation. Maybe even create an application or two to get your feet wet.

But what if you make a mistake? What if you really screw up your machine (and, these being Linux, fixing them won't be completely trivial!)

In a later post, I will talk about SVN but, for now, you best defense is to take a "snapshot" of the current state of the machine. Notice, you are preserving the "current state of the machine." Best way to think of that. If your machine was on and you were in the middle of a query when you took a snapshot, THAT will be the state of the snapshot!

With these snapshots, you have the ability to "recover" the snapshot; basically taking your computer back to the state of the machine when the snapshot was made. If it was in the middle of a query, it will go back to that time and then resume the query!

Let me show you what I mean.

Here I have my machine before I have done any snapshot.

Note the icons on the bottom left and the terminal window is open.

In my "use case," I have decided to clean up the desktop and start up a "sqlplus" session (you don't need to know what sqlplus is for this - just using it as an example)



Before I do anything drastic, I create a snapshot.

In Virtual Box, on the host, I select the machine I am working with and then select "Snapshots" (on the right).
I don't have any at this point, so all I see is the current state.

I click on the camera and I get to this image, below.

The original "Snapshot Name" is "Snapshot 1"
I am not going to stick with that. Instead I give the snapshot the name "Initial State." That name is really enough. If the snapshot was more involved, I would be tempted to add a Description.

After I click on "OK," there will be a little bit of processing but I will eventually see the following.


And now I have a Current State that is different (by 11 seconds) to the "Initial State!"
So, now that I feel confident about my "backup," I go to town on my desktop.

I deleted the icons and started SQL*Plus.
I then take a snapshot - for not really a good reason ... just because it was fun!
(Seriously, it would be a good idea to do a snapshot after any significant change you make in the system)

I now have TWO states (THREE if you include the Current State).

OH NO!!! I realize that I needed those icons!

Important to note I can't choose which bits of a snapshot I want to restore. It is an all or nothing thing. I am restoring the STATE of the machine at the time the snapshot was made.
Also important to note that you can't restore a snapshot while the machine is up and running, either! You can snapshot with the machine up (hot) or down (cold). Restoring is like revenge, it is best (and only) done cold!

So I bring the machine down (ideally by a good "shutdown.")
I then click on the state/snapshot I want to restore.

I will get a warning and the offer to make a snapshot of my current state (without the icons). You can decide for yourself if your shame is worth keeping! :) (if you want to make a snapshot - this is important because, if you don't, that state without the icons will be gone FOREVER.)



Now I have Virtual Box look like this...


When I start it up, it now looks like it's been restored to the initial condition!


There is so much more you can do here! Consider looking at the actual manual for virtual box -
http://www.virtualbox.org/manual/
http://www.virtualbox.org/manual/ch01.html#snapshots
- Or just Google around! Lots of good (and not so good (like mine!) info out there!

Have fun!




Saturday, March 29, 2014

Getting at your data in your VM sample schemas

How can you get at your sample data?

Assumptions : You have your VM up and running.
http://datadowsingrod.blogspot.com/2014/03/where-to-begin.html
http://datadowsingrod.blogspot.com/2014/03/getting-your-vm-ready.html

For this discussion, I am going to keep my focus on the fairly new Database App Development VM machine.

No matter which of the three VMs you could have downloaded, they all come with SQL Developer. SQL Developer is a light weight IDE (Integrated Development Environment) that you can use to access you data.

If you want to know more about this tool, you can go right to the source!
http://www.oracle.com/technetwork/developer-tools/sql-developer/overview/index.html

When starting the VM, a terminal window (command window) will open up and tell you some key facts!



Notice that this machine has TWO databases! It has a database "instance" called "orcl" and a new one called "pdbl." In most other VMs that have databases, orcl has the sample data. In this one, pdbl has them.

What is "sample data" or "sample schemas?" Oracle provides sample data to use in their demonstration and training. More information on those can be found here - http://docs.oracle.com/cd/E16655_01/server.121/e15979/overview.htm#COMSC005 - but, suffice to say, it is good data to play with.

But to get to this data, you need to create "connections" in SQL Developer. Open up SQL Developer. On the left, you will see either no connections or just one for "pmuser"

Add caption


To really get control over these databases, we are going to create two connections to the SYSTEM user (a very powerful user) in each database. Click on the green Plus and fill in the blanks!


Some notes :
- The Connection Name can really be anything. I prefer to name them "database_schema." This is for the "orcl" database and for the "system" schema, so I called it "orcl_system"
- Password is "oracle"
- SID (meaning "Site IDentifier" is basically the name of the database - I know, that was pretty "rough!")


Some notes :
- Notice that I am using "Service Name" and not "SID" to specify the database "name" PDB1. I admit to know knowing WHY! "I am not a DBA, nor do I play one on TV.

Now you have two powerful connections!



Almost ready. Now you just need to find the sample schemas!

Example EACH system connections and then look for "Other Users"


In my opinion, you can get pretty far in life with the HR (Human Resources) and OE (Order Entry) schemas. These are in the PDB1_system connection so they are going to be in the PDB1 database. Create those connections as demoed below.



Now, your connects list should look like this -


Now you are ready to play! Expand (click on the "+") the PDB1_hr node and notice that a worksheet will open up. You are now ready to type your first command! I would suggest ...












SELECT *
FROM   employees;

Hit <Cntr+Enter> and sit back and bask in your accomplishments!
















Getting your VM ready

 Before you start the VM...

You may want to make some minor modifications. For this example, I am focusing on the "Database App Development VM" but you could probably work out what changes you would make to other machines.

In the end, I am looking to -
- Add a description
- Adjust the memory and processors
- Adjust the network so the machines can have access to the outside world!


Assumptions : You have at least one of these VMs downloaded.
http://datadowsingrod.blogspot.com/2014/03/where-to-begin.html

When you imported your VM, if you just took the default (and, why not?), the settings probably looked like this -


This is okay but your machine is probably more powerful and could take more stress than this machine is going to demand. Also, as this is just a playground for you, you may want to store important information (like passwords) in a place where you are guaranteed to be available.

Changing the Description


In the  "Database App Development VM" machine, all the passwords (root, database, etc) are "oracle." I am pretty sure I won't remember this tomorrow so I put it into the description of the VM. Yes, this is NOT SECURE but for a playground, this is fine!

Adjusting the memory and processors.


Personally, I have a 16G machine but I am just going to give this guy 2G

I am also going to give this guy 2 CPUs. This is optional FOR THIS MACHINE. Use your judgement.

Adjusting the Network.

By default, these VMs seem to be set to NAT. This is great - if you don't plan on ever using your machine to ever access anything outside of itself! For me, having a machine that can't talk to my home network (let alone the internet) seems pretty 80's! So, I adjust them to use the "Bridged Adapter."

And, that's it. Now my machine should be ready to fire up!

Friday, March 28, 2014

Where to begin?

"How do I get my hands on a database?"

There are several choices out there for you but, let's assume you have the following criteria.

- You have very little money. - You have very little time - You have very little experience.

You would think the "barrier to entry" would be pretty significant, wouldn't you? Well that was the case in the "old days!" Now, even with a modest PC/Mac you can get your hands on a full blown database and even some "middle ware" and tools.
(Full Disclosure : I am an Oracle employee and am most familiar with Oracle products. I am sure (and hope) there are other solutions out there. Also, being an Oracle employee, I should add that these are MY views and NOT those of the company.)
Here is what I am going to propose. Why not install some kind of "visualization" software and then use a "virtual appliance" (aka "virtual machine")? Sounds tough? Big words? But this is REMARKABLY easy (most of the time) and here are the steps.

Virtual Box - Software that pretends it's a machine!

(I am certainly not an expert in this and, with some quick "Googling," you can read blogs from people that are! I actually started with visualization using VMWARE but, after Oracle bought Sun, I just went to "eating our own dog food" (an expression born from the idea of a company using its own software). I am sure if you are set on using VMWARE or something else, this advice should still work.)
For us, the starting point is here.

http://www.oracle.com/technetwork/server-storage/virtualbox/downloads/index.html

Virtual Box is software that emulates the hardware of a PC. It is "Freely available for Windows, Mac OS X, Linux and Solaris x-86 platforms:" (from the site). To my knowledge and in my experience, it cleanly installs (and uninstalls) and is an excellent way to "try before you buy" or, in this case, create an environment to play with technology you could never afford in the real world!
Once you install it, Oracle has a site with several VMs to choose from. They add (and remove) these over time so what I am pointing out now could easily be different from what you would see when you go to the site.

http://www.oracle.com/technetwork/community/developer-vm/index.html

Oracle Virtual Appliances - one to fit your needs

For me, there are three really cool ones that I spend time learning from.

Database App Development VM

It is a "Hands-on Database Application Development"
It comes with the following ...
  • Oracle Linux 6.5
  • Oracle Database 12c Release 1 Enterprise Edition
  • Oracle XML DB
  • Oracle SQL Developer
  • Oracle SQL Developer Data Modeler
  • Oracle Application Express
  • Hands-On-Labs (accessed via the Toolbar Menu in Firefox)
As for your PC, you need 2 GB of Ram (the more you can allocate, the better) and 15GB of hard-drive space.At the time of this writing, the URL for this VM was here -

http://www.oracle.com/technetwork/database/enterprise-edition/databaseappdev-vm-161299.html

This particular VM came out in Feb of 2014. It's predecessor has been a favourite one for me for years! It is all you need to start getting ramped up on this stuff.
If you are a little more savvy, there are two other ones that are quite cool.

Oracle Business Intelligence SampleAppV309

This is a " Sample Application (SampleApp) for Oracle Business Intelligence Suite Enterprise Edition is a comprehensive collection of examples designed to demonstrate Oracle BI capabilities and design best practices." - It is an example of OBIEE! (and related BI technologies)
It comes with the following ...
  • Oracle Linux 5.9 (el5PAE)
  • OBIEE 11.1.1.7.1 (includes OBIEE Essbase/EPM Suite)
  • Mobile Application Designer
  • Oracle Database 12c
  • Endeca Server 7.5.1
  • Oracle Big Data Connectors
  • Endeca Studio 3.0
  • Endeca Integrator 3.0
  • Oracle APEX Listener 2.0.1
  • Oracle Applicatio Express 4.2
  • R-2.15.1, ORE 1.3
  • Jrockit 1.6.0.37, Java SE Development Kit 7u17
  • Oracle SQL Developer 3.2.20
  • EPM 11.1.2.2 Standalone (Offered as a separate download for the SampleApp OTN page)
There is some dated stuff on here (like Oracle SQL Developer 3.2!!!) but they do have a 12c database!
You need a bit more robust PC for this, though. You need at least 8GB of "real memory" (that's if you are firing the entire VM's software up) and during the install, a whopping 84GB of space. It takes a significant time to download all the bits, unzip them and install them. But, the reward is, when you are finished, you have a great playground LOADED with BI Tech Goodies!At the time of this writing, the URL for this VM was here -

http://www.oracle.com/technetwork/middleware/bi-foundation/obiee-samples-167534.html

Oracle Big Data Lite VM

Very cool idea. Basically, this is a fully deployed "Netflix" kind of application ("Oracle MoviePlex") which not only comes with a completley faked out version of the application but all the data and tech behind it. There is TONNES to learn from in here!
  • Oracle Enterprise Linux 6.4
  • Oracle Database 12c Release 1 Enterprise Edition (12.1.0.1)
  • Cloudera’s Distribution including Apache Hadoop (CDH4.5)
  • Cloudera Manager 4.8
  • Cloudera Enterprise Technology, including Cloudera RTQ (Impala 1.2.3) and Cloudera RTS (Search 1.1)Oracle Big Data Connectors 2.4
  • Oracle NoSQL Database Enterprise Edition 12cR1 (2.1.54)
  • Oracle Data Integrator 12cR1
  • ... and more
The Technical Requirements are - 
  • Dedicate 2 cores, 5 GB memory and 30GB disk space to the virtual machine
  • Install will require ~40GB disk space including temporary files
So, again, this is not for the faint of heart! But it is quite a treat if you get it up.
The URL for that is here.
These three can keep you going for MONTHS! Certainly worth trying out.