Hey Guys,
I have issue with some ruby script and rails, rake script not running as cronjob,
so you can use the following solution.
=============================================
[root@localhost ] vi /usr/bin/railscron
#! /bin/bash
cd /app/production/current/
PATH=$PATH:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin/
/usr/local/bin/rake user:details RAILS_ENV=production >> /tmp/test
echo "its running"
==============================================
* Set as Cronjob now:
* 10 * * * /usr/bin/railscron
Fixed.
If any query, Please let me know. I am here to solve your issue.
Yo.!
Monday, October 25, 2010
Tuesday, October 19, 2010
ActionController::RoutingError No route matches .html
Added extra .html to URL in rails.
If you have added following rewiterules in apache configuration Or added in your .htaccess in your public. Basically its required for the FastCGI. if you run fastCGI server then its need, but if you running Passenger
should be remove
---------------------------------------
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
----------------------------------------
So solution is please remove that from apache config Or remove .htaccess for the passenger only. njoy.!
If you have added following rewiterules in apache configuration Or added in your .htaccess in your public. Basically its required for the FastCGI. if you run fastCGI server then its need, but if you running Passenger
should be remove
---------------------------------------
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
----------------------------------------
So solution is please remove that from apache config Or remove .htaccess for the passenger only. njoy.!
Tuesday, September 28, 2010
Background Jobs In Rails.
Well, We all know the Rails Deployment if, not please read my some older post it will really help you
for that.
Here what i am discussing it is also part of Administration/Deployment. Yes, I am Talking about Background Process. For the Rails application there is way, to run the background task with different ways i.e. as follows.
BackgroundDrb
Delayed Job
Background Job{aka BJ}
SpawWorkling
BackgroundFu
Rufus Scheduler
You can check RailsCast for the configure and installation, and i will share with you what my experience with Background Jobs, How its works, How to manage, all things.
for that.
Here what i am discussing it is also part of Administration/Deployment. Yes, I am Talking about Background Process. For the Rails application there is way, to run the background task with different ways i.e. as follows.
BackgroundDrb
Delayed Job
Background Job{aka BJ}
SpawWorkling
BackgroundFu
Rufus Scheduler
You can check RailsCast for the configure and installation, and i will share with you what my experience with Background Jobs, How its works, How to manage, all things.
Monday, August 23, 2010
[PHP+FPM+NGINX] Installtion/Compilation/Confiuration.
Its Installtion/Compilation/Confiuration of PHP+FPM+NGINX.
Please Follow The Steps One By One, Its Working Configration Tested By Me :0). IF The Any Issue Please Contact Me.
wget http://museum.php.net/php5/php-5.2.8.tar.gz
tar -xvf php-5.2.8.tar.gz
cd php-5.2.8
=========================================
./configure --enable-fastcgi --enable-fpm --with-mcrypt --with-zlib --enable-mbstring --with-pgsql --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 --with-curl --with-curlwrappers --with-ncurses --with-openssl --with-openssl-dir=/usr --with-pdo-mysql=/usr --cache-file=./config.cache' '--with-pcre-regex=/usr --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-gdbm --with-gettext --without-gmp --without-kerberos --enable-mbstring --with-mcrypt --with-mhash --enable-sockets --with-openssl --with-openssl-dir=/usr --with-gd=/usr --with-db4
=========================================
vi /etc/init.d/php-fastcgi
#!/bin/bash
BIND=127.0.0.1:9000
USER=root
PHP_FCGI_CHILDREN=8
PHP_FCGI_MAX_REQUESTS=1000
#PHP_CGI=/usr/bin/php-cgi
PHP_CGI=/usr/local/bin/php-cgi
PHP_CGI_NAME=`basename $PHP_CGI`
PHP_CGI_ARGS="- USER=$USER PATH=/usr/bin PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND"
RETVAL=0
start() {
echo -n "Starting PHP FastCGI: "
start-stop-daemon --quiet --start --background --chuid "$USER" --exec /usr/bin/env -- $PHP_CGI_ARGS
RETVAL=$?
echo "$PHP_CGI_NAME."
}
stop() {
echo -n "Stopping PHP FastCGI: "
killall -q -w -u $USER $PHP_CGI
RETVAL=$?
echo "$PHP_CGI_NAME."
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: php-fastcgi {start|stop|restart}"
exit 1
;;
esac
exit $RETVAL
=============================================
vi /etc/nginx/servers/magento.conf
server {
listen 80;
server_name domain.com;
root /home/magento/;
location / {
index index.html index.php; ## Allow a static html file to be shown first
# try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
expires max; ## Assume all files are cachable
error_page 404 = @handler;
log_not_found off;
}
location ~ /(.*)/index\.php$ { ## strip index.php from product urls
if (!-e $request_filename) { rewrite ^(.*)/index\.php$ $1/ permanent; }
}
location /minify/ { ## Needed for Fooman Speedster
rewrite ^/minify/([0-9]+)(/.*\.(js|css))$
/lib/minify/m.php?f=$2&d=$1 last;
}
## These locations would be hidden by .htaccess normally
location /app/ { deny all; }
location /includes/ { deny all; }
location /lib/ { deny all; }
location /lib/minify/ { allow all; } ## Deny is applied after rewrites so must specifically allow minify
location /media/downloadable/ { deny all; }
location /pkginfo/ { deny all; }
location /report/config.xml { deny all; }
location /var/ { deny all; }
location /var/export/ { ## Allow admins only to view export folder
auth_basic "Restricted"; ## Message shown in login window
auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
}
location /. { ## Disable .htaccess and other hidden files
return 404;
}
location @handler { ## Magento uses a common front handler
rewrite / /index.php;
}
location ~ \.php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*\.php)/ $1 last;
}
location ~ \.php$ { ## Execute PHP scripts
expires off; ## Do not cache dynamic content
# fastcgi_param HTTPS $fastcgi_http;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param MAGE_RUN_CODE base;
fastcgi_param MAGE_RUN_TYPE website;
include fastcgi_params; ## See /etc/nginx/fastcgi_params
}
}
====================================
Please Follow The Steps One By One, Its Working Configration Tested By Me :0). IF The Any Issue Please Contact Me.
wget http://museum.php.net/php5/php-5.2.8.tar.gz
tar -xvf php-5.2.8.tar.gz
cd php-5.2.8
=========================================
./configure --enable-fastcgi --enable-fpm --with-mcrypt --with-zlib --enable-mbstring --with-pgsql --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 --with-curl --with-curlwrappers --with-ncurses --with-openssl --with-openssl-dir=/usr --with-pdo-mysql=/usr --cache-file=./config.cache' '--with-pcre-regex=/usr --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-gdbm --with-gettext --without-gmp --without-kerberos --enable-mbstring --with-mcrypt --with-mhash --enable-sockets --with-openssl --with-openssl-dir=/usr --with-gd=/usr --with-db4
=========================================
vi /etc/init.d/php-fastcgi
#!/bin/bash
BIND=127.0.0.1:9000
USER=root
PHP_FCGI_CHILDREN=8
PHP_FCGI_MAX_REQUESTS=1000
#PHP_CGI=/usr/bin/php-cgi
PHP_CGI=/usr/local/bin/php-cgi
PHP_CGI_NAME=`basename $PHP_CGI`
PHP_CGI_ARGS="- USER=$USER PATH=/usr/bin PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND"
RETVAL=0
start() {
echo -n "Starting PHP FastCGI: "
start-stop-daemon --quiet --start --background --chuid "$USER" --exec /usr/bin/env -- $PHP_CGI_ARGS
RETVAL=$?
echo "$PHP_CGI_NAME."
}
stop() {
echo -n "Stopping PHP FastCGI: "
killall -q -w -u $USER $PHP_CGI
RETVAL=$?
echo "$PHP_CGI_NAME."
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: php-fastcgi {start|stop|restart}"
exit 1
;;
esac
exit $RETVAL
=============================================
vi /etc/nginx/servers/magento.conf
server {
listen 80;
server_name domain.com;
root /home/magento/;
location / {
index index.html index.php; ## Allow a static html file to be shown first
# try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
expires max; ## Assume all files are cachable
error_page 404 = @handler;
log_not_found off;
}
location ~ /(.*)/index\.php$ { ## strip index.php from product urls
if (!-e $request_filename) { rewrite ^(.*)/index\.php$ $1/ permanent; }
}
location /minify/ { ## Needed for Fooman Speedster
rewrite ^/minify/([0-9]+)(/.*\.(js|css))$
/lib/minify/m.php?f=$2&d=$1 last;
}
## These locations would be hidden by .htaccess normally
location /app/ { deny all; }
location /includes/ { deny all; }
location /lib/ { deny all; }
location /lib/minify/ { allow all; } ## Deny is applied after rewrites so must specifically allow minify
location /media/downloadable/ { deny all; }
location /pkginfo/ { deny all; }
location /report/config.xml { deny all; }
location /var/ { deny all; }
location /var/export/ { ## Allow admins only to view export folder
auth_basic "Restricted"; ## Message shown in login window
auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
}
location /. { ## Disable .htaccess and other hidden files
return 404;
}
location @handler { ## Magento uses a common front handler
rewrite / /index.php;
}
location ~ \.php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*\.php)/ $1 last;
}
location ~ \.php$ { ## Execute PHP scripts
expires off; ## Do not cache dynamic content
# fastcgi_param HTTPS $fastcgi_http;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param MAGE_RUN_CODE base;
fastcgi_param MAGE_RUN_TYPE website;
include fastcgi_params; ## See /etc/nginx/fastcgi_params
}
}
====================================
Wednesday, July 21, 2010
How to password protect PHP/Wordpress with htpasswd.
First Create .htpasswd file.
htpasswd -c /opt/app/.htpasswd admin
New password:
Re-type new password:
After that you can add .htaccess in your application.
vi /opt/app/.htaccess
AuthUserFile /opt/app/.htpasswd
AuthGroupFile /dev/null
AuthName admin
AuthType Basic
require valid-user
# Enable only if you want authentication less access for some specific host.
Allow from 192.168.10.160
Satisfy Any
htpasswd -c /opt/app/.htpasswd admin
New password:
Re-type new password:
After that you can add .htaccess in your application.
vi /opt/app/.htaccess
AuthUserFile /opt/app/.htpasswd
AuthGroupFile /dev/null
AuthName admin
AuthType Basic
require valid-user
# Enable only if you want authentication less access for some specific host.
Allow from 192.168.10.160
Satisfy Any
Wednesday, June 30, 2010
Server Monitoring with ServerSTAT server.STATS (Clook Internet Ltd)
This is Popular and real time monitoring tool. mostly it used for webhosting server. It is alarming system too.
Server.STATS is develop by clook.net
and its very useful tool where you can add multiple servers and monitoring custom ports and server load.
Please check with this image. I have configure monitoring for some major services. e.g. Httpd-MySql-Ftp etc. you can add any ports and whatever you wants no limit. So when its stoped or some services down it showing you red signal immediately with sound alarm/alerts.
Also it gives you Server Load if its cross load 5.00 its become red and sound alarm. So no need to always check the page refresh, it send you sound alarm, if you attached spekers to your system.
Its free tool, which is in php code, if someone need i can provide you, help you for configuration.
Yo Guys, lets monitor your server with serverstat. :)
Server.STATS is develop by clook.net
and its very useful tool where you can add multiple servers and monitoring custom ports and server load.
Please check with this image. I have configure monitoring for some major services. e.g. Httpd-MySql-Ftp etc. you can add any ports and whatever you wants no limit. So when its stoped or some services down it showing you red signal immediately with sound alarm/alerts.
Also it gives you Server Load if its cross load 5.00 its become red and sound alarm. So no need to always check the page refresh, it send you sound alarm, if you attached spekers to your system.
Its free tool, which is in php code, if someone need i can provide you, help you for configuration.
Yo Guys, lets monitor your server with serverstat. :)
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
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.!
========================================================================
/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
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/
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.
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.;)
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.
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.
===========================================================================================
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"=>#
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.;)
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.!
-------------------------------------------------------------
#!/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
# 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
---------------------------------------------------------
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- ;)
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!
Subscribe to:
Posts (Atom)

