Pages

About-Me

Saturday, August 28, 2010 Posted by Shrikant Lokhande 0 comments
Hey Guys,

My self Shrikant Lokhande, from Pune, India.

This is my first Technical blog. Here i will post all things related with Linux Administration, E.g. Monitoring, Commands, Shell scripts, Security, ect.
Also every post is going through test from me. And i face every issue for the resolution i have spend some time and i will very glad if it work;s for others
who also face such type of issue.

You'r Always Welcome for Suggestion. Please comment whatever you like or dislike i always to Answer your Question.

Thanks-
Email Id: lokhande.shrikant@gmail.com
Skype: shriikant
Mobile no : +91-9373920803
Labels:

How To Compile Apache on Linux/Solaris.

Thursday, December 3, 2009 Posted by Shrikant Lokhande 0 comments
Download Source from http://httpd.apache.org/download.cgi

gunzip httpd-2.2.14.tar.gz
tar -xvf httpd-2.2.14.tar
---------------------------------------------------
./configure --prefix=/usr/local/apache2 --with-mpm=worker --disable-cgid --enable-info --enable-proxy --enable-proxy-connect --enable-proxy-ftp --enable-proxy-http --enable-proxy-balancer --enable-rewrite --enable-headers --enable-cache --enable-mem-cache --enable-disk-cache --enable-expires --enable-mods-shared=all --enable-ssl=shared --with-ssl=/usr/local/ssl
make
make install
------------------------------------------------------
/usr/local/apache2/bin/apachectl restart


Please let me know, if anything i forgot.;)
Labels:

WebSite Monitoring Simple .!

Monday, November 16, 2009 Posted by Shrikant Lokhande 0 comments
First of all create one /opt/monitoring.rb and /home/sites.txt
-------------------------------------------------------------
#!/usr/bin/ruby

require 'net/http'
require 'net/smtp'


File.open("/home/sites.txt").each { |line|
# get rid of CRLF
line.chomp!

next if(line[0..0] == '#' || line.empty?)

# url, emails = line.split(' ')
# emails = emails.split(",")

url= line.split(' ')

# check if http:// was in the url if not add it in there
# url.insert(0, "http://") unless(url.match(/^http\:\/\//))

# Get the HTTP_RESPONSE from the site we are checking
res = Net::HTTP.get_response(URI.parse(url.to_s))

# Check the response code and send an email if the code is bad
unless(res.code =~ /2|3\d{2}/ ) then
from = "shrikant.lokhande@gmail.com"
message = "From: shrikant.lokhande@gmail.com\nSubject: #{url} Unavailable\n\n#{url} - #{res.code} - #{res.message}\nHTTP Version - #{res.http_version}\n\n"
begin
Net::SMTP.start("smtp server",25,"domain name","username","passwd","login") do |smtp|
smtp.send_message(message, from, 'youremail@gmail.com')
end
rescue Exception => e
print "Exception occured: " + e
end
end
}
-------------------------------------------

vi /home/sites.txt

http://www.website.com
-------------------------------------------

Add script in cron like :
* * * * * ruby /opt/monitoring.rb

from another server or same server. but prefer from another server. configure SMTP and add your email id in the script for alert.

Thats it.!
Labels:

Script for Mysql Backup on Linux.

Monday, November 9, 2009 Posted by Shrikant Lokhande 0 comments
#!/bin/bash
# USER VARIABLES
TIMESTAMP=$(date +%Y-%m-%d)
MYSQLUSER=root
MYSQLPWD=passwd
MYSQLHOST=localhost
# PATH VARIABLES
MK=/bin/mkdir
GREP=/bin/grep
MYSQL=/usr/bin/mysql
MYSQLDUMP=/usr/bin/mysqldump
# CREATE MYSQL BACKUP
# Create new backup dir
$MK /backup/mysqlbackup/mysqlback_$TIMESTAMP
#Dump new files
for i in $(echo 'SHOW DATABASES;' | $MYSQL -u$MYSQLUSER -p$MYSQLPWD -h$MYSQLHOST|$GREP -v '^Database$'); do
run $MYSQLDUMP -u$MYSQLUSER -p$MYSQLPWD -h$MYSQLHOST $i >/backup/mysqlbackup/mysqlback_$TIMESTAMP/$i.sql
echo "$i"
done

