How to install Mono Framework on Linux Server (CentOS)

When you compile Mono from the source, you can install newer versions than are offered by Novell.

Mono versions are available at:
http://download.mono-project.com/sources/mono/

Let’s Install all the Dependencies
Run the below as root

# yum install bison gettext glib2 freetype fontconfig libpng libpng-devel libX11 libX11-devel glib2-devel libgdi* libexif glibc-devel urw-fonts java unzip gcc gcc-c++ automake autoconf libtool make bzip2 wget

Time to Download and Compile
Run the below as root

# cd /usr/local/src

# wget http://download.mono-project.com/sources/mono/mono-2.10.8.tar.gz

# tar zxvf mono-2.10.8.tar.gz

# cd mono-2.10.8

# ./configure –prefix=/usr/local

# make && make install

If you do receive “Out of Memory” errors, run the below:

# ulimit -v unlimited

How to Install Mtop (MySQL Database Server Monitoring)

mtop (MySQL top) is an open source real time MYSQL Server monitoring program written in Perl language that shows queries which are taking longer time to process and kills those longer queries after certain number of specified time. Mtop program enable us to monitor and identify performance and related issues of MySQL Server from the command line interface similar to Linux Top Command.

index

Mtop includes zooming feature that display query optimizer information of a running queries and killing queries, it also shows statistics of server, configuration information and some useful tuning tips to optimize and improve MySQL performance.

Please check some of the following features offered by Mtop program.

  1. Display real time MySQL server queries.
  2. Provides MySQL configuration information.
  3. Zooming feature to display process query.
  4. Provides query Optimizer information for a query and ‘killing’ queries.
  5. Provides MySQL tuning tips.
  6. Ability to save output in a .mtoprc configuration file.
  7. Provides Sysadmin recommendation page (‘T‘).
  8. Added queries/second to main header.
  9. Added per second info to stats screen.

In this article we’re going to show how to install Mtop (MySQL Top) program under RHEL 6.3/6.2/6.1/6/5.8/5.6/4.0, CentOS 6.3/6.2/6.1/6/5.8/5.6/4.0 and Fedora 17,16,15,14,13,12 using RPMForge repository via YUM Command.

Enable RPMForge Repository in RHEL/CentOS 6/5/4 and Fedora 17-12

First, you need to enable RPMForge repository under your Linux machine to download and install latest version of MTOP program.

Install RPMForge on RHEL/CentOS 6

Select the following links based on your Linux architecture to enable RPMforge repository under your Linux box. (Note : Fedora user’s don’t need to enable any repository under Fedora box).

For RHEL/CentOS 6 32-Bit OS
# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm
# rpm -Uvh rpmforge-release-0.5.2-2.el6.rf.i686.rpm
For RHEL/CentOS 6 64-Bit OS
# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
# rpm -Uvh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

Install RPMForge on RHEL/CentOS 5

For RHEL/CentOS 5 32-Bit OS
# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
# rpm -Uvh rpmforge-release-0.5.2-2.el5.rf.i386.rpm
For RHEL/CentOS 5 64-Bit OS
# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
# rpm -Uvh rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm

Install RPMForge on RHEL/CentOS 4

For RHEL/CentOS 4 32-Bit OS
# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el4.rf.i386.rpm
# rpm -Uvh rpmforge-release-0.5.2-2.el4.rf.i386.rpm
For RHEL/CentOS 4 64-Bit OS
# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el4.rf.x86_64.rpm
# rpm -Uvh rpmforge-release-0.5.2-2.el4.rf.x86_64.rpm

Import RPMForge Repository Key in RHEL/CentOS 6/5/4

# wget http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
# rpm --import RPM-GPG-KEY.dag.txt

Install Mtop in RHEL/CentOS 6/5/4 and Fedora 17-12

Once you’ve installed and enabled RPMForge repository, let’s install MTOP using following YUM command.

# yum install mtop
Sample Output :
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
rpmforge                                                                          | 1.9 kB     00:00
rpmforge/primary_db                                                                 2.6 MB     00:19
Setting up Install Process
Dependencies Resolved

================================================================================================================
 Package                       Arch				Version					Repository				Size
