Linux

All posts in the Linux category

LVS (Load balancer) Error Fix : nanny[2687]: READ returned error 104:Connection reset by peer

Published August 6, 2014 by Siva

I have updated the centos 6.2 -> 6.5. After the My LVS(Linux Virtual server) load balancer throwing a below error in /var/log/messages/ frequently.
I have spent 2 days to resolve this issue. I would like to share this to everyone.

Aug 6 02:28:07 lb01 nanny[2687]: READ returned error 104:Connection reset by peer
Aug 6 02:28:07 lb01 nanny[2685]: READ returned error 104:Connection reset by peer
Aug 6 02:28:09 lb01 nanny[2686]: READ returned error 104:Connection reset by peer
Aug 6 02:28:12 lb01 nanny[2688]: READ returned error 104:Connection reset by peer
Aug 6 02:28:13 lb01 nanny[2687]: READ returned error 104:Connection reset by peer
Aug 6 02:28:13 lb01 nanny[2685]: READ returned error 104:Connection reset by peer
Aug 6 02:28:15 lb01 nanny[2686]: READ returned error 104:Connection reset by peer

Solution: 1) Simple check you hosts file.
Make sure the loopback entry in /etc/hosts.
127.0.0.1 localhost.localdomain localhost

2) Check both LB servers having same timezone.

Once verified, reload your config,

1) service ipvsadm reload
2) service pulse reload

Thank you.

Export PUTTY Sessions list to Another Computer – Simple

Published January 27, 2014 by Siva

Here we are going to see, How to Export PUTTY Sessions list to Another Computer,

    Run the below command on a source system ( to taking backup / export existing session list)

regedit /e “%userprofile%\desktop\putty-sessions.reg” HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions

    Do the below taskson a remote system ( Importing from reg file)

to copy the putty-sessions.reg file on remote system.

then right click on a file & merge it.

reg2

Thats it.

Compiling & Installing RRDtool – Error Fix

Published December 21, 2013 by Siva

RRDtoool:

Round Robin Database Tool(RRD) data analysis part of RRDtool is based on the ability to quickly generate graphical representations of the data values collected over a definable time period.

tar -xvf rrdtool-1.4.8.tar.gz

[local]# cd rrdtool-1.4.8
[rrdtool-1.4.8]#
./configure –enable-shared –prefix=/usr/local/rrdtool

I got the below error,

Then i found the following packages are dependencis..

configure: error: Please fix the library issues listed above and try again.

yum -y install zlib zlib-devel libpng libpng-devel freetype freetype-devel libart_lgpl libart_lgpl-devel libxml2 libxml2-devel gd gd-devel cairo cairo-devel pango pango-devel

Then compile then

#make && make install

Enjoy with open source…. !!

DynDNS Client configuration on Linux systems

Published December 16, 2013 by Siva

What is DynDNS:

As you know any domain should be pointed to an IP in order to be seen in browsers. If you don’t have a connection to the internet with static IP (cable, DSL, etc.), then it becomes tedious to set an A record for your domain every time your IP changes. Dynamic DNS is a feature that will allow you to point a domain name to any IP and the changes are almost immediate.

For example, you have a server at home and host a website on your computer. But you don’t have a static IP, that is the IP changes each time you reconnect to the Internet, you can setup Dynamic DNS for the domain.

Download from the below link:

http://sourceforge.net/projects/ddclient/

INSTALLATION:

1)   cp ddclient /usr/sbin/
2) mkdir /etc/ddclient
3)  cp sample-etc_ddclient.conf /etc/ddclient/ddclient.conf
 4)  vi /etc/ddclient/ddclient.conf
  — and change hostnames, logins, and passwords appropriately

Example :

  ## For those using Redhat style rc files and using daemon-mode:
  cp sample-etc_rc.d_init.d_ddclient /etc/rc.d/init.d/ddclient
  ## enable automatic startup when booting
  /sbin/chkconfig –add ddclient
  ## start the first time by hand
  /etc/rc.d/init.d/ddclient start

  ## If you are not using daemon-mode, configure cron and dhcp or ppp
  ## as described below.
protocol=namecheap
use=web, web=checkip.dyndns.com/, web-skip=’IP Address’
server=dynamicdns.park-your-domain.com
login=mydomain.com
password=’XXXXXXXXXXXXXXXXXXXXXX’

# I need to update for my subdomain
mysubdomain

Debug :

ddclient -daemon=0 -debug -verbose -noquiet

Cache file location :

/var/cache/ddclient/ddclient.cache

Force update:

ddclient –force

API:

http://dynamicdns.park-your-domain.com/update?host=Mysubdomain&domain=mydomain.com&password=XXXXXXXXXXXX&ip=100.1.1.1

 

—– End —

Setup Load-Balancing Cluster with LVS and Piranha on Centos 6

Published December 3, 2013 by Siva

Terminology:

piranha – This is a package that provides a configuration interface for setting up LVS.

ipvs The name of the module that allows a load-balancing on Linux.

ipvsadm – A package (and a command) that makes administrating ipvs possible. Be aware, you either user piranha-gui or /etc/sysconfig/ipvsadm to configure ipvs.

LVS Linux Virtual Server – the project name of all tools used in this document.

pulse – A service (/etc/init.d/pulse) that runs on both active and backup machine and opens a port to make checking possible. piranha-gui configures everything, pulse actually activates all configurations.

nanny A process started by pulse to monitor the realservers.

nat – Network Address Translation. A common combination with LVS. In case NAT is uses, the loadbalancer/director/LVS accepts traffic on one the VIP and sends traffic to the realservers. Be aware, the current implementation of ipvsadm does not properly use Source NAT, it currently does not rewrite the source address.

