7 Replies Latest reply: Dec 11, 2008 12:32 AM by user161771 - oracle RSS

    How do we configure Oracle listener on cloud computing


      How do we configure listener on cloud computing as the when the instance is shutdown and restarted a different set of EC2 Private IP Address & EC2 Public IP Address gets assigned and it causes the listener to fail.

      Any pointers will be appreciated.

      Ashish Agarwal - PMP, OCM & OCP
        • 1. Re: How do we configure Oracle listener on cloud computing
          I am sure sure if I fully understand the situation. Are you reassigning a different public IP address to your EC2 instance after it has been started, using a mechanism like elastic (static) IP address? What is the error that you are running into? It will help if you can list what you did step-by-step,
          • 2. Re: How do we configure Oracle listener on cloud computing
            user161771 - oracle
            I have posted a thread on the Amazon forums that is related to this.

            Essentially, I'm using the Windows images with Oracle Database XE. Because the hostname and ipaddress change during each reboot of the image, the listener.ora and tnsnames.ora files have an incorrect hostname. I was able to add a Microsoft loopback adapter and get that to work, but that method does not survive a reboot.

            Does the Linux image do any tricks for binding to a network address that stays consistent across reboots that could also be leveraged in a build-your-own Windows image?
            • 3. Re: How do we configure Oracle listener on cloud computing
              bill hodak - oracle
              In the Linux AMI's that we provided, we have a script that gets run at startup. This script determines the private dns name and private ip address and then generates a new listener.ora and tnsnames.ora with the appropriate values. Presumably, something similar could be done on the Windows platform using a batch program.

              • 4. Re: How do we configure Oracle listener on cloud computing
                user161771 - oracle
                I ended up writing / cobbling something to do this.

                I have 2 default files named cleverly DEFAULTlistener.ora and DEFAULTtnsnames.ora in my F:\oraclexe\app\oracle\product\10.2.0\server\NETWORK\ADMIN directory. Instead of the hostname or dns name, they have HOSTNAME_GOES_HERE in its place.

                Then I run a batch script that looks like this:
                set JAVA="F:\Program Files\Java\jre1.5.0_16\bin\java"
                copy F:\oraclexe\app\oracle\product\10.2.0\server\NETWORK\ADMIN\DEFAULTlistener.ora F:\oraclexe\app\oracle\product\10.2.0\server\NETWORK\ADMIN\listener.ora
                copy F:\oraclexe\app\oracle\product\10.2.0\server\NETWORK\ADMIN\DEFAULTtnsnames.ora F:\oraclexe\app\oracle\product\10.2.0\server\NETWORK\ADMIN\tnsnames.ora
                %JAVA% -cp F:\startup\replacetext.jar com.oracle.otn.text.ReplaceTextInFile F:\oraclexe\app\oracle\product\10.2.0\server\NETWORK\ADMIN\listener.ora HOSTNAME_GOES_HERE %COMPUTERNAME%
                %JAVA% -cp F:\startup\replacetext.jar com.oracle.otn.text.ReplaceTextInFile F:\oraclexe\app\oracle\product\10.2.0\server\NETWORK\ADMIN\tnsnames.ora HOSTNAME_GOES_HERE %COMPUTERNAME%

                Which replaces the dummy value with the real value and then the services can be launched. However, I still can't get the enterprise manager to come up on port 8080, so I'm still missing something else. The source code for the text replace is below.

                package com.oracle.otn.text;

                import java.io.BufferedReader;
                import java.io.BufferedWriter;
                import java.io.FileInputStream;
                import java.io.FileWriter;
                import java.io.InputStreamReader;

                public class ReplaceTextInFile {

                     * @param args
                     public static void main(String[] args) {
                          if( args.length != 3)
                               System.out.println( "Usage: java com.oracle.otn.text.ReplaceTextInFile filename textToReplace textToReplaceWith");
                          else readReplace(args[0], args[1], args[2]);

                     public static void readReplace(String fname, String oldPattern, String replPattern){
                          String line;
                          StringBuffer sb = new StringBuffer();
                          try {
                               FileInputStream fis = new FileInputStream(fname);
                               BufferedReader reader=new BufferedReader ( new InputStreamReader(fis) );
                               while((line = reader.readLine()) != null) {
                                    line = line.replaceAll(oldPattern, replPattern);
                               BufferedWriter out = new BufferedWriter ( new FileWriter(fname) );
                          catch (Throwable e) {
                          System.err.println("Exception in ReplaceTextInFile.readReplace: " + e );
                • 5. Re: How do we configure Oracle listener on cloud computing
                  You may need to set the HTTP listener end point via the xdb.dbms_xdb package e.g.
                  exec dbms_xdb.setlistenerendpoint(
                          endpoint => dbms_xdb.XDB_ENDPOINT_HTTP
                        , host => 'hostname'
                        , port => 8080 
                        , protocol => dbms_xdb.XDB_PROTOCOL_TCP);
                  It might also work to set/reset the listener local access mode with either:
                  exec dbms_xdb.setListenerLocalAccess(l_access => TRUE);
                  dbms_xdb.setListenerLocalAccess(l_access => FALSE);
                  depending on if you want the service only be available locally or also available remotely (respectively).
                  When local access mode is enabled the host name as returned by dbms_xdb.GetListenerEndpoint is localhost. When local access mode is disabled the host name as returned by dbms_xdb.GetListenerEndpoint is null.

                  Note: I haven't yet encountered this situation so I haven't had need to try any of these potential solutions so I'd like to hear back if any of them works, or what the final solution is if different.
                  • 6. Re: How do we configure Oracle listener on cloud computing
                    bill hodak - oracle
                    You will also need to make sure that the 8080 port is open in the EC2 firewall. You would use the ec2-authorize command to do this or just use the ElasticFox plug-in for the FireFox browser. Let us know if this does the trick.

                    • 7. Re: How do we configure Oracle listener on cloud computing
                      user161771 - oracle
                      I did not end up having to use the packages at all, rather I just made sure that the computer name was set correctly and that the computer name matched what was in the .ora files as I posted here:

                      I was using RDP, so the 8080 authorization wasn't an issue, but after setting the computer name settings correctly in Ec2Config, reimaging, launching the new image, attaching my EBS volume via diskmgmt.msc, then starting XE windows services, this time everything came up (TNS listener, the database service, and the management console).