================================================================================================================
Installing:
 mtop                          noarch           0.6.6-1.2.el6.rf        rpmforge                52 k
Installing for dependencies:
 perl-Curses                   i686             1.28-1.el6.rf           rpmforge                156 k

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

Total download size: 208 k
Installed size: 674 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): mtop-0.6.6-1.2.el6.rf.noarch.rpm                                           |  52 kB     00:00
(2/2): perl-Curses-1.28-1.el6.rf.i686.rpm                                         | 156 kB     00:01
-----------------------------------------------------------------------------------------------------------------
Total                                                                     46 kB/s | 208 kB     00:04
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : perl-Curses-1.28-1.el6.rf.i686													1/2
  Installing : mtop-0.6.6-1.2.el6.rf.noarch                                                     2/2
  Verifying  : perl-Curses-1.28-1.el6.rf.i686                                                   1/2
  Verifying  : mtop-0.6.6-1.2.el6.rf.noarch                                                     2/2

Installed:
  mtop.noarch 0:0.6.6-1.2.el6.rf

Dependency Installed:
  perl-Curses.i686 0:1.28-1.el6.rf

Complete!

Starting Mtop in RHEL/CentOS 6/5/4

To start Mtop program, you need to connect to your MySQL Server, using following command.

# mysql -u root -p

Then you need to create separate user called mysqltop and grant privileges to him under your MySQL server. To do, this just run the following commands in mysql shell.

mysql> grant super, reload, process on *.* to mysqltop;
Query OK, 0 rows affected (0.00 sec)

mysql> grant super, reload, process on *.* to mysqltop@localhost;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit;
Bye

Running Mtop in RHEL/CentOS 6/5/4

Let’s start the Mtop program by executing below command. You will see sample output similar to below.

# mtop
Sample Outpit :
load average: 0.01, 0.00, 0.00 mysqld 5.1.61 up 5 day(s), 19:21 hrs
2 threads: 1 running, 0 cached. Queries/slow: 5/0 Cache Hit: 71.43%
Opened tables: 0  RRN: 277  TLW: 0  SFJ: 0  SMP: 0  QPS: 0

ID       USER     HOST         DB       TIME   COMMAND STATE        INFO
322081   mysqltop localhost						Query				show full processlist

Monitor Remote MySQL Server using Mtop

Simply, type the following command to monitor any remote MySQL Server.

# mtop  –host=remotehost –dbuser=username –password=password –seconds=1

Mtop Usage and Functions

Please use the following keys while mtop is running.

Filtering/display

  1. s – change the number of seconds to delay between updates
  2. m – toggle manual refresh mode on/off
  3. d – filter display with regular expression (user/host/db/command/state/info)
  4. F – fold/unfold column names in select statement display
  5. h – display process for only one host
  6. u – display process for only one user
  7. i – toggle all/non-Sleeping process display
  8. o – reverse the sort order
  9. q – quit
  10. ? – help

For more options and usage please see the man pages of mtop command by running “man mtop” on terminal.

command nice and renice usages

Nice Command

Linux nice command is Run Process With Modified Scheduling Priority ( nicenesses ). With the help of Nice command in Linux you can set process priority. If you give a process a higher priority, then Kernel will allocate more cpu time to that process.

By default when a programe is launched in Linux, it gets launched with the priority of ’0′. However you can change the priority of your programes by either of the following methods.

You can launch a programe with your required priority. Or you can also change the priority of an already running process.

Process priority values range from -20 to 19. A process with the nice value of -20 is considered to be on top of the priority. And a process with nice value of 19 is considered to be low on the priority list.

You can use ps -al, top and various command to check priority. The column that starts with “NI” shows the nice value(priority of the process). You can clearly see that most of them has got a ’0′ priority.

PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
31102 nobody    16   0  269m  22m  10m R  2.0  0.6   0:04.44 /usr/local/apache/bin/httpd -k start -DSSL
27956 root      15   0 12884 1268  832 R  1.0  0.0   2:53.60 top -c
22384 mysql      5 -10 2830m 204m 3864 S  0.7  5.2 372:40.00 /usr/sbin/mysqld --basedir=/ --datadir=/var/lib/mysql --user=mysql --log-error=/var/lib/mysql/serv.med1med
1 root      15   0 10368  584  552 S  0.0  0.0   0:03.09 init [3]
2 root      RT  -5     0    0    0 S  0.0  0.0   0:06.15 [migration/0]
3 root      34  19     0    0    0 S  0.0  0.0   0:00.28 [ksoftirqd/0]
4 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 [watchdog/0]

For example

nice -10 <command name> Will set a process with the priority of “10″.

Renice Command

In order to change the priority of an already running process you can use “renice” command.

Suppose you see that your machine is running slow due to some lengthy process(which is not a required process at the moment), then you can reduce the priority of that process with the help of renice command. And also increase the priority of your required process at the moment.

renice command is very much similar to the nice command( interms of options in priority), however it does differ slightly in terms of parameters. You can give username,groupname etc in renice command as a parameter.

Examples:

renice 15 -p 20380 (this will set the priority of process id no 20380 to 15)

renice -17 -p 24132 -u mysql (this will set the priority of the process id 24132 to -17)

renice 11 -u cpanel,nobody -g testuser (this will set all process owned by “cpanel”,”nobody” and also the group “testuser” to 11)

Comparing Network and Server Monitoring Tools

Server and network monitoring tools are essential for today’s data centers as they help managers increase uptime, troubleshoot outages, track capacity needs, and more. However, there are considerable differences between SaaS and open source solutions that you must be aware of before investing your time and money.

Learn from those who have come before you in this informative white paper as 5 data center managers decipher the differences between 2 monitoring tools. Read on to see a head-to-head comparison of these solutions in regard to:

  • Graphing
  • The user interface
  • Costs and pricing
  • And much more

https://i1.wp.com/icons.iconarchive.com/icons/visualpharm/must-have/256/Download-icon.png

How To Use HAProxy to Set Up HTTP Load Balancing on an Ubuntu VPS

About HAProxy

HAProxy (High Availability Proxy) is an open source load balancer which can load balance any TCP service. It is particularly suited for HTTP load balancing as it supports session persistence and layer 7 processing.

Prelude

We will be using three VPS (droplets) here:

Droplet 1 – Load Balancer
Hostname: haproxy
OS: Ubuntu
Public IP: 1.1.1.1
Private IP: 10.0.0.100

Droplet 2 – Node 1
Hostname: lamp1
OS: LAMP on Ubuntu
Private IP: 10.0.0.1

Droplet 2 – Node 2
Hostname: lamp2
OS: LAMP on Ubuntu
Private IP: 10.0.0.2

Installing HAProxy

Use the apt-get command to install HAProxy.

apt-get install haproxy

We need to enable HAProxy to be started by the init script.

nano /etc/default/haproxy

Set the ENABLED option to 1

ENABLED=1

To check if this change is done properly execute the init script of HAProxy without any parameters. You should see the following.

root@haproxy:~# service haproxy
Usage: /etc/init.d/haproxy {start|stop|reload|restart|status}

Configuring HAProxy

We’ll move the default configuration file and create our own one.

mv /etc/haproxy/haproxy.cfg{,.original}

Create and edit a new configuration file:

nano /etc/haproxy/haproxy.cfg

Let us begin by adding configuration block by block to this file:

global
    log 127.0.0.1 local0 notice
    maxconn 2000
    user haproxy
    group haproxy

The log directive mentions a syslog server to which log messages will be sent. On Ubuntu rsyslog is already installed and running but it doesn’t listen on any IP address. We’ll modify the config files of rsyslog later.

The maxconn directive specifies the number of concurrent connections on the frontend. The default value is 2000 and should be tuned according to your VPS’ configuration.

The user and group directives changes the HAProxy process to the specified user/group. These shouldn’t be changed.

defaults
    log     global
    mode    http
    option  httplog
    option  dontlognull
    retries 3
    option redispatch
    timeout connect  5000
    timeout client  10000
    timeout server  10000

We’re specifying default values in this section. The values to be modified are the various timeout directives. The connect option specifies the maximum time to wait for a connection attempt to a VPS to succeed.

