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/

Monday, November 23, 2015

Chrome - Multiple Chrome icon at the taskbar

Problem


When I am fixing my laptop, I messed up with the Chrome Person setting. 



Although Chrome shows only 1 users, it will pop up an addition icon at the task bar whenever I clicked on the pinned Chrome icon (see below)


The previous behavior is only one Chrome icon at the task bar (see below)




Solution

Remove "C:\Users\YOUR_USERNAME\AppData\Local\Google\Chrome\User Data" and restart Chrome will fix the issue.


Reference:

https://code.google.com/p/chromium/issues/detail?id=91650

Tuesday, October 13, 2015

Regex - Find line that contain certain words

When you are using text editor, such as Notepad++, which support regular expression search, to analyze log file, below are some regular expression that could be useful

Basic


... | ...      Means boolean Or. Example, apple | pear match apple or pear

(...)         Means grouping. Example, gr(a|e)y match gray or grey

?             Means there is zero or one of the preceding element. Example, colo?ur match color or colour

*             Means there is zero or more of the preceding element. Example, ab*c match ac, abc, abbc, etc..

+             Means there is one or more of the preceding element. Example, ab+c match abc, abbc, etc

^             Means match starting position of the line. Example, ^abc match abcxyz but not xyzabc

$             Means match ending position of the line. Example, abc$ match xyzabc but not abcxyz

.              Means match any single character. Example, .at match cat, hat, lat, etc....

\b            Means word boundary. It is typically used to avoid accidentally matching a word that appears inside some other word. For example, \bcat\b doesn't match catfish, but it matches cat regardless of what punctuation and whitespace surrounds it.

Example

1. Match exact word in a line

^hello&

The above match hello exactly. No character before or after.

2. Match zero or more occurrences of any character

hello.*world

The above match helloANYthinGworld as well as helloworld.

3. Find line containing a specific words.

^.*\b(Some Word)\b.*$

The above will search each line which contain Some Word

4. Find line containing any of the words

^.*\b(apple|orange|pears|durian)\b.*$

The above will search each line which contain apple or orange or pears or durian


Reference

1. http://www.autohotkey.com/docs/misc/RegEx-QuickRef.htm