Saturday, December 31, 2011

MegaRaid statsus monitoring


 cd /usr/src/

 wget ftp://tsupport:tsupport@ftp0.lsil.com/private/MegaRAID/downloads/8.00.23_Linux_MegaCLI.zip
 unzip 8.00.23_Linux_MegaCLI.zip
 yum localinstall MegaCli-8.00.23-1.i386.rpm
 yum localinstall Lib_Utils-1.00-08.noarch.rpm --nogpgcheck
 yum localinstall MegaCli-8.00.23-1.i386.rpm --nogpgcheck
 cd /opt/MegaRAID/MegaCli/
 chmod 777 MegaCli64
 ./MegaCli64 -AdpAllInfo -a0

A simple and quick way to get a status of the adapters and devices in the RAID array using megacli is to run the following command:
 ./MegaCli64 -AdpAllInfo -aALL

To get more detailed information on the drives in the array, issue the command:
 ./MegaCli64 -LDPDInfo -aAll



In order to find out what drive is failed, it is actually the absence of information that shows this. Issue the following command:
 ./MegaCli64 -PDList -aALL

Monday, December 26, 2011

ERROR: Loading command: install (LoadError)

 gem install rails
ERROR:  Loading command: install (LoadError)
    cannot load such file -- zlib
ERROR:  While executing gem ... (NameError)
    uninitialized constant Gem::Commands::InstallCommand
===================


yum install zlib-devel 
 

then in /opt/ruby/ext/zlib/
 ruby extconf.rb
make && make install 
===================

Wednesday, December 21, 2011

OpenSSH key Regeneration

If you deleted or lost your public OpenSSH key; you can regenerating using the following

ssh-keygen -t rsa -y
ssh-keygen -t dsa -y
ssh-keygen -t rsa -y > ~/.ssh/id_rsa.pub
ssh-copy-id -i ~/.ssh/id_rsa.pub user@remotebox

Monday, December 19, 2011

Memcached Installation Using YUM

Memcached Installation Using YUM


Memcached is a high-performance, distributed memory object caching system, generic in nature, but originally intended for use in speeding up dynamic web applications by alleviating database load. Memcached is a very useful also in other cases, than only dynamic web applications.
This guide explains howto install Memcached 1.4.4/1.4.5/1.4.7 stable version of distributed memory object caching system on Fedora 16/15/14/13/12 and CentOS 6/5.7, Red Hat (RHEL) 6.1/6/5.7. Fedora 16/15/14/13/12, CentOS 6 and Red Hat (RHEL) 6 has Memcached 1.4.5 as default so extra repositories is not needed on F16/F15/F14/F13/F12, CentOS 6 and RHEL 6.

Install Memcached 1.4.4/1.4.5/1.4.7 on Fedora 16/15/14/13/12, CentOS/Red Hat (RHEL) 6/5.7

Install Remi repository (not needed on Fedora 16, Fedora 15, Fedora 14, Fedora 13, Fedora 12 and RHEL 6):

## Remi Dependency on CentOS and Red Hat (RHEL)
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
 
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm

Install Memcached package:

yum install memcached
 
yum --enablerepo=remi install memcached

Configure memcached

Most important value to configure is CACHESIZE, which is cache size on Megabytes. Example Following configuration use 512 Mb memory for Memcached
nano -w /etc/sysconfig/memcached
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="512"
OPTIONS=""

Start Memcached

# Set Memcached to start automatically on boot
chkconfig memcached on
# Start Memcached
/etc/init.d/memcached start
## OR ##
service memcached start

Check that Memcached is Running and Working

echo stats | nc localhost 11211
STAT pid 7599
STAT uptime 10
STAT time 1265288542
STAT version 1.4.4
STAT pointer_size 32
STAT rusage_user 0.003999
STAT rusage_system 0.052991
STAT curr_connections 10
STAT total_connections 11
STAT connection_structures 11
STAT cmd_get 0
STAT cmd_set 0
STAT cmd_flush 0
STAT get_hits 0
STAT get_misses 0
STAT delete_misses 0
STAT delete_hits 0
STAT incr_misses 0
STAT incr_hits 0
STAT decr_misses 0
STAT decr_hits 0
STAT cas_misses 0
STAT cas_hits 0
STAT cas_badval 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 6
STAT bytes_written 0
STAT limit_maxbytes 536870912
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT threads 4
STAT conn_yields 0
STAT bytes 0
STAT curr_items 0
STAT total_items 0
STAT evictions 0
END
 
