Thursday, June 24, 2010

Check Mysql Master-Slave Replication Script.

This is Mysql Master-Slave Replication Script which is checking position of log. you can set as cron and run.

vi /usr/bin/scriptname

#! /bin/bash
#
# Will Run on LOCAL LAN ON EC2 CLUSTER

SLAVE_HOST=1.2.2.1
SLAVE_PASS=passwd
SLAVE_USER=root

MASTER_PASS=passwd
MASTER_USER=root
MASTER_HOST=1.2.4.2

master_pos=`/usr/local/mysql/bin/mysql -u$SLAVE_USER -p$SLAVE_PASS -h$SLAVE_HOST -e 'show slave status \G;' |grep -r 'Read_Master_Log_Pos' |awk '{ printf " %s ", $2 }' |xargs`


slave_pos=`/usr/local/mysql/bin/mysql -u$MASTER_USER -p$MASTER_PASS -h$MASTER_HOST -e 'show master status;' | grep mysql-bin |awk '{ printf " %s ", $2 }' |xargs`

echo $master_pos
echo $slave_pos

expr $master_pos - $slave_pos

echo $master_pos
echo $slave_pos

Tuesday, June 8, 2010

/usr/libexec/mysqld: Can't change dir to '/data/mysql/' (Errcode: 13) [Resolved]

If you want's to change mysql default data directory or apart of /var/lib/mysql and for this setting you are facing this type of issue:
========================================================================
/usr/libexec/mysqld: Can't change dir to '/data/mysql/' (Errcode: 13)
100607 16:57:44 [ERROR] Aborting

100607 16:57:44 [Note] /usr/libexec/mysqld: Shutdown complete

100607 16:57:44 mysqld ended
========================================================================
Solution.
Just Do.

mysql_install_db --user=mysql --ldata=/data/mysql
mysqld_safe --datadir=/data/mysql --user=mysql &

[root@321 mysql]# /etc/init.d/mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
[root@dh119sj mysql]#

Yo.!

Thursday, May 13, 2010

PHP+FPM Compilation on Centos 5

Requirement:
yum install libmcrypt
yum install libmcrypt-devel

./configure --enable-fastcgi --enable-fpm --with-mcrypt --with-zlib --enable-mbstring --disable-pdo --with-curl --disable-debug --enable-pic --disable-rpath --enable-inline-optimization --with-bz2 --with-xml --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-xslt --enable-memcache --enable-zip --with-pcre-regex

make all install

Friday, April 30, 2010

UDP Protocol Used For Digital Signage.!

I have tested both protocol, both are UDP based and faster download.
Available in interactive mode.

http://tsunami-udp.sourceforge.net/

http://fsp.sourceforge.net/

Thursday, April 15, 2010

Configure staging environment for Phusion Passenger.!

Please follow step-by-step success is your's : LOL

Copy production.rb to staging.rb in config/environments
cd /app/config/environments/
cp production.rb staging.rb

Add a staging entry to your config/database.yml
Your database.yml is should like this :

staging:
adapter: mysql
reconnect: false
database: databae_staging
username: root
password: password
host: localhost
socket: /var/lib/mysql/mysql.sock

Add log file for staging env.
cd log/
touch staging.log
chmod 0666 log/staging.log

For just check. if the env is working for staging.
ruby script/server -e staging

For The Phusion Passenger (mod_rails) You have to put "RailsEnv staging" in your Apache Virtual Host.

Like this:

< virtualhost XX.XX.XX.XX:80 >

RailsEnv staging
< /VirtualHost >

restart apache
and check website.

Sunday, April 11, 2010

shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

Hey Guys,

If you facing issue " shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory " for restarting service whaterver mysql,httpd,etc,

just do "cd or cd / " on console

it will resolved.

[root@domU-taging]# /etc/init.d/mysqld restart
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]

[root@domU-taging]# cd

[root@domU- ~]# /etc/init.d/mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]

cool.;)

Tuesday, January 12, 2010

Ruby on Rails Deployment With Open Source Technology.

What We Need ? and What We Recommended. Ingredient For Deployment Recipes.

Linux: CentOs 5x (Recommended).
Kernel 2.6.x Flavor of any linux, Ubuntu, Gentoo , Or OpenSolaris.

WebServer: Apache(Httpd) Or Nginx (Recommended Stable)