direct routing – A method of routing available in LVS. Traffic is received on the VIP, sent through to the realservers. The realservers receive the traffic as if it was sent to the VIP, so the VIP must be configured on the realservers. To avoid arp-caches to register the wrong MAC-address-IP-address combination, a few “tricks” must be done.

wlc – Weighted Least Connections, an algorithm to balance load to realservers.

VIP Virtual IP. – The IP-address the service is configured on.

RIP Real server IP. – The IP-address of a real-server.

realserver – The server providing the actual service. This can be Linux, Windows, whatever.

This setup guide is about building web cluster with a pair of Linux loadbalancers as frontend.
It uses Linux Virtual Server(LVS) and Piranha. Piranha is a web-based gui installed in LVS Routers primarily to generating a valid /etc/lvs.cf file.

Start by installing LVS on LVS Router.

[root@lvsrouter ~]# yum groupinstall “Load Balancer”
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
ipvsadm x86_64 1.25-10.el6 base 41 k
piranha x86_64 0.8.6-2.el6_4.1 updates 623 k
Installing for dependencies:
libedit x86_64 2.11-4.20080712cvs.1.el6 base 74 k
libnl x86_64 1.1-14.el6 base 121 k
php x86_64 5.3.3-22.el6 base 1.1 M
php-cli x86_64 5.3.3-22.el6 base 2.2 M
php-common x86_64 5.3.3-22.el6 base 524 k

Transaction Summary
================================================================================
Install 7 Package(s)

Total download size: 4.7 M
Installed size: 18 M
Is this ok [y/N]: y

Start piranha and pulse services on reboot.

chkconfig piranha-gui on
chkconfig pulse on

Set a password for piranha web

/usr/sbin/piranha-passwd

Allow ports in iptables

vi /etc/sysconfig/iptables
-A INPUT -m state –state NEW -m tcp -p tcp –dport 3636 -j ACCEPT

Edit piranha config

vi /etc/sysconfig/ha/conf/httpd.conf

Start the piranha gui service

service piranha-gui start

For LVS router to forward network packets properly to real servers, each LVS router node must have IP forwarding turned on. Turn on packet forwarding by editing sysctl.conf:

vi /etc/sysctl.conf
net.ipv4.ip_forward = 1

Reload sysctl

sysctl -p /etc/sysctl.conf

Start http services on the Real Servers

service httpd start

On the LVS Router, log in to the Piranha web ui to begin configuration.

Enter Primary Router’s IP address in “Global Settings”->”Primary server public IP:”.
CENTOS Piranha Global Settings

Enter Redundant Router’s IP address in “Redundancy”->”Redundant server public IP:”.
CENTOS Piranha Redundancy

Enter Virtual Server settings in “Virtual Servers”->”Virtual Server”.
CENTOS Piranha Virtual Servers

Include Real Server settings in “Virtual Servers”->”Real Server”.
CENTOS Piranha Real Server

On each time the Piranha Gui was changed, have to sync the settings to Backup Routers,
and restart the pulse service on both routers.

service pulse restart

To see the virtual server’s statistics, use “watch ipvsadm”.


[root@lvsrouter ~]# watch ipvsadm

Courtesy : http://iomeweekly.blogspot.in/2013/04/setup-load-balancing-cluster-with-lvs.html

Setup sSMTP configuration , Sending email without smtp service

Published December 3, 2013 by Siva

Follow the below steps on terminal…

# yum -y install ssmtp

If you have Sendmail installed, you need to run the following command below to change your default Mail Transfer Agent (MTA): –

# alternatives –config mta

There are 2 programs which provide ‘mta’.

Selection Command
———————————————–
*+ 1 /usr/sbin/sendmail.sendmail
2 /usr/sbin/sendmail.ssmtp

Enter to keep the current selection[+], or type selection number: 2

You can verify the sendmail binaries by running the command below: –

# sendmail -V
sSMTP 2.61 (Not sendmail at all)

Now, sSMTP is installed and we will configure the mail server info to relay outgoing email. We going to create new configuration files as below: –

# mv /etc/ssmtp/ssmtp.conf /etc/ssmtp/ssmtp.conf.orig
# touch /etc/ssmtp/ssmtp.conf
# mv /etc/ssmtp/revaliases /etc/ssmtp/revaliases.orig
# touch /etc/ssmtp/revaliases

Next, we will configure sSMTP to forward email to any shared hosting server either running CPanel or DirectAdmin.

Include the following below in /etc/ssmtp/ssmtp.conf file: –

root=postmaster
mailhub=mail.yourdomain.com:587
Hostname=localhost
FromLineOverride=YES
AuthUser=username@yourdomain.com
AuthPass=YourPassWord
UseSTARTTLS=YES

Include the following below in /etc/ssmtp/revaliases file: –

root:username@yourdomain.com:mail.yourdomain.com:587

If you an option to forward email to Gmail server, you can configure using steps below.

Replace previous configuration to below in /etc/ssmtp/ssmtp.conf file: –

root=postmaster
mailhub=smtp.gmail.com:587
Hostname=username@gmail.com
FromLineOverride=YES
AuthUser=username@gmail.com
AuthPass=YourPassWord
UseSTARTTLS=YES

Replace previous configuration to below in /etc/ssmtp/revaliases file: –

root:username@gmail.com:smtp.gmail.com:587

Next, you can start sending email using your preferred email server using command below: –

# echo “Testing outgoing email” | mutt -s “Testing” receipient@receivermail.com

Finally, with all the configuration above I hope you are able to use and enjoy your sSMTP to send an email.

Thank you.