Monday, 5 September 2016

Ubuntu Locale Warning from Perl

Error

perl: warning: Please check that your locale settings:
    LC_ALL = (unset),
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

Fix

Add the below two entries in ~/.bashrc

LC_CTYPE=en_US.UTF-8
LC_ALL=en_US.UTF-8

( or )

sudo locale-gen

sudo dpkg-reconfigure locales

Thursday, 1 September 2016

No apport report written because MaxReports is reached already

This error comes mostly because of the debian broken packages. To fix broken packages, follow the below simple steps

Lets say for instance, I have foreman broken packages, to fix foreman installation,

sudo dpkg --purge foreman
sudo dpkg --purge foreman-proxy
sudo dpkg --purge foreman-compute
sudo dpkg --purge foreman-libvert
sudo dpkg --purge foreman-sqlite3
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get update
sudo apt-get -f install

Tuesday, 30 August 2016

activesupport requires Ruby version >= 2.2.2

Rails installation error in Ubuntu

ERROR:  Error installing rails:
        activesupport requires Ruby version >= 2.2.2

Fix

gem install rails -v 4.2.2

Tuesday, 23 August 2016

Remove APT Repository from newer versions of Ubuntu

To remove apt repository from newer versions of Ubuntu, Just type the below command in terminal

cd /etc/apt/sources.list.d

and then remove the files manually using

sudo rm -f <<filename>>.list
sudo rm -f <<filename>>.save

Puppet Master & Client Uninstallation in Ubuntu

Uninstall puppetmaster-common

sudo apt-get remove puppetmaster-common

This will remove just the puppetmaster-common package itself.

Uninstall puppetmaster-common and it's dependencies

sudo apt-get remove --auto-remove puppetmaster-common

This will remove the puppetmaster-common package and any other dependant packages that are no longer needed.

Purging your config/data

If you also want to delete your local/config files for puppetmaster-common then this will do the trick.

sudo apt-get purge puppetmaster-common

Or similarly, like this


sudo apt-get purge --auto-remove puppetmaster-common




Uninstall just puppet

sudo apt-get remove puppet

This will remove just the puppet package itself.

Uninstall puppet and it's dependencies

sudo apt-get remove --auto-remove puppet

This will remove puppet package and any other dependant packages that are no longer needed.

Purging your config/data too

If you also want to delete your local/config files for puppet then this will do the trick.

sudo apt-get purge puppet

Or like this,

sudo apt-get purge --auto-remove puppet

Saturday, 19 December 2015

Android Studio JVM Error

Error:  android studio was unable to find a valid JVM

Fix:

  •    Go to Applications->Android Studio
  •    Right click and choose Show Package Contents
  •    Open Info.plist
  •    Change the key JVMversion to 1.7* or 1.8* ( depends on which jdk is installed in your mac )

Sunday, 22 November 2015

setColor cocos2dx compile error

Error: setColor cocos2dx compile error

Fix:

  ccColor3B c3 = { 0, 0, 0 };
  selectedImage->setColor(c3);

Saturday, 14 November 2015

syntax error: unknown user in statoverride file

Fix:    sudo sed -i '/<user>/d' /var/lib/dpkg/statoverride

Note: Replace <user> with your real userID

installation error: install_failed_media_unavailable

Fix:    Make sure that you have enough space in your device

Friday, 6 November 2015

Turn ON MySql Event Scheduler feature

By default MySql event scheduler settings are turned OFF. Execute the below commands to turn ON event scheduling in MySql

show variables where variable_name='event_scheduler';

+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| event_scheduler | OFF   |
+-----------------+-------+


SET GLOBAL event_scheduler = ON;


show variables where variable_name='event_scheduler';

+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| event_scheduler | ON    |
+-----------------+-------+


Monday, 19 October 2015

How to find and kill a process that is using a particular port in ubuntu

1) sudo netstat -lpn |grep :8080
    
      and press Enter

      You can see the PID that occupied the port 8080

2) sudo kill -9 xxxx

      Now you can use the port 8080 for some other application

Memory constraints and limitations of Virtual Private Server

Before you decide to go for Virtual Private Server( VPS ), make your requirements very clear and know the memory limitations of VPS. Long time back I purchased a VPS and I was able to install MySql, Glassfish, Nginx, mail server, puppetmaster and client, memcached, git, etc. Later on I was trying to improve the performance of Glassfish cluster instances and Mysql.
I was able to make changes in memory settings MySql and optimized its performance and tested with mysqltuner. No problem!
Since I had two glassfish cluster instances running on the same machine, I thought of increasing JVM heap size of both instances to 5G. Earlier I had allocated only 2G and I was trying to push this to 5G for both instances.
After making changes in cluster xml, I started 1st instance and it was successful. Instance one was ready to serve requests.
When I try to start the 2nd instance, BOOOOOM!, 2nd instance throws "Out Of Memory Exception", Couldn't reserve enough space for JVM.

Then I checked the available memory in my machine using "free -g". It displayed like this 17G free available memory and only 3G occupied.

What does that mean? 17GB still left but unable to allocate.

Then I spoke to my hosting provider guys and I have been told that it doesn't work the way you think.

This command:
       "cat /proc/user_beancounters" 


You have to investigate the output of the above command to understand why it couldn't allocate 5G to second instance.

Look for this row:
       privvmpages
Check for limit column. That number is the maximum limit that can be allocated to any application. In my case, it was just about 5G. Thats it!
They will not allow you to edit and increase this limit. You have to go for either large vps or a dedicated server to allocate more memory.

Saturday, 17 October 2015

Increase memcached memory limit in ubuntu

Follow the below simple steps to increase memcached memory limit for production use:

1) In Ubuntu, memcached configuration file is located at /etc/



2)  increase the value of -m 64 ( default ) to 2 to 3g.


3) Restart memcached server

                /etc/init.d/memcached restart

Tuesday, 13 October 2015

Display Number of Processors in Linux

The below command spits the number of processors of Linux machine. In Linux, /proc/cpuinfo has all the processor information for all current processors in your machine.

cat /proc/cpuinfo | grep processor | wc -l

or

nproc

or

lscpu gathers cpu architecture information in human readable format

lscpu


Simultaneous TCP connection limitations of Virtual Private Server ( VPS )

Thinking that one VPS machine can handle more than 100k concurrent users, I have configured nginx web server to handle quite a large number of concurrent users and adjusted glassfish web instance max connection, thread pools and acceptor threads to a large and optimized values.
I tested this setup with quite a large number of users but it was not going beyond 3k users concurrently. Finally I came across the network tcp connection limitations of vps server and restrictions made by the hosting providers. In order to make these many number of concurrent users even one dedicated machine is not enough. We need to have a cloud setup.

I don't believe that even a good dedicated server can handle 100k TCP requests
simultaneously. Your vServer is limited by the user_beancounters. You can
check these with

cat /proc/user_beancounters

The numtcpsock parameter will show you how many TCP connections can be handled in parallel.

How to check Java Max Heap Size in Ubuntu


java -XX:+PrintFlagsFinal -version | grep -iE 'HeapSize|PermSize|ThreadStackSize'

Tuesday, 26 November 2013

Native Query Mapping to Transient Fields of Entity class

Native queries are often a problem when comes to mapping with customized Entity classes. Especially classes with transient fields. To overcome this problem we have a special annotation available in JPA since version 1.0.
                                      @SqlResultSetMapping
That will do the trick for you!
This type of mapping is called scalar mapping. The only problem in choosing JPA is, the community is very limited and very limited resources are available internet. For complex JPA queries, most struggle to find a solution.
So I am going to show an example of mixing entity and scalar mapping.

@ColumnResult(name = "progress") does the scalar mapping. Remember that when you write your native query, It must have a column with alias progress.

For example: select p.*, count(*) as progress from project p
We can also use @SqlResultSetMapping to map different Entities from one native query. I will show this example in my next post.

Thursday, 31 October 2013

How to make java program run as a service/daemon in linux

Create a shell script as below
Now move this file to init.d location and issue update command to automatically start this as service when system reboots.

Thursday, 17 October 2013

Connecting to Plesk Mysql through Command Line

Connecting to Plesk Mysql though Command Line:

     Connection to plesk mysql on ubuntu systems doesn't work in the usual way. Plesk mysql password is stored in a different location and its encrypted too. So we can't keyin the normal password through commandline unless you know the complete encrypted form.So, mysql -u root -p command is not going to work for you. Use the below command to connect to plesk mysql on ubuntu systems through command line. /etc/psa/.psa.shadow ( this is the place where your plesk mysql password is stored ). Use "cat" command to print the password right after -p.

   
  mysql -uadmin -p`cat /etc/psa/.psa.shadow`  

Sunday, 6 October 2013

Install Android in NetBeans 7.3

Android in Netbeans 7.3

Please follow the below steps to install Android in NetBeans 7.3


Step1:

  Open Netbeans, Go to Tools->Plugins, and select Settings Tab, Click on Add button

Step 2:

  In URL field, paste the below url
         http://nbandroid.org/release72/updates/updates.xml     

  In Name Field, "Android"





Step 3: 

  Now go to Available Plugins tab and search for "Android", select android plugin and click Install button and restart NetBeans.

Step 4:

  Create new android project: 
      select "Android" category and "Android Project" from Projects section.



Step 5: Provide project Name, Location, package name, main activity and select android target platform.




 If Android SDK is not configured, Please go to android developer site and download the latest android sdk 
http://developer.android.com/sdk/index.html

and configure its path in netbeans ( Go to Tools->Options and select Android tab )