The client and server timeouts apply when the client or server is expected to acknowledge or send data during the TCP process. HAProxy recommends setting the client and server timeouts to the same value.

The retries directive sets the number of retries to perform on a VPS after a connection failure.

The option redispatch enables session redistribution in case of connection failures. So session stickness is overriden if a VPS goes down.

listen appname 0.0.0.0:80
    mode http
    stats enable
    stats uri /haproxy?stats
    stats realm Strictly\ Private
    stats auth A_Username:YourPassword
    stats auth Another_User:passwd
    balance roundrobin
    option httpclose
    option forwardfor
    server lamp1 10.0.0.1:80 check
    server lamp2 10.0.0.2:80 check

This contains configuration for both the frontend and backend. We are configuring HAProxy to listen on port 80 for appname which is just a name for identifying an application. The stats directives enable the connection statistics page and protects it with HTTP Basic authentication using the credentials specified by the stats auth directive.

This page can viewed with the URL mentioned in stats uri so in this case, it is http://1.1.1.1/haproxy?stats;
a demo of this page can be viewed here.

The balance directive specifies the load balancing algorithm to use. Options available are Round Robin (roundrobin), Static Round Robin (static-rr), Least Connections (leastconn), Source (source), URI (uri) and URL parameter (url_param).

Information about each algorithm can be obtained from the official documentation.

The server directive declares a backend server, the syntax is:

server <name> <address>[:port] [param*]

The name we mention here will appear in logs and alerts. There are many paratmeters supported by this directive and we’ll be using the check and cookie parameters in this article. The check option enables health checks on the VPS otherwise, the VPS is
always considered available.

Once you’re done configuring start the HAProxy service:

service haproxy start

Testing Load Balancing and Failover

To test this setup, create a PHP script on all your web servers (backend servers – LAMP1 and LAMP2 here).

/var/www/file.php

<?php
header('Content-Type: text/plain');
echo "Server IP: ".$_SERVER['SERVER_ADDR'];
echo "\nClient IP: ".$_SERVER['REMOTE_ADDR'];
echo "\nX-Forwarded-for: ".$_SERVER['HTTP_X_FORWARDED_FOR'];
?>

Now we will use curl and request this file multiple times.

> curl http://1.1.1.1/file.php

Server IP: 10.0.0.1
Client IP: 10.0.0.100
X-Forwarded-for: 117.213.X.X

> curl http://1.1.1.1/file.php

Server IP: 10.0.0.2
Client IP: 10.0.0.100
X-Forwarded-for: 117.213.X.X

> curl http://1.1.1.1/file.php

Server IP: 10.0.0.1
Client IP: 10.0.0.100
X-Forwarded-for: 117.213.X.X

Notice here how HAProxy alternatively toggled the connection between LAMP1 and LAMP2, this is how Round Robin works. The client IP we see here is the Private IP address of the load balancer and the X-Forwarded-For header is your IP.

To see how failover works, go to a web server and stop the service:

lamp1@haproxy:~#service apache2 stop

Send requests with curl again to see how things work.

Session Stickiness

If your web application serves dynamic content based on users’ login sessions (which application doesn’t), visitors will experience odd things due to continuous switching between VPS. Session stickiness ensures that a visitor sticks on to the VPS which served their first request. This is possible by tagging each backend server with a cookie.

We’ll use the following PHP code to demonstrate how session stickiness works.

/var/www/session.php

<?php
header('Content-Type: text/plain');
session_start();
if(!isset($_SESSION['visit']))
{
        echo "This is the first time you're visiting this server";
        $_SESSION['visit'] = 0;
}
else
        echo "Your number of visits: ".$_SESSION['visit'];

$_SESSION['visit']++;

echo "\nServer IP: ".$_SERVER['SERVER_ADDR'];
echo "\nClient IP: ".$_SERVER['REMOTE_ADDR'];
echo "\nX-Forwarded-for: ".$_SERVER['HTTP_X_FORWARDED_FOR']."\n";
print_r($_COOKIE);
?>

This code creates a PHP sesssion and displays the number of page views in a single session.

Cookie insert method