Database : Mysql (Recommended Stable)

ImageMagick: 6.5.8-10 (Recommended Use Latest Version)

Ruby : 1.9.1 (Recommended Latest and Stable)

RubyGems : 1.3.5 (Recommended Latest and Stable)

Rails: 2.3.x (Recommended Latest and Stable)

Web Proxy: Mod_rails, Phusion Passenger. (Recommended Stable)

Let Start on Box.

[root@localhost ~]#yum install httpd httpd-devel mysql-server mysql mysql-devel phpmyadmin php

[root@localhost home]# wget ftp://ftp.fifi.org/pub/ImageMagick/ImageMagick-6.5.6-10.tar.gz

[root@localhost home]# wget ftp://ftp.fifi.org/pub/ImageMagick/ImageMagick-6.5.6-10.tar.gz
--2010-01-12 14:06:16-- ftp://ftp.fifi.org/pub/ImageMagick/ImageMagick-6.5.6-10.tar.gz
=> `ImageMagick-6.5.6-10.tar.gz'
Resolving ftp.fifi.org... 64.81.30.201
Connecting to ftp.fifi.org|64.81.30.201|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD /pub/ImageMagick ... done.
==> SIZE ImageMagick-6.5.6-10.tar.gz ... 11097065
==> PASV ... done. ==> RETR ImageMagick-6.5.6-10.tar.gz ... done.
Length: 11097065 (11M)

100%[==================================================================================================================>] 11,097,065 110K/s in 1m 42s

2010-01-12 14:08:07 (107 KB/s) - `ImageMagick-6.5.6-10.tar.gz' saved [11097065]

tar -xzvf ImageMagick-6.5.6-10.tar.gz

[root@localhost home]# cd ImageMagick-6.5.6-10

[root@localhost ImageMagick-6.5.6-10]# ./configure

[root@localhost ImageMagick-6.5.6-10]# make && make install

Downlaod Ruby and Install.

[root@localhost ~]# wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p376.tar.gz
--2010-01-12 13:28:00-- ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p376.tar.gz
=> `ruby-1.9.1-p376.tar.gz.1'
Resolving ftp.ruby-lang.org... 221.186.184.68
Connecting to ftp.ruby-lang.org|221.186.184.68|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD /pub/ruby/1.9 ... done.
==> SIZE ruby-1.9.1-p376.tar.gz ... 9073007
==> PASV ... done. ==> RETR ruby-1.9.1-p376.tar.gz ... done.
Length: 9073007 (8.7M)

100%[==================================================================================================================>] 9,073,007 217K/s in 54s

2010-01-12 13:28:58 (163 KB/s) - `ruby-1.9.1-p376.tar.gz' saved [9073007]

[root@localhost ~]#tar -xzvf ruby-1.9.1-p376.tar.gz
[root@localhost ~]#cd ruby-1.9.1-p376
[root@localhost ruby-1.9.1-p376]# ./configure
[root@localhost ruby-1.9.1-p376]# make && make install
[root@localhost ruby-1.9.1-p376]# which ruby
/usr/local/bin/ruby
[root@localhost ruby-1.9.1-p376]# /usr/local/bin/ruby -v
ruby 1.9.1p376 (2009-12-07 revision 26041) [i686-linux]

Download and Install RubyGems

[root@localhost home]# wget http://rubyforge.org/frs/download.php/60719/rubygems-1.3.5.zip
--2010-01-12 14:21:38-- http://rubyforge.org/frs/download.php/60719/rubygems-1.3.5.zip
Resolving rubyforge.org... 205.234.109.19
Connecting to rubyforge.org|205.234.109.19|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://files.rubyforge.vm.bytemark.co.uk/rubygems/rubygems-1.3.5.zip [following]
--2010-01-12 14:21:43-- http://files.rubyforge.vm.bytemark.co.uk/rubygems/rubygems-1.3.5.zip
Resolving files.rubyforge.vm.bytemark.co.uk... 80.68.94.54
Connecting to files.rubyforge.vm.bytemark.co.uk|80.68.94.54|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 362863 (354K) [application/zip]
Saving to: `rubygems-1.3.5.zip'

100%[==================================================================================================================>] 362,863 34.6K/s in 15s

2010-01-12 14:22:02 (23.0 KB/s) - `rubygems-1.3.5.zip' saved [362863/362863]