# Try to get some value
echo get some_value | nc localhost 11211
END
 
# Not found, but check the stats again
echo stats | nc localhost 11211
STAT pid 7599
STAT uptime 10
STAT time 1265288542
STAT version 1.4.4
[...]
STAT cmd_get 1
STAT cmd_set 0
STAT cmd_flush 0
STAT get_hits 0
STAT get_misses 1
STAT delete_misses 0
[...]
STAT evictions 0
END
Everything working nice. Then it’s time to test memcache example with some web application.

Open Memcached Port (11211) on Iptables Firewall (If the Memcached will also be used other local servers)

Edit /etc/sysconfig/iptables file:

nano -w /etc/sysconfig/iptables

Add following line before COMMIT:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 11211 -j ACCEPT

Restart Iptables Firewall:

service iptables restart
## OR ##
/etc/init.d/iptables restart

Test remote connection:

echo stats | nc memcache_host_name_or_ip 11211

Install Memcache and/or Memcached PHP Module on Fedora 16, Fedora 15, Fedora 14, Fedora 13 and Fedora 12

More information about Memcache Module.
More information about Memcached Module.

Install Memcache Module and PHP

yum install php php-pecl-memcache

Install Memcached Module and PHP

yum install php php-pecl-memcached

Restart Web server

/etc/init.d/httpd restart
## OR ##
service httpd restart

Wednesday, December 14, 2011

Install JAVA.1.7 in linux



To Install JAVA.1.7 in Linux

#wget http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.tar.gz
#tar -xzf jdk-7-linux-i586.tar.gz
#mv ./jdk1.7.0/ /usr/lib/jvm/jdk1.7.0
#update-alternatives --config java
In case you have other answer from update-alternatives --config java command, e.g. ‘no alternatives for java’, try this command:

#update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0/jre/bin/java 0

To know under what number you will config you new Java installation.Remember the last number and press enter to exit this utility.

#update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0/jre/bin/java 3 

#java -version
java version “1.7.0″
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)


=================================
To update javac
#javac -version
  javac 1.6.0_26 

# update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0/bin/javac 3
# update-alternatives --config javac
#  javac -version

Thursday, December 8, 2011

How to Install MemCached.1.4.10 with Sasl


 How to Install MemCached.1.4.10 with Sasl

 

================================================================================
  cd /usr/src/
  1. wget http://www.monkey.org/~provos/libevent-1.4.9-stable.tar.gz  
  2. tar xvfz libevent-1.4.9-stable.tar.gz  
  3. cd libevent-1.4.9-stable  
  4. ./configure; make; make install 
 ================================================================================

 cd /usr/src/
  wget http://memcached.googlecode.com/files/memcached-1.4.10.tar.gz
 tar -xzf memcached-1.4.10.tar.gz
yum install cyrus-sasl cyrus-sasl-devel cyrus-sasl-gssapi cyrus-sasl-md5 cyrus-sasl-plain
cd memcached-1.4.10
./configure --enable-sasl
make
make install
memcached -Bbinary -d -m 1024 10.0.127.154 -p 11211 -u nobody




Run memcached as service Create memcached config file:

 vi /etc/memcached.conf  

================================================================================
#Memory a user can use
-m 16
# default port
-p 11211
# user to run daemon nobody/apache/www-data
-u nobody
# only listen locally
-l 127.0.0.1  


================================================================================
 touch /etc/init.d/memcached
chmod 
+/etc/init.d/memcached 

================================================================================

 #!/bin/bash
#
# memcached This shell script takes care of starting and stopping
# standalone memcached.
#
. /etc/rc.d/init.d/functions
PATH
=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON
=/usr/local/bin/memcached
DAEMONBOOTSTRAP
=/usr/local/bin/start-memcached
DAEMONCONF
=/etc/memcached.conf
NAME
=memcached
DESC
=memcached
PIDFILE
=/var/run/$NAME.pid[ -x $DAEMON ] || exit 0[ -x $DAEMONBOOTSTRAP ] || exit 0
RETVAL
=0
start
() {
echo -
$"Starting $DESC: "daemon $DAEMONBOOTSTRAP $DAEMONCONF
RETVAL
=$?
$RETVAL -eq 0 ] && touch $PIDFILEecho
return 
$RETVAL}stop() {
echo -
$"Shutting down $DESC: "killproc $NAME
RETVAL
=$?
echo
$RETVAL -eq 0 ] && rm -f $PIDFILEreturn $RETVAL}# See how we were called.case "$1" in
start
)start;;stop)stop;;restart|reload)stop
start
RETVAL
=$?
;;
status)status $prog
RETVAL
=$?
;;
*)
echo $
"Usage: $0 {start|stop|restart|status}"exit 1
esac
exit $RETVAL  


================================================================================
touch /usr/local/bin/start-memcached
chmod 
+/usr/local/bin/start-memcached  



================================================================================
#!/usr/bin/perl -w
# start-memcached
use strict;
if ($> != 
and $< != 0) {
print 
STDERR "Only root wants to run start-memcached.\n";
exit;
}
my $etcfile shift || "/etc/memcached.conf";my $params = [];my $etchandle;# This script assumes that memcached is located at /usr/bin/memcached, and
# that the pidfile is writable at /var/run/memcached.pid
my $memcached "/usr/local/bin/memcached";my $pidfile "/var/run/memcached.pid";# If we don't get a valid logfile parameter in the /etc/memcached.conf file,
# we'll just throw away all of our in-daemon output. We need to re-tie it so
# that non-bash shells will not hang on logout. Thanks to Michael Renner for
# the tip
my $fd_reopened "/dev/null";sub handle_logfile {my ($logfile) = @_;$fd_reopened $logfile;
}
sub reopen_logfile {my ($logfile) = @_;open *STDERR">>$logfile";open *STDOUT">>$logfile";open *STDIN">>/dev/null";$fd_reopened $logfile;
}
# This is set up in place here to support other non -[a-z] directivesmy $conf_directives = {"logfile" => &handle_logfile};
if (
open $etchandle$etcfile) {
foreach 
my $line (<$etchandle>) {$line =~ s/#.*//go;$line join ' 'split ' '$line;next unless $line;next if $line =~ /^-[dh]/o;
if (
$line =~ /^[^-]/o) {my ($directive$arg) = $line =~ /^(.*?)s+(.*)/;$conf_directives->{$directive}->($arg);next;
}
push @$params$line;
}
}
unshift @$params"-u root" unless (grep $_ eq '-u', @$params);$params join " ", @$params;
if (-
e $pidfile) {open PIDHANDLE"$pidfile";my $localpid = <PIDHANDLE>;close PIDHANDLE;chomp $localpid;
if (-
"/proc/$localpid") {
print 
STDERR "memcached is already running.\n";
exit;
} else {
`
rm -f $localpid`;
}
}
my $pid fork();
if (
$pid == 0) {reopen_logfile($fd_reopened);exec "$memcached $params";
exit(
0);
elsif (open PIDHANDLE,">$pidfile") {
print 
PIDHANDLE $pid;close PIDHANDLE;
} else {
print 
STDERR "Can't write pidfile to $pidfile.\n";
}  


==================

[root@test init.d]# /etc/init.d/memcached restartShutting down memcached: [ OK ]Starting memcached: [ OK ]  


=================
# /sbin/chkconfig memcached on# /sbin/chkconfig --list | grep memcachedmemcached 0off 1off 2on 3on 4on 5on 6off  

==========================================================================

Monday, November 28, 2011

Install IMageMagic with the support of JPEG,PNG,TIFF


yum install libpng.i386
yum install libpng..68_64
yum install libtiff.i386
yum install libtiff..68_64
 yum install libtiff-devel.i386
yum install libtiff-devel..68_64
yum install libpng-devel.i386
yum install libpng-devel.x86_64
wget ftp://mirror.aarnet.edu.au/pub/imagemagick/ImageMagick-6.7.2-1.tar.gz
tar xzf ImageMagick-6.7.2-1.tar.gz
cd ImageMagick-6.7.2-1
 ./configure --enable-shared --with-jpeg=yes --with-png=yes --with-tiff=yes --with-xml=yes
 make
 make install

To Know image format support of Imagemagik

identify -list format

identify -list format | grep -i tif

Wednesday, November 23, 2011

Invalid command “SSLEngine”, perhaps misspelled OR defined by a module not included.

    “Invalid command “SSLEngine”, perhaps misspelled or defined by a module not included in the server configuration”

while browsing the website. The error message indicates that the module mod_ssl required to run SSL engine on a CentOS server is missing and needs to be installed.

Install the mod_ssl module using yum

    #yum install mod_ssl

Once it is installed, make sure to restart the Apache service

    #service httpd restart

Thursday, September 1, 2011

====================

Step 1: Download

Source code: version 1.8.7-2011.03
http://rubyenterpriseedition.googlecode.com/files/ruby-enterprise-1.8.7-2011.03.tar.gz

Step 2: Install

Extract it:
tar xzvf ruby-enterprise-X.X.X.tar.gz

Run the installer (completely safe, none of your system
files will be touched!
):
./ruby-enterprise-X.X.X/installer
=================================

Friday, August 5, 2011

Cut First Character From Line

Cut First Character From Line
=======================

cat 12 |sed 's/.\(.*\)/\1/' ( 12 is the file name)


Removing the last three characters from every filename.

==============
$ cat files
apache-1.3.39.exe
==============
$ cat files | sed 's/\(.*\).../\1/'
apache-1.3.39
==============

Removing last character from each filename/strin.

==============
$ cat files |sed 's/\(.*\)./\1/'
apache-1.3.39.ex

==============

Tuesday, August 2, 2011

How to Install VirtualBox In Centos.5.5

How to Install VirtualBox In Centos.5.5
=================================

#cd /etc/yum.repos.d

#wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo

#yum --enablerepo rpmforge install dkms

#yum groupinstall "Development Tools"

#yum install kernel-devel

#yum install VirtualBox-4.0

# usermod -G vboxusers username

=================================



Monday, August 1, 2011

Install Openfire/Spark Server.

Install Openfire/Spark Server.
===================

1. Install java
===============
wget http://javadl.sun.com/webapps/download/AutoDL?BundleId=33879

Rename the downloaded file and extract it with the following command::
mv jre* jre-install.bin
chmod +x jre-install.bin
./jre-install.bin
======
1. Install Openfire.

wget http://www.igniterealtime.org/downloads/download-landing.jsp?file=openfire/openfire-3.7.0-1.i386.rpm

rpm -ivh http://www.igniterealtime.org/downloads/download-landing.jsp?file=openfire/openfire-3.7.0-1.i386.rpm

===
To access Admin Console
127.0.0.1:9090
===
selet embeded databse
===
import user from existing server shold mention old server hostname
====

Sunday, July 31, 2011

Install Reverse Proxy Using NGNIX

=====
Install Reverse Proxy Using NGNIX
=====

# yum -y groupremove "X Window System"
# x=$(yum list installed | egrep -i 'php|httpd|mysql|bind|dhclient|tftp|inetd|xinetd|ypserv|telnet-server|rsh-server|vsftpd|tcsh' | awk '{ print $1}')
# yum -y remove $x
# yum -y install bind-utils sysstat openssl-devel.x86_64 pcre-devel.x86_64 openssl097a.x86_64
# /usr/sbin/authconfig --passalgo=sha512 --update
# passwd root

# useradd nginx

# cd /opt
# wget http://sysoev.ru/nginx/nginx-0.8.33.tar.gz

# tar -zxvf nginx-0.8.33.tar.gz
# cd nginx-0.8.33

For with out ssl

# ./configure --without-http_autoindex_module --without-http_ssi_module --without-http_userid_module --without-http_auth_basic_module --without-http_geo_module --without-http_fastcgi_module --without-http_empty_gif_module --with-openssl=/lib64

=====For ssl ====

./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/sbin --with-debug --with-http_ssl_module --without-http_autoindex_module --without-http_ssi_module --without-http_userid_module --without-http_auth_basic_module --without-http_geo_module --without-http_fastcgi_module --without-http_empty_gif_module

====

Sample outputs:

======

....

nginx path prefix: "/usr/local/nginx"

nginx binary file: "/usr/local/nginx/sbin/nginx"

nginx configuration prefix: "/usr/local/nginx/conf"

nginx configuration file: "/usr/local/nginx/conf/nginx.conf"

nginx pid file: "/usr/local/nginx/logs/nginx.pid"

nginx error log file: "/usr/local/nginx/logs/error.log"

nginx http access log file: "/usr/local/nginx/logs/access.log"

nginx http client request body temporary files: "client_body_temp"

nginx http proxy temporary files: "proxy_temp"

nginx http fastcgi temporary files: "fastcgi_temp"

...

# make
# make install

#cd /usr/local/nginx/conf

#mv –rp nginx.conf nginx.conf.org

============================================

[root@revproxy conf]# vi nginx.conf

pid logs/nginx.pid;

user nginx nginx;

worker_processes 10;


events {

worker_connections 1024;

}


http {

default_type application/octet-stream;


## Common options ##

include options.conf;


## Proxy settings ##

include proxy.conf;


## lb domains ##

include domain.net.conf;

}


# root@revproxy conf]# vi options.conf

## Size Limits

client_body_buffer_size 128K;

client_header_buffer_size 1M;

client_max_body_size 1M;

large_client_header_buffers 8 8k;


## Timeouts

client_body_timeout 60;

client_header_timeout 60;

expires 24h;

keepalive_timeout 60 60;

send_timeout 60;


## General Options

ignore_invalid_headers on;

keepalive_requests 100;

limit_zone gulag $binary_remote_addr 5m;

recursive_error_pages on;

sendfile on;

server_name_in_redirect off;

server_tokens off;


## TCP options

tcp_nodelay on;

tcp_nopush on;


## Compression

gzip on;

gzip_buffers 16 8k;

gzip_comp_level 6;

gzip_http_version 1.0;

gzip_min_length 0;

gzip_types text/plain text/css image/x-icon application/x-perl application/x-httpd-cgi;

gzip_vary on;

## Log Format

log_format main '$remote_addr $host $remote_user [$time_local] "$request" '

'$status $body_bytes_sent "$http_referer" "$http_user_agent" '

'"$gzip_ratio"';

[root@revproxy conf]# vi proxy.conf

## Proxy caching options

proxy_buffering on;

proxy_cache_min_uses 3;

proxy_cache_path /usr/local/nginx/proxy_temp/ levels=1:2 keys_zone=cache:10m inactive=10m max_size=1000M;

proxy_cache_valid any 10m;

proxy_ignore_client_abort off;

proxy_intercept_errors on;

proxy_next_upstream error timeout invalid_header;

proxy_redirect off;

proxy_set_header X-Forwarded-For $remote_addr;

proxy_connect_timeout 60;

proxy_send_timeout 60;

proxy_read_timeout 60;

[root@revproxy conf]# vi domain.net.conf

## Connect to backend servers via LAN ##

## Reverse Proxy Load Balancer Logic ##

upstream domain {

server 192.168.26.39 weight=10 max_fails=3 fail_timeout=30s;

server 192.168.26.42 weight=10 max_fails=3 fail_timeout=30s;

# only comes alive when above two fails

server 192.168.1.23 weight=1 backup;

}


server {

access_log logs/access.log main;

error_log logs/error.log;

index index.html;

root /usr/local/nginx/html;

server_name subdomain.domain.net www.subdomain.domain.net;


## Only requests to our Host are allowed

if ($host !~ ^(subdomain.domain.net|www.subdomain.domain.net)$ ) {

return 444;

}


## redirect www to nowww

# if ($host = 'www.subdomain.domain.net' ) {

# rewrite ^/(.*)$ http://subdomain.domain.net/$1 permanent;

# }


## Only allow these request methods

if ($request_method !~ ^(GET|HEAD|POST)$ ) {

return 444;

}


## PROXY - Web

location / {

proxy_pass http://192.168.26.39;

proxy_cache cache;

proxy_cache_valid 200 24h;

proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;

proxy_ignore_headers Expires Cache-Control;


proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}

# redirect server error pages to the static page /50x.html

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root html;

}

}