In this method, all responses from HAProxy to the client will contain a Set-Cookie: header with the name of a backend server as its cookie value. So going forward the client (web browser) will include this cookie with all its requests and HAProxy will forward the request to the right backend server based on the cookie value.

For this method, you will need to add the cookie directive and modify the server directives under listen

   cookie SRVNAME insert
   server lamp1 10.0.0.1:80 cookie S1 check
   server lamp2 10.0.0.2:80 cookie S2 check

This causes HAProxy to add a Set-Cookie: header with a cookie named SRVNAME having its value as S1 or S2 based on which backend answered the request. Once this is added restart the service:

service haproxy restart

and use curl to check how this works.

> curl -i http://1.1.1.1/session.php
HTTP/1.1 200 OK
Date: Tue, 24 Sep 2013 13:11:22 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3.8
Set-Cookie: PHPSESSID=l9haakejnvnat7jtju64hmuab5; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Length: 143
Connection: close
Content-Type: text/plain
Set-Cookie: SRVNAME=S1; path=/

This is the first time you're visiting this server
Server IP: 10.0.0.1
Client IP: 10.0.0.100
X-Forwarded-for: 117.213.X.X
Array
(
)

This is the first request we made and it was answered by LAMP1 as we can see from Set-Cookie: SRVNAME=S1; path=/. Now, to emulate what a web browser would do for the next request, we add these cookies to the request using the --cookie parameter of curl.

> curl -i http://1.1.1.1/session.php --cookie "PHPSESSID=l9haakejnvnat7jtju64hmuab5;SRVNAME=S1;"
HTTP/1.1 200 OK
Date: Tue, 24 Sep 2013 13:11:45 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3.8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Length: 183
Connection: close
Content-Type: text/plain

Your number of visits: 1
Server IP: 10.0.0.1
Client IP: 10.0.0.100
X-Forwarded-for: 117.213.87.127
Array
(
    [PHPSESSID] => l9haakejnvnat7jtju64hmuab5
    [SRVNAME] => S1
)

> curl -i http://1.1.1.1/session.php --cookie "PHPSESSID=l9haakejnvnat7jtju64hmuab5;SRVNAME=S1;"
HTTP/1.1 200 OK
Date: Tue, 24 Sep 2013 13:11:45 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3.8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Length: 183
Connection: close
Content-Type: text/plain

Your number of visits: 2
Server IP: 10.0.0.1
Client IP: 10.0.0.100
X-Forwarded-for: 117.213.87.127
Array
(
    [PHPSESSID] => l9haakejnvnat7jtju64hmuab5
    [SRVNAME] => S1
)

Both of these requests were served by LAMP1 and the session was properly maintained. This method is useful if you want stickiness for all files on the web server.

Cookie Prefix Method

On the other hand, if you want stickiness only for specific cookies or don’t want to have a separate cookie for session stickiness, the prefix option is for you.

To use this method, use the following cookie directive:

cookie PHPSESSID prefix

The PHPSESSID can be replaced with your own cookie name. The server directive remains the same as the previous configuration.

Now let’s see how this works.

> curl -i http://1.1.1.1/session.php
HTTP/1.1 200 OK
Date: Tue, 24 Sep 2013 13:36:27 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3.8
Set-Cookie: PHPSESSID=S1~6l2pou1iqea4mnhenhkm787o56; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Length: 143
Content-Type: text/plain

This is the first time you're visiting this server
Server IP: 10.0.0.1
Client IP: 10.0.0.100
X-Forwarded-for: 117.213.X.X
Array
(
)

Notice how the server cookie S1 is prefixed to the session cookie. Now, let’s send two more requests with this cookie.

> curl -i http://1.1.1.1/session.php --cookie "PHPSESSID=S1~6l2pou1iqea4mnhenhkm787o56;"
HTTP/1.1 200 OK
Date: Tue, 24 Sep 2013 13:36:45 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3.8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Length: 163
Content-Type: text/plain

Your number of visits: 1
Server IP: 10.0.0.1
Client IP: 10.0.0.100
X-Forwarded-for: 117.213.X.X
Array
(
    [PHPSESSID] => 6l2pou1iqea4mnhenhkm787o56
)

> curl -i http://1.1.1.1/session.php --cookie "PHPSESSID=S1~6l2pou1iqea4mnhenhkm787o56;"
HTTP/1.1 200 OK
Date: Tue, 24 Sep 2013 13:36:54 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3.8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Length: 163
Content-Type: text/plain

Your number of visits: 2
Server IP: 10.0.0.1
Client IP: 10.0.0.100
X-Forwarded-for: 117.213.X.X
Array
(
    [PHPSESSID] => 6l2pou1iqea4mnhenhkm787o56
)

We can clearly see that both the requests were served by LAMP1 and the session is perfectly working.

Configure Logging for HAProxy

When we began configuring HAProxy, we added a line: log 127.0.0.1 local0 notice which sends syslog messages to the localhost IP address. But by default, rsyslog on Ubuntu doesn’t listen on any address. So we have to make it do so.

Edit the config file of rsyslog.

nano /etc/rsyslog.conf

Add/Edit/Uncomment the following lines:

$ModLoad imudp
$UDPServerAddress 127.0.0.1
$UDPServerRun 514

Now rsyslog will work on UDP port 514 on address 127.0.0.1 but all HAProxy messages will go to /var/log/syslog so we have to separate them.

Create a rule for HAProxy logs.

nano /etc/rsyslog.d/haproxy.conf

Add the following line to it.

if ($programname == 'haproxy') then -/var/log/haproxy.log

Now restart the rsyslog service:

service rsyslog restart

This writes all HAProxy messages and access logs to /var/log/haproxy.log.

Keepalives in HAProxy

Under the listen directive, we used option httpclose which adds a Connection: close header. This tells the client (web browser) to close a connection after a response is received.

If you want to enable keep-alives on HAProxy, replace the option httpclose line with:

option http-server-close
timeout http-keep-alive 3000

Set the keep-alive timeout wisely so that a few connections don’t drain all the resources of the load balancer.

Testing Keepalives

Keepalives can be tested using curl by sending multiple requests at the same time. Unnecessary output will be omitted in the following example:

> curl -v http://1.1.1.1/index.html http://1.1.1.1/index.html
* About to connect() to 1.1.1.1 port 80 (#0)
*   Trying 1.1.1.1... connected
> GET /index.html HTTP/1.1
> User-Agent: curl/7.23.1 (x86_64-pc-win32) libcurl/7.23.1 OpenSSL/0.9.8r zlib/1.2.5
> Host: 1.1.1.1
> Accept: */*
>
......[Output omitted].........
* Connection #0 to host 1.1.1.1 left intact
* Re-using existing connection! (#0) with host 1.1.1.1
* Connected to 1.1.1.1 (1.1.1.1) port 80 (#0)
> GET /index.html HTTP/1.1
> User-Agent: curl/7.23.1 (x86_64-pc-win32) libcurl/7.23.1 OpenSSL/0.9.8r zlib/1.2.5
> Host: 1.1.1.1
> Accept: */*
>
.......[Output Omitted].........
* Connection #0 to host 1.1.1.1 left intact
* Closing connection #0

In this output, we have to look for the line: Re-using existing connection! (#0) with host 1.1.1.1, which indicates that curl used the same connection to make subsequent requests.

How reset root password in Debian.

At grub-boot loader screen. Select Recovery mode the version of the kernel that you wish to boot and type e for edit. Select the line that starts with kernel and type e to edit the line.

Go to the end of the line and type init=/bin/bash as a separate one word (press the spacebar and then type init=/bin/bash). Press enter key to exit edit mode.

Back at the GRUB screen, type b to boot into single user mode. This causes the system to boot the kernel and run /bin/bash instead of its standard init. This will allow us gain root privileges without password.

If you wanna reset root password remount partitions

# mount -n -o remount,rw /

# mount -avt nonfs,noproc,nosmbfs

# cd /etc

#passwd
Changing password for user root.
New UNIX password:
Retype new UNIX password:

Now, you will get following messages. It means that password for root user has been updated.

passwd: all authentication tokens updated successfully.

At last, reboot the server and you are done.