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
Thursday, August 20, 2009
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.
-----------------------------------------------------
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.
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';
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
`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
Tuesday, August 4, 2009
MySQL Backups using LVM snapshots
lvcreate -L40G -s -n dbbackup /dev/VolGroup00/LogVol03
lvm> lvremove /dev/VolGroup00/dbbackup
Do you really want to remove active logical volume "dbbackup"? [y/n]:
----------------------------------------------------------------------------
Stapes to Install and configure LVM.
fdisk -l
fdisk /dev/hdb
:p to print partition
:n to Extend partition
:e
Last cylender _______ enter
:n to new partition
Last cylender : +10G
Again create +10G partition
:n
choose: e
Last cylender :+10G
Command:l for list.
---------------------------
Command: t
partition number : 5
hexadecimal number: 8e
again create:
command: t
partition number: 6
hexadecimal number: 8e
command: w to save.
-------------------------
# partprobe
take hdb drive and make two partition if you want 1 is ok.
pvcreate /dev/hdb1 /dev/hdb2
vgcreate test1 /dev/hdb1
mkdir /mnt/Backup_disk/snap0 or
mkdir /snap0
lvcreate -L1000M -s -n /mnt/Backup_disk/snap0 /dev/test1/data
mount /dev/test1/data /mnt/Backup_disk/snap0
or
mount /dev/test1/snap0 /snap0 dependupmon path you can mount any where in disk just
mysql -uroot -p passwd > FLUSH TABLES WITH READ LOCK
create TAR
tar -cvf /mnt/Backup_disk/snap0/mysql`date +%Y%m%d%H`.tar /var/lib/mysql/
login to you mysql
and
mysql > UNLOCK TABLES;
cd /snap0
ls mysql2009080419.tar
tar -xvf mysql2009080419.tar
this is your hot backup.
Now you can umount LVM
root@localhost ~]# umount /mnt/Backup_disk/snap0
Check with command: lvdisplay
--- Logical volume ---
LV Name /dev/test1/snap0
VG Name test1
LV UUID ZCYdo5-RinV-EJ4L-03Tq-Snk1-i1Qt-pkQG1X
LV Write Access read/write
LV snapshot status active destination for /dev/test1/data
LV Status available
# open 0
LV Size 1.00 GB
Current LE 256
COW-table size 1000.00 MB
COW-table LE 250
Allocated to snapshot 0.01%
Snapshot chunk size 8.00 KB
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:3
[root@localhost ~]# lvremove /dev/test1/snap0
Do you really want to remove active logical volume "snap0"? [y/n]: y
Logical volume "snap0" successfully removed
Whenerver you want just crete LVM useing this command:
lvcreate -L1000M -s -n /mnt/Backup_disk/snap0 /dev/test1/data
and mount same process.
lvm> lvremove /dev/VolGroup00/dbbackup
Do you really want to remove active logical volume "dbbackup"? [y/n]:
----------------------------------------------------------------------------
Stapes to Install and configure LVM.
fdisk -l
fdisk /dev/hdb
:p to print partition
:n to Extend partition
:e
Last cylender _______ enter
:n to new partition
Last cylender : +10G
Again create +10G partition
:n
choose: e
Last cylender :+10G
Command:l for list.
---------------------------
Command: t
partition number : 5
hexadecimal number: 8e
again create:
command: t
partition number: 6
hexadecimal number: 8e
command: w to save.
-------------------------
# partprobe
take hdb drive and make two partition if you want 1 is ok.
pvcreate /dev/hdb1 /dev/hdb2
vgcreate test1 /dev/hdb1
mkdir /mnt/Backup_disk/snap0 or
mkdir /snap0
lvcreate -L1000M -s -n /mnt/Backup_disk/snap0 /dev/test1/data
mount /dev/test1/data /mnt/Backup_disk/snap0
or
mount /dev/test1/snap0 /snap0 dependupmon path you can mount any where in disk just
mysql -uroot -p passwd > FLUSH TABLES WITH READ LOCK
create TAR
tar -cvf /mnt/Backup_disk/snap0/mysql`date +%Y%m%d%H`.tar /var/lib/mysql/
login to you mysql
and
mysql > UNLOCK TABLES;
cd /snap0
ls mysql2009080419.tar
tar -xvf mysql2009080419.tar
this is your hot backup.
Now you can umount LVM
root@localhost ~]# umount /mnt/Backup_disk/snap0
Check with command: lvdisplay
--- Logical volume ---
LV Name /dev/test1/snap0
VG Name test1
LV UUID ZCYdo5-RinV-EJ4L-03Tq-Snk1-i1Qt-pkQG1X
LV Write Access read/write
LV snapshot status active destination for /dev/test1/data
LV Status available
# open 0
LV Size 1.00 GB
Current LE 256
COW-table size 1000.00 MB
COW-table LE 250
Allocated to snapshot 0.01%
Snapshot chunk size 8.00 KB
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:3
[root@localhost ~]# lvremove /dev/test1/snap0
Do you really want to remove active logical volume "snap0"? [y/n]: y
Logical volume "snap0" successfully removed
Whenerver you want just crete LVM useing this command:
lvcreate -L1000M -s -n /mnt/Backup_disk/snap0 /dev/test1/data
and mount same process.
Saturday, August 1, 2009
Ruby On Rails : "God Monitoring With backgroundrb".
vi config/backgroundrb.god
#--------------------------------------------------------------
#run on command line with 'god -c backgroundrb.god -D'
RAILS_ROOT = '/mnt/app/application/current'
#load required rails and backgroundrb files
require File.dirname(__FILE__) + '/boot'
require File.dirname(__FILE__) + '/environment'
require 'erb'
$LOAD_PATH << "#{RAILS_ROOT}/vendor/plugins/backgroundrb/lib"
require "#{RAILS_ROOT}/vendor/plugins/backgroundrb/lib/backgroundrb.rb"
#create custom condition for checking that QueryProcessingWorker is running
# MiddleMan = BackgrounDRb::ClusterConnection.new
module God
module Conditions
class Backgroundrb < PollCondition
def initialize; super; end
def valid?; true; end
def test
begin
queue_worker = MiddleMan.all_worker_info.values.flatten.select { |w| :queue_processing_worker == w[:worker] }
queue_worker.empty?
rescue #if all_worker_info raises exception, then bdrb isn't running and we were unable to connect
true
end
end
end
end
end
God::Contacts::Email.message_settings ={
:from => 'shrii@gmail.com'
}
God::Contacts::Email.server_settings = {
:address => "Ipaddress_of mail server",
:port => 25,
:domain => "Ipaddress_of mail server",
:user_name => "user",
:password => "passwd",
:authentication => :login
}
God.contact(:email) do |c|
c.name = 'Username'
c.email = 'shrikant@gmail.com'
end
God.watch do |w|
w.name = 'backgroundrb'
w.interval = 1.minute
w.restart = "cd #{RAILS_ROOT} && /usr/local/bin/ruby script/backgroundrb stop && /usr/local/bin/ruby script/backgroundrb -e production start"
w.stop = "cd #{RAILS_ROOT} && /usr/local/bin/ruby script/backgroundrb stop"
w.start = "cd #{RAILS_ROOT} && /usr/local/bin/ruby script/backgroundrb -e production start"
w.grace = 1.minute
w.pid_file = "#{RAILS_ROOT}/tmp/pids/backgroundrb_11006.pid"
w.start_if do |start|
start.condition(:process_running) do |c|
c.running = false
c.notify = "username"
end
end
w.restart_if do |restart|
restart.condition(:cpu_usage) do |c|
c.above = 70.percent
c.times = [3,5]
c.notify = "username"
end
end
end
#----------------------------------------------------------
* To Start God. in RAILS_ROOT
god -c config/backgroundrb.god
* To Check Prosess id of GOD:
ps -aufx| grep god
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ
root 11219 0.0 0.0 60260 732 ttyp1 S+ 07:48 0:00 \_ grep god
root 26944 0.2 0.3 163240 61476 ttyp0 S 07:14 0:05 /usr/local/bin/ruby /usr/local/bin/god -c config/backgroundrb.god
Thats It.. Please let me know if there is any issue.
#--------------------------------------------------------------
#run on command line with 'god -c backgroundrb.god -D'
RAILS_ROOT = '/mnt/app/application/current'
#load required rails and backgroundrb files
require File.dirname(__FILE__) + '/boot'
require File.dirname(__FILE__) + '/environment'
require 'erb'
$LOAD_PATH << "#{RAILS_ROOT}/vendor/plugins/backgroundrb/lib"
require "#{RAILS_ROOT}/vendor/plugins/backgroundrb/lib/backgroundrb.rb"
#create custom condition for checking that QueryProcessingWorker is running
# MiddleMan = BackgrounDRb::ClusterConnection.new
module God
module Conditions
class Backgroundrb < PollCondition
def initialize; super; end
def valid?; true; end
def test
begin
queue_worker = MiddleMan.all_worker_info.values.flatten.select { |w| :queue_processing_worker == w[:worker] }
queue_worker.empty?
rescue #if all_worker_info raises exception, then bdrb isn't running and we were unable to connect
true
end
end
end
end
end
God::Contacts::Email.message_settings ={
:from => 'shrii@gmail.com'
}
God::Contacts::Email.server_settings = {
:address => "Ipaddress_of mail server",
:port => 25,
:domain => "Ipaddress_of mail server",
:user_name => "user",
:password => "passwd",
:authentication => :login
}
God.contact(:email) do |c|
c.name = 'Username'
c.email = 'shrikant@gmail.com'
end
God.watch do |w|
w.name = 'backgroundrb'
w.interval = 1.minute
w.restart = "cd #{RAILS_ROOT} && /usr/local/bin/ruby script/backgroundrb stop && /usr/local/bin/ruby script/backgroundrb -e production start"
w.stop = "cd #{RAILS_ROOT} && /usr/local/bin/ruby script/backgroundrb stop"
w.start = "cd #{RAILS_ROOT} && /usr/local/bin/ruby script/backgroundrb -e production start"
w.grace = 1.minute
w.pid_file = "#{RAILS_ROOT}/tmp/pids/backgroundrb_11006.pid"
w.start_if do |start|
start.condition(:process_running) do |c|
c.running = false
c.notify = "username"
end
end
w.restart_if do |restart|
restart.condition(:cpu_usage) do |c|
c.above = 70.percent
c.times = [3,5]
c.notify = "username"
end
end
end
#----------------------------------------------------------
* To Start God. in RAILS_ROOT
god -c config/backgroundrb.god
* To Check Prosess id of GOD:
ps -aufx| grep god
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ
root 11219 0.0 0.0 60260 732 ttyp1 S+ 07:48 0:00 \_ grep god
root 26944 0.2 0.3 163240 61476 ttyp0 S 07:14 0:05 /usr/local/bin/ruby /usr/local/bin/god -c config/backgroundrb.god
Thats It.. Please let me know if there is any issue.
Subscribe to:
Posts (Atom)