Installing Oracle 11g XE and Apex 4.11 in Amazon AWS


I have written about how to install Apex and XE on Linux, this one takes those thoughts and applies them to Amazon AWS.

There is some improvement on my ramblings of Linux Apex installation as well 🙂

If you want to run a highly resilient APEX installation then I would suggest that you run an Oracle RDS instance and a separate APEX web server, details of how to do this can be found at APEX within the Oracle RDS environment

 

One thing to note, if you are installing on an Amazon Ec2 image. Create a separate security group for this server and allow the following ports 8080,8181,37339. You obviously have to allow all of your standard ports 22 etc, but this is based of how you access the server. This is just note to highlight that there are some special ports that are required.

I am installing this on an Amazon Linux 64 bit image and I will be using the llg express edition

mkdir -p /opt/software/oracle
cd /opt/software/oracle

Download the oracle database and upload it to this folder. I have yet to work out how to you lynx on this site so I have to use a GUI browser. http://www.oracle.com/technetwork/products/express-edition/downloads/index.html?ssSourceSiteId=ocomen

You will also need to download the Apex software

unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip 
rpm -Uvh oracle-xe-11.2.0-1.0.x86_64.rpm

You will probably get this error

Preparing… ########################################### [100%]

This system does not meet the minimum requirements for swap space. Based on
the amount of physical memory available on the system, Oracle Database 11g
Express Edition requires 1190 MB of swap space. This system has 0 MB
of swap space. Configure more swap space on the system and retry the
installation.

error: %pre(oracle-xe-11.2.0-1.0.x86_64) scriptlet failed, exit status 1
error: install: %pre scriptlet failed (2), skipping oracle-xe-11.2.0-1.0

 Do not worry just follow these instructions on creating swap space  and then get right back to this document 🙂

rpm -Uvh oracle-xe-11.2.0-1.0.x86_64.rpm

Once installed you will get the following message

Executing post-install steps…
You must run ‘/etc/init.d/oracle-xe configure’ as the root user to configure the database.

/etc/init.d/oracle-xe configure

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 [8080]:

Specify a port that will be used for the database listener [1521]:

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.

To test the connection

ln -s /u01/app/oracle/product/11.2.0/xe/bin/sqlplus /usr/bin/sqlplus

If you ran sqplus from the command line you would get the following error

P2-0667: Message file sp1<lang>.msb not found
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory

To correct this you need to set the ORACLE_HOME

vi /etc/profile

Insert the following lines at the bottom

export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
export ORACLE_HOMEexport ORACLE_SID=XEexport NLS_LANG=AMERICAN.AL32UTF8
export PATH=$PATH:$ORACLE_HOME/bin

You need to run the profile to get the variables

. /etc/profile

Note the space between . /

It is also worth adding these lines to the .bashrc file in the home directory

echo $ORACLE_HOME

This will see if you have set the directory correctly

To see if you have Oracle working correctly then:

sqlplus sys@localhost as sysdba

Enter the password that you set at the start of the installation

This should give you a SQL> prompt

select sysdate from dual;

This will return today’s date

Change host name of server and allow Oracle to start properly.

Due to the nature of the installation in Amazon there are a few workarounds required, these consist of changing the host name and reconfiguring the tnsnames.ora and listener.ora files in Oracle.

The host name must be registered in a DNS server, I use Route 53 for this as it gives me ultimate control over the servers in the Amazon infrastructure.

vi /etc/sysconfig/network

Find the following entry HOSTNAME=localhost.localhost.com

Change this to your FQDN as per what is registered in your DNS.

You will need a reboot of the server

reboot

Now you have completed this part you need to change the Oracle ora files, I have taken care of this for you in the following post Starting an Oracle XE listener on Amazon EC2 instance

Now to install APEX

Please be careful if copying and pasting some of the ‘ get replace which will result in errors in the scripst

We need to change some parameters in Oracle

sqlplus sys/password@localhost as sysdba
ALTER SYSTEM SET SHARED_POOL_SIZE='100M' SCOPE=spfile;
exit
service oracle-xe restart
cd /opt/software/oracle/apex
sqlplus sys/password@localhost as sysdba

The creation of this environment will be based on the table space being called apex

So at the SQL> prompt

create tablespace apex
  logging
  datafile '/u01/app/oracle/oradata/XE/apex.dbf' 
  size 32m 
  autoextend on 
  next 32m maxsize 2048m
  extent management local;

The command we will use is as follows

@@apexins tablespace_apex tablespace_files tablespace_temp images

e.g.

@@apexins apex apex temp /i/

Now we will set the password for the admin of the site

@apxchpwd

Enter a password for the ADMIN user Enter admin password that you want

