Thursday, December 13, 2018

libstdc++.so.5: cannot open shared object file: No such file or directory

Description.

OS : centos 7
Mysql version : 5.1

Mysql server doesn't start at the initially just after install it. Contain the following error message in /usr/local/mysql/data/.err file.

181214 09:13:49 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
/usr/local/mysql/bin/mysqld: error while loading shared libraries: libstdc++.so.5: cannot open shared object file: No such file or directory
181214 09:13:49 mysqld_safe mysqld from pid file /usr/local/mysql/data/tap-insights-da.pid ended

>yum list compat-libstdc++-33

Installed Packages
compat-libstdc++-33.i686                                                  3.2.3-72.el7                               
compat-libstdc++-33.x86_64                                                3.2.3-72.el7                                                

"compat-libstdc" is 32 bit one. So  need to install 64 bit.

> yum install compat-libstdc++-33

Thursday, May 18, 2017

Resource temporarily unavailable

If you see a message like following while working on centos system, that means the particular user you are using has exceeded the open process limit.


bash: fork: retry: Resource temporarily unavailable
bash: fork: retry: Resource temporarily unavailable
bash: fork: retry: Resource temporarily unavailable
bash: fork: retry: Resource temporarily unavailable


So you need to increase it. Here is the way...

Login as root. Go to "limits.conf" file.

> vi /etc/security/limits.conf

Set a higher number of "nproc" value.
Add these two lines.
user          soft    nproc     65550
user          hard    nproc     65555

user - replace with your username

source : https://access.redhat.com/solutions/30316

Tuesday, May 16, 2017

Get "pretty" result always without typing .pretty() on mongo.

When executing mongo commands we put .pretty() at the end to get a readable out put.

Ex:
db.myTable.find({"id":"123"}).pretty()
However there is a way to avoid this command. Just enter the following line into "$HOME/.mongorc.js"
DBQuery.prototype._prettyShell = true
That will enable pretty print globally by default.

Thursday, April 6, 2017

Check Java application Memory consumption using jconsole

First add these JAVA OPTS to the application.

JAVA_OPTS="$JAVA_OPTS -Djava.rmi.server.hostname="
JAVA_OPTS="$JAVA_OPTS -Djava.rmi.server.useLocalHostname"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=9010"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.local.only=false"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.ssl=false"

Or to the wrapper.xml

wrapper.java.additional.14=-Djava.rmi.server.hostname=
wrapper.java.additional.15=-Djava.rmi.server.useLocalHostname
wrapper.java.additional.16=-Dcom.sun.management.jmxremote
wrapper.java.additional.17=-Dcom.sun.management.jmxremote.port=9010
wrapper.java.additional.18=-Dcom.sun.management.jmxremote.local.only=false
wrapper.java.additional.19=-Dcom.sun.management.jmxremote.authenticate=false
wrapper.java.additional.20=-Dcom.sun.management.jmxremote.ssl=false


Then start the java application.

Start jconsole. The java path should have setted.

> jconsole

Go to "Connection --> New connection".
Select "Remote" tab and give the IP and port, Click connect.
Go to "Memory" tab.



Thursday, December 29, 2016

Copy folder in linux without changing the existing permission.

 Sometimes we need to copy some folders without changing its permissions. But when we copy a folder to a new location, the new copy will have the copying person's permission. (Ex: If the copying person is 'root' then the new folder will have the permission only for root.
 One can copy the folder and then change the permission back to the original user. But this will difficult it the folder contains different permissions for different files or folders.
 So the solution for this is use "-pdR" options while copying.

> cp -pdR <file folder_name> <new_location>

Wednesday, December 7, 2016

Give root privileges for user on centos

By adding the user into 'wheel' group can give the root permission. Use the following command to add the user into wheel group. For this you should be login as root. Replace "username" with your one.

usermod -aG wheel username

Now switch to new user account from root.

> su - username

Check whether it works using a command which needs root privileges.

> sudo ls -ls /root

For the first time it will ask the user accounts password.

[sudo] password for username:

If the password is correct the command should execute with root privileges.

