Monday, August 5, 2013

How to install Apache, Java, Tomcat and Solr

Here is the procedure to install Apache, Tomcat, Java and Solr:

First of all we need Apache in our box:
Download the Apache source.

tar -zxvf httpd-2.2.24.tar.gz
cd httpd-2.2.24
./configure --enable-so --enable-expires --enable-file-cache --enable-cache --enable-disk-cache --enable-mem-cache --enable-headers --enable-ssl --enable-http --disable-userdir --enable-rewrite --enable-deflate --enable-proxy --enable-proxy-connect --enable-proxy-ftp --enable-proxy-http --enable-proxy-ajp --enable-proxy-balancer --enable-cgi --disable-dbd --enable-modules=most --with-mpm=worker --prefix=/usr/local/apache2
make; make install
/usr/local/apache2/bin/apachectl -t

./configure : Specify the modules which you want to install for your Apache ( ./configure with out specified modules will install all the modules )
--prefix= :  Its used to specify the path where you need to install Apache.
apachectl -t : To check the syntax of Apache

Download Java from oracle site as Tomcat and Solr will be needing Java to work, after that follow these steps:

chmod 777 jdk-6u17-linux-i586.bin
./jdk-6u17-linux-i586.bin
mkdir -p /usr/java
cp -r  jdk1.6.0_17 /usr/java/
ln -s /usr/java/jdk1.6.0_17/bin/java /usr/bin/java
java -version

Change the .bin permission to executable by +x or 755 or 777.
ln -s :  Created the soft link for java to be executed from any where, you can also create environment variable for java according to you need.
java -version will display the java version installed.

Now once your java is installed correctly and enviornment is set download the Tomcat:

tar -zxvf apache-tomcat-7.0.39.tar.gz
mkdir  -p  /usr/tomcat
cp -rf apache-tomcat-7.0.39/* /usr/tomcat/
ls /usr/tomcat/
/usr/tomcat/bin/version.sh

Now we need Tomcat Native to link Apache and Tomcat with each other so download the tomcat-connectors:

tar -zxvf tomcat-connectors-1.2.37-src.tar.gz
cd tomcat-connectors-1.2.37-src/native/
./configure --with-apxs=/usr/local/apache2/bin/apxs  --with-java-home=/usr/java/jdk1.6.0_17 --prefix=/usr
make
make install

Now add the configuration which you want to setup for your Tomcat server in httpd.conf and worker.properties:

cd /usr/local/apache2/conf/
cp httpd.conf httpd.conf.original
vi worker.properties
vi httpd.conf
../bin/apachectl stop
../bin/apachectl start

Here is demo configuration for httpd.conf and workers.properties:

configure httpd.conf. 

JkWorkersFile /usr/local/apache2/conf/worker.properties
JkLogFile logs/jk-log
# Set the jk log level debug/error/info
JkLogLevel info
# Select the log format
JkLogStampFormat "%a %b %d %H:%M:%S %Y "
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"
# Mount your applications
JkMount /rest/* node1 

configure workers.properties. 

# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
# modifications after using mpm worker
worker.worker1.connection_pool_size=128
worker.worker1.connection_pool_timeout=600
worker.worker1.socket_keepalive=1  

Now download the Solr source:

tar -zxvf solr-4.2.1.tgz
mkdir -p /usr/solr/
cp -rf solr-4.2.1/* /usr/solr/


How to delete multiple user in linux

 To delete multiple user in Linux, refer the following video.



If you want to delete multiple system users in Linux following command can be used..
for user in `cat del.user`;do userdel $user;done

user : its the variable used to have values from del.user.
del.user : Its the file having name of the users which you want to delete.
userdel : Command used to delete user.
userdel -r : If you want to delete users home directory as well use this.

File having user names which need to be removed:
# cat del.user
ravi
roma
ben
honey
chin


How to check logs hour wise and know the maximum requests in respecitive hours..

If you want to check logs per hours from a days log file use the following command:

Here time.list is the file having time period of which logs is needed by hours..

for  time in `cat  time.list`;do cat access.log | grep -ir 30/Jul/2013:$time: > logs_$time:00-$time:59.txt;done  

It will create the separate text files having logs entry with in the time periods ex "logs_12:00-12:59.txt".


If you need to know maximum requests within specific hours use the following command:

for  time in `cat  time.list`;do cat access.log | grep -ir 30/Jul/2013:$time: | awk ' { print $7 } ' | sort | uniq -cd | sort -nr  |head -15 > maxhit_$time:00-$time:59.txt;done  

awk ' { print $7 } ' : It will take the 7th entry from logs.
sort : It will sort the hits.
uniq -cd : It will count the unique entry and not display the ones having only single entry.
sort -nr : It will count all the unique entries.
head -15 : It will display the top 15 results.

Command will create the separate text file having maximum hits in an hour ex "maxhits_12:00-12:59.txt"


For example it you want logs or hits from 10:00 AM to 20:00 PM use following time.list file.
# cat time.list
10
11
12
13
14
15
16
17
18
19
20


script to backup log files..

If there are multiple logs files which needed to be compressed and than Null following script can be used:

# vi log_compress.sh

echo $1_`date +%d%B%y`

cat $1 | gzip > $1_`date +%d%B%y`.gz
cp /dev/null $1

# chmod 755 log_compress.sh

For example you want to compress error.log use the following command:

# sh log_compress.sh error.log

It will compress the error log in .gz format and null the original error.log



How to install or update newrelic to latest version

Use the following steps to update Relic to latest version:

Url to track latest update:
http://download.newrelic.com/php_agent/release/(external link)

Steps:
  1. wget http://download.newrelic.com/php_agent/release/newrelic-php5-3.7.5.7-linux.tar.gz(external link)
  2. tar –xvf newrelic-php5-3.7.5.7-linux.tar.gz
  3. cp –r newrelic-php5-3.7.5.7-linux /usr/local/
  4. cd /usr/local/newrelic-php5-3.7.5.7-linux/
  5. ls
agent daemon LICENSE MD5SUMS newrelic-install README scripts
  1. ./newrelic-install
  2. /usr/local/apache2/bin/apachectl stop
  3. /usr/local/apache2/bin/apachectl start
  4. php -i | grep Relic
New Relic RPM Monitoring => enabled
New Relic Version => 3.7.5.7 ("hadrosaurus")

Setup fully configurable EFK Elasticsearch Fluentd Kibana setup in Kubernetes

In the following setup, we will be creating a fully configurable Elasticsearch, Flunetd, Kibana setup better known as EKF setup. There is a...