[root@localhost home]# unzip rubygems-1.3.5.zip

[root@localhost home]# cd rubygems-1.3.5

[root@localhost rubygems-1.3.5]# /usr/local/bin/ruby setup.rb
RubyGems 1.3.5 installed

[root@localhost rubygems-1.3.5]# gem -v
1.3.5

[root@localhost rubygems-1.3.5]# gem -v
1.3.5
You have new mail in /var/spool/mail/root
[root@localhost rubygems-1.3.5]# gem install rails
Successfully installed rake-0.8.7
Successfully installed activesupport-2.3.5
Successfully installed activerecord-2.3.5
Successfully installed rack-1.0.1
Successfully installed actionpack-2.3.5
Successfully installed actionmailer-2.3.5
Successfully installed activeresource-2.3.5
Successfully installed rails-2.3.5
8 gems installed
Installing ri documentation for rake-0.8.7...
Installing ri documentation for activesupport-2.3.5...
Installing ri documentation for activerecord-2.3.5...
Installing ri documentation for rack-1.0.1...
Installing ri documentation for actionpack-2.3.5...
Installing ri documentation for actionmailer-2.3.5...
Installing ri documentation for activeresource-2.3.5...
Installing ri documentation for rails-2.3.5...
Updating class cache with 1513 classes...
Installing RDoc documentation for rake-0.8.7...
Installing RDoc documentation for activesupport-2.3.5...
Installing RDoc documentation for activerecord-2.3.5...
Installing RDoc documentation for rack-1.0.1...
Installing RDoc documentation for actionpack-2.3.5...
Installing RDoc documentation for actionmailer-2.3.5...
Installing RDoc documentation for activeresource-2.3.5...
Installing RDoc documentation for rails-2.3.5...
You have new mail in /var/spool/mail/root
[root@localhost rubygems-1.3.5]# gem list rails

*** LOCAL GEMS ***

rails (2.3.5)

Download and Install Passenger

[root@localhost home]#gem install passenger
Building native extensions. This could take a while...
Building native extensions. This could take a while...
Successfully installed fastthread-1.0.7
Successfully installed passenger-2.2.9
2 gems installed
Installing ri documentation for fastthread-1.0.7...
Installing ri documentation for passenger-2.2.9...
Updating class cache with 2543 classes...
Installing RDoc documentation for fastthread-1.0.7...
Installing RDoc documentation for passenger-2.2.9...

[root@localhost rubygems-1.3.5]# passenger-install-apache2-module

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

Please edit your Apache configuration file, and add these lines:

LoadModule passenger_module /usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.2.9/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.2.9
PassengerRuby /usr/local/bin/ruby

After you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific
configuration!
----------------------------------------------

Edit Your httpd.conf and module.
Now Configure your Host in Apache Virtual Host and restart Apache.
/etc/init.d/httpd restart.

Wednesday, December 9, 2009

Errno::EACCES (Permission denied - Permission denied - Paperclip+Jruby+RMagick4j

If The issue Like:
===========================================================================================
Processing UsersController#upload_photo (for 125.18.56.182 at 2009-12-09 00:29:27) [POST]
Parameters: {"authenticity_token"=>"9w6TN5+/SsEp90euL2/qX/z+/v/RGkwPy7jKCmA1Z2A=", "user"=>{"photo"=>#}, "x"=>"31", "y"=>"16"}
User Load (3.0ms) SELECT * FROM `users` WHERE (`users`.`id` = 29) LIMIT 1
User Load (3.0ms) SELECT `users`.id FROM `users` WHERE (LOWER(`users`.`screen_name`) = 'shrii' AND `users`.id <> 29) LIMIT 1
User Load (3.0ms) SELECT `users`.id FROM `users` WHERE (LOWER(`users`.`email`) = 'shrikant.lokhande@betterlabs.net' AND `users`.id <> 29) LIMIT 1
User Update (2.0ms) UPDATE `users` SET `photo_file_name` = '3d_animals_11.jpg', `photo_content_type` = 'image/jpeg', `photo_file_size` = 0, `non_login_key` = '7276c63c3af812a1d7b9dca628e27f437b8003dc', `updated_at` = '2009-12-09 05:29:28' WHERE `id` = 29
[paperclip] Saving attachments.
[paperclip] saving /mnt/assets/3d_animals_11.jpg

Errno::EACCES (Permission denied - Permission denied - /tmp/3d_animals_11,12625,3937.jpg or /mnt/app/3d_animals_11.jpg):
/opt/jruby/lib/ruby/1.8/fileutils.rb:505:in `mv'
/opt/jruby/lib/ruby/1.8/fileutils.rb:1395:in `fu_each_src_dest'
/opt/jruby/lib/ruby/1.8/fileutils.rb:1411:in `fu_each_src_dest0'
/opt/jruby/lib/ruby/1.8/fileutils.rb:1393:in `fu_each_src_dest'
/opt/jruby/lib/ruby/1.8/fileutils.rb:494:in `mv'
app/controllers/users_controller.rb:72:in `upload_photo'
====================================================================================

FIX is :
vi rails/vendor/plugins/paperclip/lib/paperclip.rb

-----------------------------------
def flush_writes #:nodoc:
@queued_for_write.each do |style, file|
file.close
FileUtils.mkdir_p(File.dirname(path(style)))
log("saving #{path(style)}")
# FileUtils.mv(file.path, path(style)) # Comment out this
FileUtils.cp(file.path, path(style)) # add this two line
FileUtils.rm(file.path) # this too.
FileUtils.chmod(0644, path(style))
end
@queued_for_write = {}
end
---------------------------------------
Its look like.

Its Worked for me. Cool.

Thursday, December 3, 2009

How To Compile Apache on Linux/Solaris.

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

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

Monday, November 16, 2009

WebSite Monitoring Simple .!

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.!

Monday, November 9, 2009

Script for Mysql Backup on Linux.

#!/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

Tuesday, October 20, 2009

Mysql Master-Slave Replication

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

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

Friday, October 16, 2009

Cpanel/WHM Documentation

Hi All,

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

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

Enjoy- ;)

Monday, September 21, 2009

Shrikant Lokhande's blog | Found on IndiBlogger.in

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!

Sunday, September 6, 2009

How to change MTA on Centos5.3(RHEL based server)

Here you can see, how to change MTA qmail to any other you can set as simple sendmail or postfix, exim or qmail.

[root@hostshot ~]#ll /etc/alternatives/mta
lrwxrwxrwx 1 root root 23 Aug 31 03:39 /etc/alternatives/mta -> /var/qmail/bin/sendmail


[root@hotshot ~]# alternatives --config mta

There are 4 programs which provide 'mta'.

Selection Command
-----------------------------------------------
*+ 1 /var/qmail/bin/sendmail
2 /usr/sbin/sendmail.exim
3 /usr/sbin/sendmail.postfix
4 /usr/sbin/sendmail.sendmail

Enter to keep the current selection[+], or type selection number: 2

[root@vh115sj ~]# /etc/init.d/qmail stop
Stopping : [root@hotshot ~]# /etc/init.d/exim restart
Shutting down exim: [ OK ]
Starting exim: [ OK ]

[root@hotshot ~]# echo " for shrikant " | mail -s " for shrikant " shrikant.lokhande@betterlabs.net

;) Its done. Please comment if any issue.

Thursday, August 20, 2009

Problem with installation of gem mechanize nokogiri rfeedparser

If the issue is with installtion of :
gem install mechanize


Following package needs:
yum install expat
yum install libexpat
yum install libxml2-devel
yum install libxml
yum install libxml-devel
yum install libxslt libxslt-dev
yum install libxslt-devel

cd /usr/local/lib/ruby/gems/1.8/gems/nokogiri-1.3.3
ruby ext/nokogiri/extconf.rb
make
make install

Or just do "gem install mechanize"

----------------------------------------------------------------------
gem install rfeedparser

Building native extensions. This could take a while...
ERROR: Error installing rfeedparser:
ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb
checking for main() in -lc... yes
creating Makefile

make
gcc -I. -I/usr/local/include/ruby-1.9.1/i686-linux -I/usr/local/include/ruby-1.9.1/ruby/backward -I/usr/local/include/ruby-1.9.1 -I. -D_FILE_OFFSET_BITS=64 -fPIC -O2 -g -Wall -Wno-parentheses -o hpricot_scan.o -c hpricot_scan.c
ext/hpricot_scan/hpricot_scan.rl: In function ‘hpricot_scan’:
ext/hpricot_scan/hpricot_scan.rl:172: error: ‘struct RString’ has no member named ‘ptr’
ext/hpricot_scan/hpricot_scan.rl:185: error: ‘struct RString’ has no member named ‘ptr’
ext/hpricot_scan/hpricot_scan.rl:185: error: ‘struct RString’ has no member named ‘len’
ext/hpricot_scan/hpricot_scan.rl:186: error: ‘struct RString’ has no member named ‘len’
ext/hpricot_scan/hpricot_scan.rl:202: error: ‘struct RString’ has no member named ‘ptr’
make: *** [hpricot_scan.o] Error 1


Gem files will remain installed in /usr/local/lib/ruby/gems/1.9.1/gems/hpricot-0.6 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.9.1/gems/hpricot-0.6/ext/hpricot_scan/gem_make.out

Resolution:
Need Above all yum packages installed.

http://www.yoshidam.net/xmlparser-0.6.8.tar.gz
cd xmlparser/
ruby extconf.rb
checking for expat.h... yes
checking for XML_ParserCreate() in -lexpat... yes
checking for XML_SetNotStandaloneHandler()... yes
checking for XML_SetParamEntityParsing()... yes
checking for XML_SetDoctypeDeclHandler()... yes
checking for XML_ParserReset()... yes
checking for XML_SetSkippedEntityHandler()... yes
checking for XML_GetFeatureList()... yes
checking for XML_UseForeignDTD()... yes
checking for XML_GetIdAttributeIndex()... yes
checking for ntohl() in -lsocket... no
creating Makefile

make && make install

root@localhost xmlparser]# gem install rfeedparser
Successfully installed rfeedparser-0.9.951
1 gem installed
[root@localhost xmlparser]#