------------------------------
run this script in cron like
* 1 * * * /usr/bin/mysqlbackup
Labels:

Mysql Master-Slave Replication

Tuesday, October 20, 2009 Posted by Shrikant Lokhande 0 comments
Master server ip: 10.0.0.1
Slave server ip: 10.0.0.2
Slave username: repl
Slave pw: replpasswd
Your data directory is: /usr/local/mysql/data


-----------------------Master Server-----------------------
# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-locking
key_buffer_size = 256M
max_allowed_packet = 1M
table_open_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8

# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin


# Uncomment the following if you are using InnoDB tables
innodb_data_home_dir = /usr/local/mysql/data/
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /usr/local/mysql/data/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 256M
innodb_additional_mem_pool_size = 20M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 64M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

# changes made to do slave

server-id = 1
relay-log = /usr/local/mysql/data/mysql-relay-bin
relay-log-index = /usr/local/mysql/data/mysql-relay-bin.index
log-error = /usr/local/mysql/data/mysql.err
master-info-file = /usr/local/mysql/data/mysql-master.info
relay-log-info-file = /usr/local/mysql/data/mysql-relay-log.info
datadir = /usr/local/mysql/data
log-bin = /usr/local/mysql/data/mysql-bin


#binlog_do_db =f4pforalpha


# end master

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout
--------------------------------------------------------------------------------

***********Slave server*******************
# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-locking
key_buffer_size = 256M
max_allowed_packet = 1M
table_open_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8

slave-net-timeout = 30
master-connect-retry = 30

# Uncomment the following if you are using InnoDB tables
innodb_data_home_dir = /usr/local/mysql/data/
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /usr/local/mysql/data/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 256M
innodb_additional_mem_pool_size = 20M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 64M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50


# changes made to do slave
server-id = 2
relay-log = /usr/local/mysql/data/mysql-relay-bin
relay-log-index = /usr/local/mysql/data/mysql-relay-bin.index
log-error = /usr/local/mysql/data/mysql.err
master-info-file = /usr/local/mysql/data/mysql-master.info
relay-log-info-file = /usr/local/mysql/data/mysql-relay-log.info
datadir = /usr/local/mysql/data
# end slave setup

# end slave

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout
---------------------------------------------------------------------------

Create user on master:
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'10.0.0.2' IDENTIFIED BY 'replpass';
FLUSH TABLES WITH READ LOCK;
mysqldump -u root --all-databases --single-transaction --master-data=1 > masterdump.sql
rsync -avz -e ssh /opt/dbdump123.db root@10.0.0.2:/opt
mysql < masterdump.sql
Login to Slave Server.
CHANGE MASTER TO MASTER_HOST='10.0.0.1', MASTER_USER='repl', MASTER_PASSWORD='replpass';
mysql> start slave;
mysql> show slave status\G

Its Looks Like.


mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.0.0.1
Master_User: repl
Master_Port: 3306
Connect_Retry: 30
Master_Log_File: mysql-bin.000014
Read_Master_Log_Pos: 199
Relay_Log_File: mysql-relay-bin.000242
Relay_Log_Pos: 251
Relay_Master_Log_File: mysql-bin.000014
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 199
Relay_Log_Space: 551
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
1 row in set (0.00 sec)


---------------------------------------------------

SHOW MASTER STATUS;

mysql> SHOW MASTER STATUS\G;
*************************** 1. row ***************************
File: mysql-bin.000014
Position: 199
Binlog_Do_DB:
Binlog_Ignore_DB:
1 row in set (0.00 sec)

ERROR:
No query specified

---------------------------------------------------------
Labels:

Cpanel/WHM Documentation

Friday, October 16, 2009 Posted by Shrikant Lokhande 0 comments
Hi All,

You may find good documentation of cPanel/WHM installation and configuration.

http://twiki.cpanel.net/twiki/bin/view/AllDocumentation/WebHome

Enjoy- ;)
Labels:

Shrikant Lokhande's blog | Found on IndiBlogger.in

Monday, September 21, 2009 Posted by Shrikant Lokhande 0 comments

I want you to take a look at: Shrikant Lokhande's blog

It's on IndiBlogger.in, the largest, coolest and most active community of Indian bloggers!

Labels: