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  

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