Monday, July 18, 2016

Oracle - Enabling Oracle XE APEX

I had been trying to figure where and why can't I log into my Oracle 11g XE APEX. The following are the steps to fix my APEX

1. Find out which port is binded for APEX. For this, you can use lsnrctl command to find it out

$ lsnrctl status | grep HTTP
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=tng-l.localdomain)(PORT=12345))(Presentation=HTTP)(Session=RAW))

The above shows that my APEX is binded to port 12345. So, the URL will be http://hostname:12345apex/apex_admin

2. Next, when I access the url from the browser, it requires me to provide a username password in a authentication dialog, and this dialog always display with either "the server says xdb" or "the server says APEX"

For me, this is telling me that my Oracle has not been set up for remote access. To fix this, I log into Oracle database instance from the command line and issue a procedure call as follow

$sqlplus / as sysdba
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

SQL> EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);
SQL> exit

After the above, you may need to restart your Oracle database. Then, try to log into APEX again. It should bring you to the log in page which look like


3. Now, I had also forgotten my APEX password. So, I have to reset it with the following in the command line

$sqlplus / as sysdba
Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

SQL> @apxxepwd admin
SQL> exit

The above will reset the default Administrator account (username: admin) with the password: admin

You can now log into the APEX with

Username: admin
Password: admin

The APEX will then ask you to change the Administrator password.

There you go, you can start using APEX.

Wednesday, May 18, 2016

LDAP - Create encrypted user password

In Person object class, there is a userPassword attribute and LDAP usually use this to store user password.

To add an encrypted password to the LDAP userPassword attribute, you could

1. Use ldappasswd command

ldappasswd -xv -D "cn=Manager,dc=example,dc=com" -w secret -S "cn=user1,dc=example,dc=com"

where

x --> Use simple authentication
v --> Run in verbose
D --> bind DN
w --> password for simple authentication
-S --> prompt for new password

2. Use slappasswd command

$ /usr/local/sbin/slappasswd
New password:
Re-enter new password:
{SSHA}a6a4/lrXhERF&14qesnZZAAkCgIUvSDOx


It will ask for your password and generate a SSHA password. Copy the output and put at the userPassword attribute in your ldif file.

Wednesday, April 27, 2016

LDAP - Adding inetOrgPerson schema to OpenLDAP

By default, inetOrgPerson schema is not included in the slapd.conf. You will need the following steps to add inetOrgPerson schema to OpenLDAP

1. Edit slapd.conf with any editor tools. The slapd.conf usually is located at /usr/local/etc/openldap and require sudo access to edit the file.

2. Add  the following

include        /usr/local/etc/openldap/schema/cosine.schema
include         /usr/local/etc/openldap/schema/inetorgperson.schema

to the top section of the slapd.conf file. Please note that the order is important. cosine.schema is required because attribute type audio is defined in cosine.schema.

3. Restart the LDAP with "su root -c /usr/local/libexec/slapd"




Tuesday, March 15, 2016

Oracle - ORA-01034: ORACLE not available

When you see the following error

ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
Process ID: 0
Session ID: 0 Serial number: 0

and your ORACLE_HOME is set correctly. You may want to check if your ORACLE_SID spelled with wrong case. 

ORACLE_SID is case sensitive in Linux

I saw this https://asktom.oracle.com/pls/asktom/f?p=100:11:0::NO::P11_QUESTION_ID:318216852435

The SID is a site identifier. It plus the Oracle_home are hashed together in Unix to create a unique key name for attaching an SGA. If your Oracle_sid or Oracle_home is not set correctly, you'll get "oracle not available" since we cannot attach to a shared memory segment that is identified by magic key.

From Oracle website, the basic format of tnsnames.ora is

net_service_name= 
 (DESCRIPTION= 
   (ADDRESS=(protocol_address_information))
   (CONNECT_DATA= 
     (SERVICE_NAME=service_name))) 

net_service_name can be use when connecting with sqlplus

CONNECT username@net_service_name

If no net_service_name is given, it will use ORACLE_SID

Connectivity Concepts from Oracle is a good read about Service name and SID.


Tuesday, February 23, 2016

Linux - Adding a swap file to RHEL

It is very possible that you may want to increase swap space after installation. For myself, my server is running out of memory, both physical and virtual. So as a workaround, I tried the following to increase my swap space. Although swap partition is recommended, I chose swap file because it will be less disruptive to the users (ie, do not need to reboot..)

To add a swap file:

Determine the size of the new swap file in megabytes and multiple by 1024 to determine the block size. For example, the block size of a 8GB swap file is 8192000.

1. At a shell prompt as root, type the following command with count being equal to the desired block size:

dd if=/dev/zero of=/swapfile bs=1024 count=8192000

The command output is

$ dd if=/dev/zero of=/swapfile bs=1024 count=8192000
8192000+0 records in
8192000+0 records out
8388608000 bytes (8.4 GB) copied, 25.3272 s, 331 MB/s

2. Setup the swap file with the command:

mkswap /swapfile

The command output is

$ mkswap /swapfile
mkswap: /swapfile: warning: don't erase bootbits sectors
        on whole disk. Use -f to force.
Setting up swapspace version 1, size = 8191996 KiB
no label, UUID=7s1166af-ls99-e938-lpos-p0a9000e1234


3. To enable the swap file immediately but not automatically at boot time:

swapon /swapfile

This command does not have any output

4. To enable it at boot time, edit /etc/fstab to include:

/swapfile               swap                    swap    defaults        0 0

The next time the system boots, it enables the new swap file.

This command does not have any output

5. After adding the new swap file and enabling it, verify it is enabled by viewing the output of the command cat /proc/swaps or free.

You could also use Top or HTop command to see the additional swap amount. Or, you could ls -al / to see the swapfile

$ ls -al /
...
-rw-r--r--    1 root root 8388608000 Jul  5 22:21 swapfile
...

The above is reference from RedHat System Administrator Guide with my own experience added.


Tuesday, January 12, 2016

Linux - sed to clean up "color codes" or escape sequence

If you see

drwxr-xr-x   23 abc xyz          4096 May 24  2011  [00;34m. [00m/
drwxrwsr-x    4 abc xyz          4096 May  3 01:14  [00;34m.. [00m/

in your directories, you could use the following to remove the color code.


sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"


Reference:

1. http://www.commandlinefu.com/commands/view/3584/remove-color-codes-special-characters-with-sed

Wednesday, December 16, 2015

WebSphere - Error 404: SRVE0190E: File not found: {0}

When you are accessing a URL from WebSphere Application Server and you encounter the following error

Error 404: SRVE0190E: File not found: {0}

this could means that your WebSphere Application Server is misconfigured.

This could happen if you are trying to access a URL which is actually a servlet mapping and the actual URL/resource does not actually exist.

To workaround this problem, set the following in your WebSphere Application Server

com.ibm.ws.webcontainer.invokefilterscompatibility=true

Resource:

1. http://www-01.ibm.com/support/knowledgecenter/SS7JFU_7.0.0/com.ibm.websphere.express.doc/info/exp/ae/rweb_custom_props.html?cp=SS7JFU_7.0.0%2F1-15-5-9522.

2.  http://frightanic.com/software-development/solution-to-error-404-srve0190e-on-websphere-6-1/