server {

access_log logs/access.log main;

error_log logs/error.log;

index index.html;

root /usr/local/nginx/html;

server_name revpro3.domain.net www.subdomain.domain.net.net;


## Only requests to our Host are allowed

if ($host !~ ^(subdomain.domain.net|www.subdomain.domain.net)$ ) {

return 444;

}


## redirect www to nowww

# if ($host = 'www.subdomain.domain.net' ) {

# rewrite ^/(.*)$ http://subdomain.domain.net/$1 permanent;

# }


## Only allow these request methods

if ($request_method !~ ^(GET|HEAD|POST)$ ) {

return 444;

}

# redirect server error pages to the static page /50x.html

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root html;

}

}



server {

### server port and name ###

listen 443;

server_name subdomain.domain.net;


### SSL log files ###

access_log logs/ssl-access.log;

error_log logs/ssl-error.log;


### SSL cert files ###

ssl on;

ssl_certificate ssl/star_domain_com.crt;

ssl_certificate_key ssl/domain.com.key;

### Add SSL specific settings here ###

keepalive_timeout 60;


### Limiting Ciphers ########################

# Uncomment as per your setup

#ssl_ciphers HIGH:!ADH;

#ssl_perfer_server_ciphers on;

#ssl_protocols SSLv3;

##############################################

### We want full access to SSL via backend ###

location / {

proxy_pass https://192.168.26.48;

### force timeouts if one of backend is died ##

proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;


### Set headers ####

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;


### Most PHP, Python, Rails, Java App can use this header ###

proxy_set_header X-Forwarded-Proto https;



## PROXY - Web

location / {

proxy_pass http://192.168.26.42;

proxy_cache cache;

proxy_cache_valid 200 24h;

proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;

proxy_ignore_headers Expires Cache-Control;


proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}

server {

### server port and name ###

listen 443;

server_name subdomain.domain.net;


### SSL log files ###

access_log logs/ssl-access.log;

error_log logs/ssl-error.log;


### SSL cert files ###

ssl on;

ssl_certificate ssl/subdomain.domain.net;

ssl_certificate_key ssl/subdomain.domain.net.key;

### Add SSL specific settings here ###

keepalive_timeout 60;


### Limiting Ciphers ########################

# Uncomment as per your setup

#ssl_ciphers HIGH:!ADH;

#ssl_perfer_server_ciphers on;

#ssl_protocols SSLv3;

##############################################

### We want full access to SSL via backend ###

location / {

proxy_pass https://192.168.26.46;

### force timeouts if one of backend is died ##

proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;


### Set headers ####

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;


### Most PHP, Python, Rails, Java App can use this header ###

proxy_set_header X-Forwarded-Proto https;


### By default we don't want to redirect it ####

proxy_redirect off;

}

}


# /usr/local/sbin/nginx –t test conffile

# /usr/local/sbin/nginx -s reload

# /usr/local/sbin/nginx

# pkill -9 nginx

# /usr/local/sbin/nginx


# /usr/local/nginx/sbin/nginx
# netstat -tulpn | grep :80
# echo ' /usr/local/nginx/sbin/nginx' >> /etc/rc.local



Keelpalivd

# cd /opt
# wget http://www.keepalived.org/software/keepalived-1.1.19.tar.gz
# tar -zxvf keepalived-1.1.19.tar.gz
# cd keepalived-1.1.19

# yum -y install kernel-headers kernel-devel

388 ./configure --with-kernel-dir=/lib/modules/$(uname -r)/build

389 make && make install

390 cd /etc/sysconfig

391 ln -s /usr/local/etc/sysconfig/keepalived .

392 cd /etc/rc3.d/

393 ln -s /usr/local/etc/rc.d/init.d/keepalived S100keepalived

394 cd /etc/init.d/

395 ln -s /usr/local/etc/rc.d/init.d/keepalived .

396 cd /usr/local/etc/keepalived

397 cp keepalived.conf keepalived.conf.bak

vi keepalived.conf

vrrp_instance VI_1 {

interface eth0

state MASTER

virtual_router_id 51

priority 101 --- should set 100 in lb1(second failover mechine)

authentication {

auth_type PASS

auth_pass Add-Your-Password-Here

}

virtual_ipaddress {

192.168.26.47 dev eth0:1

}

}