BUT if you receive a message like this.

username is not in the sudoers file. This incident will be reported.

That means the "wheel" group doesn't activated. To activate the group login as a root and check 'sudoers' file.

> visudo

That will open the 'sudoers' file. Go to the bottom and uncomment this line.

# %wheel        ALL=(ALL)       ALL

Now you can use root privileges.... ;)

Thursday, February 19, 2015

Block ports on Linux

To block port 80 (HTTP server), enter (or add to your iptables shell script): 

# /sbin/iptables -A INPUT -p tcp --destination-port 80 -j DROP
# /sbin/service iptables save

 Block Incomming Port 80 except for IP Address 1.2.3.4 

 # /sbin/iptables -A INPUT -p tcp -i eth1 -s ! 1.2.3.4 --dport 80 -j DROP


To block outgoing port # 25, enter:

# /sbin/iptables -A OUTPUT -p tcp --dport 25 -j DROP
# /sbin/service iptables save

You can block port # 1234 for IP address 192.168.1.2 only:

# /sbin/iptables -A OUTPUT -p tcp -d 192.168.1.2 --dport 1234 -j DROP
# /sbin/service iptables save

To unblock ports. 

 /sbin/iptables -A INPUT -p tcp --destination 12375 -j ACCEPT
 /sbin/iptables -A OUTPUT -p tcp --destination 12375 -j ACCEPT

/sbin/service iptables save

Monday, August 5, 2013

MySQL installation errors and solutions.

 libstdc++.so.5: cannot open shared object file


Some times while executing the "mysql_install_db" script we get this error.

While loading shared libraries: libstdc++.so.5: cannot open shared object file: No such file or directory

You can check whether this library file is there using this command.

>ls -l /usr/lib | grep -i libstdc++

In my case it returns
lrwxrwxrwx.  1 root root       19 Jul 26 17:34   libstdc++.so.6 -> libstdc++.so.6.0.17
-rwxr-xr-x.  1 root root   926280 Sep 21  2012 libstdc++.so.6.0.17

so I download libstdc++.so.5 rpm from here and install the rpm. After that i got the result like this.

lrwxrwxrwx.  1 root root       18 Aug  5 19:00 libstdc++.so.5 -> libstdc++.so.5.0.7
-rwxr-xr-x.  1 root root   763204 May  5 05:14 libstdc++.so.5.0.7
lrwxrwxrwx.  1 root root       19 Jul 26 17:34 libstdc++.so.6 -> libstdc++.so.6.0.17
-rwxr-xr-x.  1 root root   926280 Sep 21  2012 libstdc++.so.6.0.17

Then i try the "mysql_install_db" script and it works.

Getting (errno: 13) in mysqld.log file.

Ex:
/usr/local/mysql/bin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
[ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.

Then check the "/var/lib/mysql" ownership.
> ll /var/lib/mysql
The "mysql" folder and its child's should have the mysql user ownership.

Getting (errno: 2) in mysqld.log file.

Ex:
130805 20:08:55 [ERROR] /usr/local/mysql/bin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2)
130805 20:08:55 [ERROR] Can't start server: can't create PID file: No such file or directory

Check whether there exist a folder called "mysqld" in /var/run and has correct permission. That folder ownership should be given to mysql user.


Before try a new installation you need to delete these 5 things.
1) /var/lib/mysql
2) /usr/bin/mysql3) /var/run/mysqld
4) /usr/local/mysql    - Symbolic link
5) /usr/local/mysql-x.x.x-m2-linux-x86_64-icc-glibc23   - The extracted folder.


Log path : /var/log/mysqld.log

Thursday, June 6, 2013

Simple tool to get diff and merge text files.

I found a simple GUI tool to diff and merge text files called Meld. It provides two- and three-way comparison of both files and directories, and has support for many popular version control systems.

http://meldmerge.org/


Tuesday, February 19, 2013

How to get history of mysql commands

Actually i know how to get the shell command history on linux. We just need to type "history" and press enter. Like wise if we need to get the mysql command history, this is the way.

Go to shell.
> cat ~/.mysql_history

