Keep Your Linux SSH Session From Disconnecting

Global Configuration

Add the following line to the /etc/ssh/ssh_config file:

ServerAliveInterval 60

The number is the amount of seconds before the server with send the no-op code.

Current User Configuration

Add the following lines to the ~/.ssh/config file (create if it doesn’t exist)

Host *hostname.com
   ServerAliveInterval 60

Ref: http://www.howtogeek.com/howto/linux/keep-your-linux-ssh-session-from-disconnecting/

 

Keep Your Linux SSH Session From Disconnecting

GSON Null Object Support

The default behaviour that is implemented in Gson is that null object fields are ignored.  This allows for a more compact output format; however, the client must define a default value for these fields as the JSON format is converted back into its Java.

Here’s how you would configure a Gson instance to output null:
Gson gson = new GsonBuilder().serializeNulls().create();

NOTE: when serializing nulls with Gson, it will add a JsonNull element to the JsonElement structure.  Therefore, this object can be used in custom serialization/deserialization.

Here’s an example:

public class Foo {
  private final String s;
  private final int i;

  public Foo() {
    this(null, 5);
  }

  public Foo(String s, int i) {
    this.s = s;
    this.i = i;
  }
}

Gson gson = new GsonBuilder().serializeNulls().create();
Foo foo = new Foo();
String json = gson.toJson(foo);
System.out.println(json);

json = gson.toJson(null);
System.out.println(json);

======== OUTPUT ========
{"s":null,"i":5}
null

Ref: https://sites.google.com/site/gson/gson-user-guide#TOC-Null-Object-Support

GSON Null Object Support

Hadoop save “parquet” error OutOfMemoryError: PermGen space

This may be caused by many reasons, the following is solution for  the one that I faced

  1. Set max perm size
    -Xms256m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m

    You should modify the value as long as suitable for your situation

  2. Using higher jdk version
    In this case I update my jdk version to 8

 

Hadoop save “parquet” error OutOfMemoryError: PermGen space

Linux Increase “Open Files Limit”

If you are getting error “Too many open files (24)” then your application/command/script is hitting max open file limit allowed by linux. You need to increase open file limit as below:

Increase limit

Per-User Limit

Open file: /etc/security/limits.conf

Paste following towards end:

*         hard    nofile      500000
*         soft    nofile      500000
root      hard    nofile      500000
root      soft    nofile      500000

 

500000 is fair number. I am not sure what is max limit but 999999 (Six-9) worked for me once as far as I remember.

Once you save file, you may need to logout and login again.

Verify New Limits

Use following command to see max limit of file descriptors:

cat /proc/sys/fs/file-max

Ref: https://rtcamp.com/tutorials/linux/increase-open-files-limit/

Linux Increase “Open Files Limit”

How to run nodejs app as background service (daemon)

There are 2 ways to make your node js app run as background service:

  1. Using nohup
    Just type the following from your terminal:

    $ nohup node [yourapp.js] &
  2. Using forever
    Install forever by typing the following command:

    $ npm install forever

    Usage

    Using forever from command line

    $ forever start server.js

    Using an instance of Forever from Nodejs

    var forever = require('forever');
    
      var child = new (forever.Forever)('your-filename.js', {
        max: 3,
        silent: true,
        args: []
      });
    
      child.on('exit', this.callback);
      child.start();

Ref: http://stackoverflow.com/questions/4903570/how-does-one-start-a-node-js-server-as-a-daemon-process

How to run nodejs app as background service (daemon)

How to upgrade PHP version 5.3.x to 5.4.x or 5.5.x on CentOS

Step1. Add EPEL and Remi repositories onto your system:

On CentOS 6.x 32-bit

wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm

On CentOS 6.x x86_64 (64-bit)

wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm

upgrade-php-centos-1

Step 2 – Now enable your newly added Remi repo. Open the /etc/yum.repos.d/remi.reporepository file using a text editor of your choice

vi /etc/yum.repos.d/remi.repo

Step 3 – Edit enabled=0 line to enabled=1:

4.a – Update to PHP 5.4, in [remi] section:
upgrade-php-centos-4

4.b – Update to PHP 5.5, in [remi-php55] section:
upgrade-php-centos-4b

Step 4 – Now update yum

yum update -y

upgrade-php-centos-5

Step 5 – Done. Now you can check using this command:

php -v

Screen Shot 2015-09-20 at 1.12.47 AM

Now you can test your PHP script on your browser and hope everything still runs smoothly.

Source from: http://www.servermom.org/upgrade-php-53-54-55-centos/1534/

How to upgrade PHP version 5.3.x to 5.4.x or 5.5.x on CentOS