rock na.! if any issue, write to lokahnde.shrikant@gmail.com

How to "gem install mysql" ?

If you trying to install mysql gem, and you are not able to install.
-----------------------------------------------------
gem install mysql
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb install mysql
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
-----------------------------------------------------

Resolution :


cd /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/ && ruby extconf.rb --with-mysql-config --with-mysql-include

o/p:
checking for mysql_ssl_set()... yes
checking for mysql.h... yes
creating Makefile
[root@localhost:/usr/local/lib/ruby/gems/1.8/gems/mysql-2.7] make
gcc -I. -I. -I/usr/local/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_SSL_SET -DHAVE_MYSQL_H -I/usr/include/mysql -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -g -O2 -c mysql.c
gcc -shared -o mysql.so mysql.o -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L. -rdynamic -Wl,-export-dynamic -L/usr/lib64/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -L/usr/lib64 -lssl -lcrypto -ldl -lcrypt -lm -lc

make install
o/p:/usr/bin/install -c -m 0755 mysql.so /usr/local/lib/ruby/site_ruby/1.8/x86_64-linux

[root@localhost rails
]# irb

irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'mysql'
=> true
irb(main):003:0> quit

Cool Done.! It may possible that mysql gem is not in gem list.

Friday, August 14, 2009

How to set sphinx.yml for Thinking-Sphinx (full text indexer)?

----------------------------------------------------------------------
vi config/sphinx.yml

production:
port: 3312
address: 127.0.0.1
mem_limit: 512M
max_children: 300
max_matches: 100000
seamless_rotate: 1
preopen_indexes: 1
query_log_file: /mnt/app/rails/releases/code/log/searchd.query.log
searchd_log_file: /mnt/app/rails/releases/code/log/searchd.log
pid_file: /mnt/app/crawler/rails/code/log/searchd.production.pid
searchd_file_path: /mnt/app/rails/current/db/sphinx/production/

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

It is for Production mode, you can set same for development or staging mode just to change environment.

Access remote mysql database.

Grant all databases remotely to given IP address:

GRANT ALL ON *.* TO root@'164.19.212.15' IDENTIFIED BY 'passwd';


If you want to Particular IP address :

GRANT ALL ON india.* TO root@'164.19.212.15' IDENTIFIED BY 'passwd';

Monday, August 10, 2009

Create Session table in (RoR) Ruby on Rails .!

CREATE TABLE `sessions` (
`id` int(11) NOT NULL auto_increment,
`session_id` varchar(255) default NULL,
`data` varchar(255) default NULL,
`updated_at` datetime default NULL,
`created_at` datetime default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


To change Session cookie to Active records do following setting:
cat config/initializers/session_store.rb

* un-comment line
ActionController::Base.session_store = :active_record_store