Monday, February 18, 2013

Alias on Linux profile

I had a problem on ubuntu (& debian)shells. That is i can't use "ll" command as i used in Fedora. Most of the time I use "ll" command just after go into a folder. Always i retyped "ls -l" to get the same out put which gives from "ll" command on fedora. So I found a simple solution for it. That is use alias on profile.

Open the profile
&gt vi ~/.profile

Add this at the bottom.
#Alias 
alias ll="ls -l"

Save and quit.
:wq

Source the profile
>source ~/.profile

Now check the result.
>ll

   You feel like fedora...

Tuesday, January 1, 2013

Chrome browser + Selenium issue.

I tried to automate the chrome browser with selenium. I just need to open the chrome browser, go to google.com, enter "land" on search box, press search and check the browser title.

Here is my code:
System.setProperty("webdriver.chrome.driver", 
           "/media/partition1/QA/selenium_automation/chromedriver");
WebDriver driver1 = new ChromeDriver();

driver1.get("http://www.google.com");
WebElement element1 = driver1.findElement(By.name("q"));
element1.sendKeys("land");
element1.submit();
System.out.println("Page title is: " + driver1.getTitle());
(new WebDriverWait(driver1, 10)).until(new ExpectedCondition() {
    public Boolean apply(WebDriver input) {
         return input.getTitle().toLowerCase().startsWith("land");
    }
});
System.out.println("Page title is: " + driver1.getTitle());
driver1.quit();

How ever when im running this i got an exception. This is the important part of it.

/opt/google/chrome/google-chrome: /lib/libz.so.1: no version information available (required by /opt/google/chrome/google-chrome)
/opt/google/chrome/google-chrome: /lib/libz.so.1: no version information available (required by /opt/google/chrome/google-chrome)
/opt/google/chrome/chrome: /lib/libz.so.1: no version information available (required by /opt/google/chrome/chrome)
/opt/google/chrome/chrome: /lib/libz.so.1: no version information available (required by /opt/google/chrome/chrome)
/opt/google/chrome/nacl_helper: /lib/libz.so.1: no version information available (required by /opt/google/chrome/nacl_helper)

I just see the browser opens and suddenly disappears. I checked my chrome version. It was 17. But the current stable version is 23. So I installed the new version. It resolved my issue.

RPM

How to install a "rpm" file on linux (Fedora)

> rpm -ivh <package>.rpm


How to uninstall an installed rpm.

First you need to find out the package name.

> rpm -qa | grep <part_of_the_package_name>

It will give you the full package name. So you can uninstall it.

> rpm -e <package_name>

Tuesday, July 24, 2012

"bash" command on Solaris machine.