ALTER USER APEX_PUBLIC_USER ACCOUNT UNLOCK
ALTER USER APEX_PUBLIC_USER IDENTIFIED BY ENTER PASSWORD;

Once the user and passwords have been set we can exit from the SQL> screen

exit

Now to install and set-up the Glassfish server

cd  /opt/software
mkdir glassfish
cd  glassfish

Download the server from the Oracle Glassfish site to this directory

unzip  ogs*.zip
cp -r glassfish3 /opt/
mkdir -p /opt/glassfish3/glassfish/domains/domain1/docroot/i

Note: The ‘i’ directory is very important, again not from any notes that I have seen, might have missed this. Got it from a YouTube demo installation.

cd /opt/software/oracle/apex/images
cp -r * /opt/glassfish3/glassfish/domains/domain1/docroot/i
cd /opt/glassfish3/glassfish/bin
./asadmin start-domain

This domain requires an administrative password to be set before
the domain can be started. Please specify an administrative password. 
Enter an admin password for user “admin”>

Enter an admin password for user “admin” again>

You possibly will get the following error
Waiting for domain1 to start …………………………Error starting domain domain1.
The server exited prematurely with exit code 0.
Before it died, it produced the following output:

Launching GlassFish on Felix platform
[#|2012-07-28T16:59:02.488+0000|INFO|oracle-glassfish3.1.2|com.sun.enterprise.server.logging.GFFileHandler|_ThreadID=1;_ThreadName=main;|Running GlassFish Version: Oracle GlassFish Server 3.1.2.2 (build 5)|#]

[#|2012-07-28T16:59:02.777+0000|INFO|oracle-glassfish3.1.2|org.glassfish.ha.store.spi.BackingStoreFactoryRegistry|_ThreadID=10;_ThreadName=main;|Registered org.glassfish.ha.store.adapter.cache.ShoalBackingStoreProxy for persistence-type = replicated in BackingStoreFactoryRegistry|#]

[#|2012-07-28T16:59:03.521+0000|INFO|oracle-glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.services.impl|_ThreadID=11;_ThreadName=Grizzly-kernel-thread(1);|Grizzly Framework 1.9.50 started in: 59ms – bound to [0.0.0.0:4848]|#]

[#|2012-07-28T16:59:03.522+0000|INFO|oracle-glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.services.impl|_ThreadID=12;_ThreadName=Grizzly-kernel-thread(1);|Grizzly Framework 1.9.50 started in: 92ms – bound to [0.0.0.0:8181]|#]

[#|2012-07-28T16:59:03.533+0000|INFO|oracle-glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.services.impl|_ThreadID=13;_ThreadName=Grizzly-kernel-thread(1);|Grizzly Framework 1.9.50 started in: 37ms – bound to [0.0.0.0:3700]|#]

[#|2012-07-28T16:59:03.548+0000|INFO|oracle-glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.services.impl|_ThreadID=14;_ThreadName=Grizzly-kernel-thread(1);|Grizzly Framework 1.9.50 started in: 14ms – bound to [0.0.0.0:7676]|#]

[#|2012-07-28T16:59:10.723+0000|INFO|oracle-glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=10;_ThreadName=main;|Oracle GlassFish Server 3.1.2.2 (5) startup time : Felix (7,610ms), startup services(10,613ms), total(18,223ms)|#]

[#|2012-07-28T16:59:10.724+0000|SEVERE|oracle-glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=10;_ThreadName=main;|Shutting down v3 due to startup exception : No free port within range: 8080=com.sun.enterprise.v3.services.impl.monitor.MonitorableSelectorHandler@68d448a1|#]

[#|2012-07-28T16:59:11.679+0000|INFO|oracle-glassfish3.1.2|javax.enterprise.system.tools.admin.com.sun.enterprise.v3.admin|_ThreadID=15;_ThreadName=Thread-21;|Server shutdown initiated|#]

[#|2012-07-28T16:59:11.685+0000|INFO|oracle-glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=15;_ThreadName=Thread-21;|Already stopped, so just returning|#]

Command start-domain failed.

The following will delete and recreate the domain that is required (Note that there are 2 dashes in front of nopassword)

./asadmin delete-domain domain1
./asadmin create-domain domain

Enter admin user name [Enter to accept default “admin” / no password]> admin
Enter the admin password [Enter to accept default of no password]> Enter the password
Enter the admin password again> Enter the password

You will get following output
Using default port 4848 for Admin.
Default port 8080 for HTTP Instance is in use. Using 37339
Using default port 7676 for JMS.
Using default port 3700 for IIOP.
Using default port 8181 for HTTP_SSL.
Using default port 3820 for IIOP_SSL.
Using default port 3920 for IIOP_MUTUALAUTH.
Using default port 8686 for JMX_ADMIN.
Using default port 6666 for OSGI_SHELL.
Using default port 9009 for JAVA_DEBUGGER.
Distinguished Name of the self-signed X.509 Server Certificate is:
[CN=ip-10-248-83-138.eu-west-1.compute.internal,OU=GlassFish,O=Oracle Corporation,L=Santa Clara,ST=California,C=US]
Distinguished Name of the self-signed X.509 Server Certificate is:
[CN=ip-10-248-83-138.eu-west-1.compute.internal-instance,OU=GlassFish,O=Oracle Corporation,L=Santa Clara,ST=California,C=US]
No domain initializers found, bypassing customization step
Domain domain created.
Domain domain admin port is 4848.
Domain domain admin user is “admin”.
Command create-domain executed successfully.

You need to recreate the directory and copy the files again

mkdir -p /opt/glassfish3/glassfish/domains/domain/docroot/i
cp -r /opt/software/oracle/apex/images/* /opt/glassfish3/glassfish/domains/domain/docroot/i
./asadmin start-domain

Waiting for domain to start …………
Successfully started the domain : domain
domain Location: /opt/glassfish3/glassfish/domains/domain
Log File: /opt/glassfish3/glassfish/domains/domain/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.

You now have a working Glassfish server ready for the listener and Apex to be deployed.

Configure the Apex Listner

You need to obtain the latest listner from the Oracle web site

Once downloaded unzip the file, you will need this later when you have configured the Glassfish server.

mkdir /opt/software/apexlistener
cd /opt/software/apexlistener
unzip apex*.zip

Configure Glassfish

Navigate to http://FQDN:4848 (where FQDN is your server name)

Login with the credentials that you specified when creating the domain

You will probably get this error Secure Admin must be enabled to access the DAS remotely.

cd /opt/glassfish3/bin

To get the asadmin prompt

./asadmin

asadmin> get secure-admin.enabled

Enter admin user name> admin
Enter admin password for user “admin”>
secure-admin.enabled=false
Command get executed successfully.

asadmin> enable-secure-admin

Enter admin user name> admin
Enter admin password for user “admin”>

You must restart all running servers for the change in secure admin to take effect.
Command enable-secure-admin executed successfully.

asadmin> stop-domain
Waiting for the domain to stop ….
Command stop-domain executed successfully.

asadmin> start-domain
Waiting for domain1 to start ……
Successfully started the domain : domain
domain Location: /u01/app/glassfish3/glassfish/domains/domain1
Log File: /u01/app/glassfish3/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.

asadmin> get secure-admin.enabled
secure-admin.enabled=true
Command get executed successfully.

Configure the Glassfish Server

Navigate to http://FQDN:4848 (where FQDN is your server name)

Login with the credentials that you specified when creating the domain

From the left hand pain pick server-config

Apex Security configurtion

When the security screen is displayed

Select the check box next to Default Principal to Role Mapping.

Don’t forget to press the save button

This is from the Apex install guide

From the web console.

Select the realm to which to add your user (for example, file).

The Edit Realm page appears.

On the Edit Realm page, click the Manage Users button.

The File Users page appears.

On the File Users page, click New.

The New File Realm User page appears.

On the New File Realm User page, create an Admin user:

User ID – Enter the name of the Oracle Application Express Listener administrator:

User ID: adminlistener

Group List – Enter the role to which the user belong:

Group List: Admin

New Password – Enter a unique password.

Confirm New Password – Enter the password again.

Click OK.

Repeat the previous steps and create another user for the Oracle Application Express Listener manager, by specifying the following:

User ID: managerlistener

Group List: Manager

Click OK.

APEX Listener installation and configuration

We now need to install the apex listner that we downloaded earlier on.

On the navigation tree, click the Application node.

The Applications page displays.

Click the Deploy button.

The Deploy Applications or Modules page displays.

Choose the  “Local Packaged File or Directory That Is Accessible from GlassFish Server”  and enter the location of the apex.war file

/opt/software/apexlistener/apex_listener.1.1.4.195.00.12/apex.war

Complete the other field as shown below

This will upload the war file and deploy it in the server.

There seems to be some additional security in 11g version of Oracle, so from the installation guide from Oracle

Enable Network Services in Oracle Database 11g
By default, the ability to interact with network services is disabled in Oracle Database
11g release 1 or 2. Therefore, if you are running Oracle Application Express with
Oracle Database 11g release 1 or 2, you must use the new DBMS_NETWORK_ACL_
ADMIN package to grant connect privileges to any host for the APEX_040100 database
user.”

mkdir -p /opt/glassfish3/configpackage

cd /opt/glassfish3/configpackage

vi createpackages.sql

Paste the following in to the file

DECLARE
ACL_PATH VARCHAR2(4000);
BEGIN
— Look for the ACL currently assigned to ‘*’ and give APEX_040100
— the “connect” privilege if APEX_040100 does not have the privilege yet.
SELECT ACL INTO ACL_PATH FROM DBA_NETWORK_ACLS
WHERE HOST = ‘*’ AND LOWER_PORT IS NULL AND UPPER_PORT IS NULL;
IF DBMS_NETWORK_ACL_ADMIN.CHECK_PRIVILEGE(ACL_PATH, ‘APEX_040100’,
‘connect’) IS NULL THEN
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(ACL_PATH,
‘APEX_040100’, TRUE, ‘connect’);
END IF;
EXCEPTION
— When no ACL has been assigned to ‘*’.
WHEN NO_DATA_FOUND THEN
DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(‘power_users.xml’,
‘ACL that lets power users to connect to everywhere’,
‘APEX_040100’, TRUE, ‘connect’);
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(‘power_users.xml’,’*’);

END;

/
COMMIT;

DECLARE
ACL_PATH VARCHAR2(4000);
BEGIN
— Look for the ACL currently assigned to ‘localhost’ and give APEX_040100
— the “connect” privilege if APEX_040100 does not have the privilege yet.
SELECT ACL INTO ACL_PATH FROM DBA_NETWORK_ACLS
WHERE HOST = ‘localhost’ AND LOWER_PORT IS NULL AND UPPER_PORT IS NULL;
IF DBMS_NETWORK_ACL_ADMIN.CHECK_PRIVILEGE(ACL_PATH, ‘APEX_040100’,
‘connect’) IS NULL THEN
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(ACL_PATH,
‘APEX_040100’, TRUE, ‘connect’);
END IF;
EXCEPTION
— When no ACL has been assigned to ‘localhost’.
WHEN NO_DATA_FOUND THEN
DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(‘local-access-users.xml’,
‘ACL that lets users to connect to localhost’,
‘APEX_040100’, TRUE, ‘connect’);
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(‘local-access-users.xml’,’localhost’);
END;
/
COMMIT;

sqlplus sys/password@localhost as sysdba

@@createpackages.sql

Access Oracle Application Express Listener Administration

Once you have completed the above steps and uploaded the apex.war file you can now launch the application.

Navigate to the Applications section in the navigation tree. You will see the apex line with “Launch | Redeploy | Reload”

Click on Launch, a new window will open giving you two URL’s that you will access the apex application on.

http://FQDN:37339/apex
https://FQDN:8181/apex

To access Oracle Application Express Listener Administration, in your Web browser go to:

http://FQDN:8181/apex/listenerConfigure

The setting are as follows:

Username:APEX_PUBLIC_USER

Password: As per what was set  above with the SQL script (ALTER USER APEX_PUBLIC_USER IDENTIFIED BY ENTER PASSWORD😉

Connection Type: Basic

Hostname: FQDN of the sever

Port:1521

SID:XE

Once you click on OK, then you should be be presented with the following

https://FQDN:8181/apex/wwv_flow.accept

And a web page should appear as below

We now need to create a workspace so that we can start working.

Navigate to

https://FQDN:8181/apex/apex_admin

Logon with the admin password that was set when you managed the users in the realm configuration

You will be asked to change the password to match the new 11g complexity passwords.

You now should have a working APEX installation

You may have a working environment but you will not be able to do anything with it.

Directly from one of the installation guides

"JOB_QUEUE_PROCESSES determine the maximum number of concurrently running jobs. In Oracle Application Express release 4.1, transactional support and SQL scripts require jobs.

If JOB_QUEUE_PROCESSES is not enabled and working properly, you cannot successfully execute a script.”

To see how many JOB_QUEUE_PROCESSES there are, can be checked in three ways. The easiest is from the command line

sqlplus sys/ORACLE_PASSWORD@localhost as sysdba

SELECT VALUE FROM v$parameter WHERE NAME = ‘job_queue_processes’

ALTER SYSTEM SET JOB_QUEUE_PROCESSES = <number>

Replace number with the amount of processes that you wish to run. I have no idea at the moment what this number should be set to as I suspect it will be based on how many applications and user will be accessing the system. For a start I set mine to 20, it’s a good number to start with. More later on how you determine what this number should be.

Advertisements

2 Comments on “Installing Oracle 11g XE and Apex 4.11 in Amazon AWS”

  1. […] is also a new install guide based on the 4.11 Apex and 11g Oracle Installing Oracle 11g XE and Apex 4.11 in Amazon AWS, even though you are looking at Centos or one of the other Linux distributions it maybe worth […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s