Saturday, March 29, 2014

Installing Oracle Apex Listener (now called Oracle REST Data Services)

A client was having problems with the APEX Embedded PL/SQL Gateway (now there's a surprise) and asked if I knew how to install the APEX listener. Basically my answer was no.

Anyway, I decided I'd better move with the times so went to download the APEX Listener only to find Oracle have renamed it to Oracle REST Data Services for some reason.

So I downloaded this instead : http://www.oracle.com/technetwork/developer-tools/rest-data-services/downloads/index.html

It's quite a small file, and once downloaded I thought a good place to put it would be in the $ORACLE_HOME. It can go anywhere, but it's probably easier to put it somewhere you'd expect to look.

I copied it to $ORACLE_HOME/ords and extracted it there.

The install is very easy, just follow the instructions, but there were a couple of things I had to fix.

Since this is in a VM on my PC, I ran it in Standalone mode and followed these instructions: http://docs.oracle.com/cd/E37099_01/doc/doc.20/e25066/install.htm#AELIG7022

Before going ahead, you might want to do some preparation:

Connect to the database as sys and unlock the APEX_PUBLIC_USER account and change the password, because it asks you for this when you install REST Data Services. You night also want to run apxchgpw.sql to set the APEX admin password - use a temporary one because you will need to change it when you first login to the web page. You also need to make it reasonably complex or it will just exit.

So, once the ords zip file is extracted, run "java -jar ords.war"
It will run through some prompts, most should be obvious.

Enter the location to store configuration data:
I used "/u01/app/oracle/product/12.1.0/rest"

Enter the name of the database server: - I used localhost

Enter the database listen port - I used 1521

Enter 1 to specify the database service name, or 2 to specify the database SID [1]: - I used "1" and entered the SERVICE_NAME of the database

Enter the database user name [APEX_PUBLIC_USER]: - I let this default and put in the password I set earlier for the next 2 prompts.

Enter the database password for APEX_PUBLIC_USER:
Confirm password:

Enter 1 to enter passwords for the RESTful Services database users...
I entered "2" to use the same password. Obviously in a PROD environment you wouldn't do this, would you?

Enter 1 if you wish to start in standalone mode or 2 to exit [1]: - I entered "1"

Enter the APEX static resources location or Enter to skip: - Don't skip this. I don't know why they give you the option, because if you do the APEX login page will be blank.
I skipped this the first time round, and the APEX page was blank. I've seen this before in ealier versions, it means you haven't defined the images location.
So for this prompt, you need to enter the location of the APEX images, usually
"/u01/app/oracle/product/12.1.0/dbhome_1/apex/images".

Enter the HTTP port [8080]: - Pick a port. I used 8888 because a lot of the time 8080 is in use. Make sure any firewalls allow this port access.

That's it. The installer will go and do some stuff, then will tell you where the login page is : 
INFO: http://localhost:8888/ords/ started.
Note that the terminal window is now locked to this process.

Go to a browser and type in the URL. If all is well, you'll be presented with the APEX login page - use INTERNAL as the workspace and ADMIN as the user and the password you set earlier - and it will prompt you to change it.

So that's it. I'm not sure the benefits of this method over the EPG, but it looks as if it's the way Oracle is going, so you may as well use it.

Oh, it didn't work for me the first time. When I first went to the URL I got "service unavailable", but the feedback told me what was wrong "Account is Locked", so I unlocked the APEX_PUBLIC_USER account and that fixed it. The other thing was the page was there but it was completely blank, so I had to delete the files, re-extract the zip file and then use the "images" directory for the "static resources" prompt as mentioned earlier.

Happy APEXing.







Sunday, December 29, 2013

Working with Virtualbox - Installing Oracle 12c

If you read my last post (and I know you did), hopefully you'll have Oracle Virtualbox running an OEL6 virtual machine.

As an Oracle DBA, you'll probably want to install 12C to have a play, so go and download it from the Oracle edelivery website - and you'll need an ID.  http://edelivery.oracle.com

Obviously the best place to look is the Oracle documentation - here's the Linux installation guide:

http://docs.oracle.com/cd/E16655_01/install.121/e17720/toc.htm

This page is a condensed version to (hopefully) get you up and running.

First, Oracle have very handily added a yum file that has all the necessary packages. Assuming you've added the public yum repository as in my previous post, type this to get it

yum install oracle-rdbms-server-12cR1-preinstall

This will install the required packages for the database, as well as create the oracle user, oinstall and dba groups etc (a neat trick).

Since this is an install on a VM, you can skip a lot of the pre-installation tasks.

Make the directories as root:

mkdir -p /u01
mkdir -p /u01/app
mkdir -p /u01/app/oracle
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01/app/oracle

Change the oracle user password

passwd oracle

Copy the 12c database software to a temporary directory and unzip it as oracle.

At this point I ran out of space in the VM so had to add a disk, so here's a slight detour on how to do that.

Shutdown the VM, then in Virtualbox go to Settings and select "Storage". Click on the "Controller" item and the "+" icon. Add a new disk with a reasonable size and restart the VM.

In an ideal world the disk would appear when you restarted the VM, but it's not that easy...

So, login as root, and do an "fdisk -l" and you should see the new disk, probably at "/dev/sdb".

Next, do "fdisk /dev/sdb" and you should see a command prompt. Enter "n" to create a new disk, then "p" to make it a primary partition. Choose "2", then enter, then enter at the cylinder prompts and it should come back to the command prompt. Enter 'w' to create it.

However, it needs to be formatted, so exit from the fdisk command if not already, then type

mkfs -t ext4 /dev/sdb

If it prompts you to proceed, enter 'y' (it's only a VM, what's the worst that could happen?)

Remove the "/u01 directory created earlier, and mount this new disk as /u01:

mkdir /u01
mount /dev/sdb /u01

It should be there:

df -h

Add the directories again

mkdir -p /u01/app
mkdir -p /u01/app/oracle
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01/app/oracle

OK, back on track. Download Xming, because the installer uses Xwindows - http://sourceforge.net/projects/xming/

Install it and start the Xming server.

Open a CMD Prompt on your PC where Xming is running and find the IP address using 'ipconfig' - you may have a few show up, it's the one with "Virtualbox" in the name.

Next, sign on to the Linux VM as root and download the Xhost packages

yum install xhost

Enter 'y' when prompted.

Still as root, type export DISPLAY=ipaddress_from_command_prompt:0.0
Then, "xhost +"

You should see "access control disabled, clients can connect from any host"

Nearly there....

Still as root, type 'ifconfig' and note the IP address.
Edit the /etc/hosts file to look like this:

127.0.0.1  localhost.localdomain localhost
192.168.0.5 oel6.localdomain oel6

Where the second IP address is that found from the 'ifconfig' command and the 'oel6' is what you called your VM.

Save the file.

Log in to the VM as oracle, export the DISPLAY variable again, then cd to the place you extracted the software.

Run "./runInstaller"

Hopefully you'll see a few "Passed" messages, then the GUI will pop up. Let it think about itself for a minute, then you should see the first installer window.

You should be able to take it from here, because the responses will be specific to your set up.