Yesterday i had to connect to a Solaris machine through ssh. I faced some inconvenience when press 'tab' for generate rest of the file names, folder names etc.. Not like in Linux environment it push the cursor for 4 spaces to the right without generating the rest of the file name. hmmm.... I had to type the whole file names and folder names. :(   However I deside to find a solution for this headache, cause it becomes a real headache at the end of the day. ........... Thanks for Google.

That's a simple step. "bash". I just need to enter this command. Then its same as usual.


$ bash
bash-3.00$

Monday, June 11, 2012

How to add DNS entry in Windows 7

Open the note pad. (You have to run it as Administrator). Then open   C:\Windows\System32\ drivers\etc\hosts" file in the Note pad  [i assume your windows partission is 'C' ;)]. Add the ip address and the host name at the end of the file. The IP address should be placed in the first column followed by the corresponding host name.

Ex:
192.168.0.24     sec.office.hms

Save the file and close it.
That's all.

Tuesday, May 8, 2012

log4j common conversion pattern.



Yesterday, one of my friend asked about log4j xml file. She's new for development and wants to understand it line by line. How ever she has stuck on conversion line. hmmm... so my work starts from there.. Simply she needs to get the meaning of this line.

   <layout class="org.apache.log4j.PatternLayout">
          <param name="ConversionPattern" value="%d{DATE} %-5p [%t] %c{1} - %m%n"/>
   </layout>

This says the layout of the log lines in the log file. According to this pattern it writes a log line like this.

09 May 2012 10:50:14,125 INFO [WrapperListener_start_runner] MuleServer - Mule Server initializing...

Lets see the meanings...

%d{DATE} = %d means the date. The format goes in the {} brackets. DATE - DateTimeDateFormat. ( "dd MMM yyyy HH:mm:ss,SSS" for example, "06 Nov 1994 15:49:37,459"

%-5p = Type of the log entry. INFO, DEBUG, ERROR etc.. -5 means use 5 characters to mention it.

[%t] = Says the tread name. In hear the box brackets will cover the thread name.

%c{1} = The class name. {1} says to mention only the class name. %c will write "org.mule.MuleServer"

- = Simply add dash "-" between class name and message.

%m = The message.

%n = new line.

For quick reference.... http://www.daniel-hirscher.de/Java_files/Log4jQuickRef.pdf

Friday, April 13, 2012

How to recover MongoDB after an Unclean shutdown.

April 13th 10.48pm .... ;)

Sometimes my laptop switch off at once due to lack of battery power. It doesn't support for auto hibernate when it runs with fedora.. :(   So those times my mongod server also crashed. When i start it on the next time it ask to repair the db and direct to their help and support web site. According to that i found this command. It is a simple command to repair the db .. That's....

shell> ./mongod --repair --dbpath=<path_to_db>

I assume that you are in the mongodb bin folder... :)

Wednesday, March 21, 2012

How to find the MAC address on Windows phone. (Old versions)

My previous blog's method works for "Windows Phone 7 7.10.7720" version. But the old versions doesn't have this feature. So I found another two more methods to find out the MAC address on windows phones.

Method 1 (works on "Windows Phone 7 7.10.7720" version on LG at&t)

1) Go to phone dialer.
2) Type ##634# and press "call" button.
3) In the MFG screen enter 277634#*# as password.
4) In "Factory menu" select "Engineer Menu"
5) In "Engineer Menu" select "Device Test"
6) From "Device Test" select "WIFI Test"
7) From "WIFI Test" open "Net.Info."

You will see the MAC address... ;)

For Samsung phones. [I didn't test this method]

1) Go to phone dialer.
2) Type ##634# (might have been ##643#) and press "call" button.
3) In the MFG screen enter 277634#*# as password.
4) Go to Diagnosis.
5) enter *#1234#
6) It should bring up a menu that includes the WiFi Mac Address


Method 2 [I didn't test this one. :P]

1) Enable your router logs.
2) Then enable your phone wi-fi.
3) Select the router from your phone's wifi list and let it to connect.
4) Check the DHCP CLIENT LOG of the router.

How to find the MAC address on Windows phone.

There is a simple way to find out the MAC (Media Access Control) address.
Go to Settings -> About -> More info

That's it. Simple ;)

Portable Wi-Fi hotspot.

This is another valuable reason to buy a Nexus S phone.. ;). The phone should connect to the network first and then can start its hotspot. [Model number : Nexus s, Android version : 2.3.6]. To connect to the network, set the APN  (Access Point Names).

Menu -> Settings -> wireless network -> Mobite networks -> Access Point Names. Press Menu button. New APN.

I used a mobitel (Sri Lanka) sim. So... these are the mobitel settings

Name : Mobitel
APN : mobitel3g
proxy : 192.168.050.163
port : 8080
username :
password :
And keep all others with default values.

Then enable the data access over mobile network.
Menu -> Settings -> Wireless & networks -> Mobile networks -> Data enabled (put a tick)

Now the phone should allow to connect to the internet. [If there are enough signal strength... :)]
Ok... then convert the phone to allow other devices [laptops, phones etc.. which has Wi-Fi] to use the same network connection. In other word make it a "hotspot".

Steps...
Menu -> Settings -> Wireless & networks -> Tethering & portable hotspot -> Portable Wi-Fi hotspot (put a tick)
You can configure Network SSID (Service Set Identifier) and password in hotspot configurations.

Your portable hotspot is ready to use.... ;)