<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1799089414943341229</id><updated>2011-04-21T15:06:44.184-07:00</updated><title type='text'>A r U n O n R a I L s . . !</title><subtitle type='html'>I am a Rails Developer having 4+ experience..

Let discuss more about Rails here..!!</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sanjayarun.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1799089414943341229/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://sanjayarun.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>A r U n oN R a I L s</name><uri>http://www.blogger.com/profile/11075052794334935094</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_KXqD7tyTVE8/SgPAm-Cj21I/AAAAAAAAADo/JAWajtqBUE0/S220/DSC00442.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1799089414943341229.post-3724246948694471140</id><published>2009-04-23T00:05:00.000-07:00</published><updated>2009-04-23T00:06:12.519-07:00</updated><title type='text'>High Availability-Installing DRBD and Hearbeat in Ubuntu</title><content type='html'>TS93-55 - 192.168.1.93     10.0.0.55&lt;br /&gt;TS94-56 - 192.168.1.94     10.0.0.56&lt;br /&gt;&lt;br /&gt;Virtual Ip - 192.168.1.95&lt;br /&gt;&lt;br /&gt;Each machine has 2 network cards: one for public and one for private traffic. The public interfaces connect to my main switch on the 192.168.1.X network. The private interfaces are connected via a crossover cable on the 10.0.0.X network.&lt;br /&gt;&lt;br /&gt;Once you have installed Ubuntu 8.04 Server, you need to install some build tools.&lt;br /&gt;&lt;br /&gt;apt-get install build-essential binutils cpp gcc autoconf automake1.9 libtool \&lt;br /&gt;autotools-dev g++ make flex&lt;br /&gt;&lt;br /&gt;In theory, that should get all of the development tools installed that you'll need.&lt;br /&gt;&lt;br /&gt;Next we need to get the entire kernel source code. Just the kernel headers won't cut it. We need to compile the kernel so that it builds some of the scripts needed to compile the DRBD driver. We'll also install the ncurses library so that menuconfig works.&lt;br /&gt;&lt;br /&gt;apt-get install libncurses5-dev linux-source-2.6.24&lt;br /&gt;&lt;br /&gt;Then extract the kernel source:&lt;br /&gt;&lt;br /&gt;cd /usr/src&lt;br /&gt;tar -xvf linux-source-2.6.24.tar.bz2&lt;br /&gt;cd /usr/src/linux-source-2.6.24&lt;br /&gt;&lt;br /&gt;Next, lets clean up any unneeded files (which there shouldn't be any the first time):&lt;br /&gt;&lt;br /&gt;make mrproper&lt;br /&gt;&lt;br /&gt;Before you can build the kernel, you need to copy your existing kernel build configuration into the kernel source directory:&lt;br /&gt;&lt;br /&gt;cp /boot/config-2.6.24-16-server /usr/src/linux-source-2.6.24/.config&lt;br /&gt;&lt;br /&gt;Now we run the menuconfig which will read in our kernel build configuration and build some version files. As soon as the GUI appears, just exit immediately. You don't have to change any of the settings.&lt;br /&gt;&lt;br /&gt;make menuconfig&lt;br /&gt;&lt;br /&gt;Finally we need to prepare the kernel and compile it. This will take quite some time.&lt;br /&gt;&lt;br /&gt;make prepare&lt;br /&gt;make&lt;br /&gt;&lt;br /&gt;Now that we have the kernel source compiled and ready to go, let's get the DRBD source.&lt;br /&gt;&lt;br /&gt;cd /root&lt;br /&gt;wget http://oss.linbit.com/drbd/8.2/drbd-8.2.5.tar.gz&lt;br /&gt;tar -xvf drbd-8.2.5.tar.gz&lt;br /&gt;cd /root/drbd-8.2.5&lt;br /&gt;&lt;br /&gt;We need to build the DRBD driver and specify the path to the kernel source, then install the driver in the /lib path:&lt;br /&gt;&lt;br /&gt;make KDIR=/usr/src/linux-source-2.6.24&lt;br /&gt;make install&lt;br /&gt;&lt;br /&gt;Once the driver is compiled, we need to move/copy it to the appropriate lib directory:&lt;br /&gt;&lt;br /&gt;mv /lib/modules/2.6.24.3/kernel/drivers/block/drbd.ko \&lt;br /&gt;    /lib/modules/2.6.24-16-server/kernel/drivers/block&lt;br /&gt;&lt;br /&gt;Next we need to start the driver and tell Linux to load it the next time it boots:&lt;br /&gt;&lt;br /&gt;modprobe drbd&lt;br /&gt;echo 'drbd' &gt;&gt; /etc/modules&lt;br /&gt;update-rc.d drbd defaults&lt;br /&gt;&lt;br /&gt;Now that everything is installed, verify the driver is loaded:&lt;br /&gt;&lt;br /&gt;lsmod | grep drbd&lt;br /&gt;&lt;br /&gt;It might be a good idea to reboot and make sure it loads.&lt;br /&gt;&lt;br /&gt;At this point, you should set up the /etc/drbd.conf, which mine looks like this:&lt;br /&gt;&lt;br /&gt;global {&lt;br /&gt;  usage-count no;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;common {&lt;br /&gt;  protocol C;&lt;br /&gt;&lt;br /&gt;  syncer {&lt;br /&gt;    rate 30M;&lt;br /&gt;    al-extents 1801;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  startup {&lt;br /&gt;    wfc-timeout  0;&lt;br /&gt;    degr-wfc-timeout 15;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  disk {&lt;br /&gt;&lt;br /&gt;    on-io-error   detach;&lt;br /&gt;    # fencing resource-and-stonith;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  net {&lt;br /&gt;    sndbuf-size 512k;&lt;br /&gt;    timeout        60;   #  6 seconds  (unit = 0.1 seconds)&lt;br /&gt;    connect-int    10;   # 10 seconds  (unit = 1 second)&lt;br /&gt;    ping-int       10;   # 10 seconds  (unit = 1 second)&lt;br /&gt;    ping-timeout   5;    # 500 ms (unit = 0.1 seconds)&lt;br /&gt;    max-buffers    8000;&lt;br /&gt;    max-epoch-size 8000;&lt;br /&gt;    cram-hmac-alg  "sha1";&lt;br /&gt;    shared-secret  "secret";&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;resource r0 {&lt;br /&gt;  on TS93-55 {&lt;br /&gt;    disk       /dev/mapper/ts-ts--ts1-1;&lt;br /&gt;    address    10.0.0.55:7788;&lt;br /&gt;    device     /dev/drbd0;&lt;br /&gt;    meta-disk  internal;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  on TS94-56 {&lt;br /&gt;    disk      /dev/mapper/ts-ts2-1;&lt;br /&gt;    address   10.0.0.56:7788;&lt;br /&gt;    device     /dev/drbd0;&lt;br /&gt;    meta-disk  internal;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;With the configuration set, you need to restart/reload DRBD, create the meta disk, and bring the drive up:&lt;br /&gt;&lt;br /&gt;/etc/init.d/drbd restart&lt;br /&gt;drbdadm create-md r0&lt;br /&gt;drbdadm up r0&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    * If any error like the following one occurs:&lt;br /&gt;&lt;br /&gt;TS93-55 # drbdadm create-md r0&lt;br /&gt;md_offset 1069215744&lt;br /&gt;al_offset 1069182976&lt;br /&gt;bm_offset 1069150208&lt;br /&gt;&lt;br /&gt;Found ext3 filesystem which uses 1044160 kB&lt;br /&gt;current configuration leaves usable 1044092 kB&lt;br /&gt;&lt;br /&gt;Device size would be truncated, which&lt;br /&gt;would corrupt data and result in&lt;br /&gt;'access beyond end of device' errors.&lt;br /&gt;You need to either&lt;br /&gt;* use external meta data (recommended)&lt;br /&gt;* shrink that filesystem first&lt;br /&gt;* zero out the device (destroy the filesystem)&lt;br /&gt;Operation refused.&lt;br /&gt;&lt;br /&gt;Command 'drbdmeta /dev/drbd0 v08 /dev/sdb5 internal create-md'&lt;br /&gt;terminated with exit code 40&lt;br /&gt;drbdadm aborting&lt;br /&gt;&lt;br /&gt;try&lt;br /&gt;&lt;br /&gt;dd if=/dev/zero of=/dev/sda5 bs=1M count=128&lt;br /&gt;&lt;br /&gt;* And then you can successfully create your resource on both machines:&lt;br /&gt;&lt;br /&gt;[paras1]# drbdadm create-md r0&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Wait the end of the synchronization.&lt;br /&gt;&lt;br /&gt;At this point you can view the DRBD status:&lt;br /&gt;&lt;br /&gt;TS93-55:~$ cat /proc/drbd&lt;br /&gt;version: 8.0.11 (api:86/proto:86)&lt;br /&gt;GIT-hash: b3fe2bdfd3b9f7c2f923186883eb9e2a0d3a5b1b build by phil@mescal, 2008-02-12&lt;br /&gt; 0: cs:Connected st:Primary/Secondary ds:UpToDate/UpToDate C r---&lt;br /&gt;    ns:221871972 nr:7160 dw:3856764 dr:227396211 al:763 bm:17504 lo:0 pe:0 ua:0 ap:0&lt;br /&gt;    resync: used:0/31 hits:13841287 misses:13628 starving:0 dirty:0 changed:13628&lt;br /&gt;    act_log: used:0/1801 hits:961638 misses:790 starving:0 dirty:27 changed:763&lt;br /&gt;&lt;br /&gt;chris@app1:~$ /etc/init.d/drbd status&lt;br /&gt;drbd driver loaded OK; device status:&lt;br /&gt;version: 8.0.11 (api:86/proto:86)&lt;br /&gt;GIT-hash: b3fe2bdfd3b9f7c2f923186883eb9e2a0d3a5b1b build by phil@mescal, 2008-02-12&lt;br /&gt;m:res  cs         st                 ds                 p  mounted    fstype&lt;br /&gt;0:r0   Connected  Primary/Secondary  UpToDate/UpToDate  C &lt;br /&gt;&lt;br /&gt;* Now it’s time to create your EXT3 filesystem on the DRBD device! (only in the case there was no existing data on /dev/sdb5)&lt;br /&gt;&lt;br /&gt;[TS93-55]# mke2fs -j /dev/drbd0&lt;br /&gt;&lt;br /&gt;You're now ready to mount /dev/drbd0 and put data on it. There's still other things you need to do if you plan on using Heartbeat for failover monitoring.&lt;br /&gt;&lt;br /&gt;Step1:&lt;br /&gt;&lt;br /&gt;sudo apt-get install heartbeat&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Step 2.&lt;br /&gt;Now we’re going to configure the /etc/ha.d/ha.cf file for our machine. Here is what I’ve put into the /etc/ha.d/ha.cf file ON EACH MACHINE:&lt;br /&gt;&lt;br /&gt;vim /etc/ha.d/ha.cf&lt;br /&gt;&lt;br /&gt;logfile /var/log/ha-log&lt;br /&gt;logfacility local0&lt;br /&gt;keepalive 2&lt;br /&gt;deadtime 30&lt;br /&gt;initdead 120&lt;br /&gt;bcast eth0&lt;br /&gt;udpport 694&lt;br /&gt;auto_failback on&lt;br /&gt;node TS93-55&lt;br /&gt;node TS94-56&lt;br /&gt;&lt;br /&gt;Step 3.&lt;br /&gt;Now configure the /etc/ha.d/authkeys file ON EACH MACHINE for what kind of security and file checking you want, I don’t care about security in this example so I put this is the file since it’s the fastest:&lt;br /&gt;auth 2&lt;br /&gt;2 crc&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Step 4:&lt;br /&gt;&lt;br /&gt;vim /etc/ha.d/hareresource&lt;br /&gt;&lt;br /&gt;TS93-55 drbddisk::r0 Filesystem::/dev/drbd0::/pgsql/data::ext3 192.168.1.95 postgresql-8.2 apache2&lt;br /&gt;&lt;br /&gt;Step 5.&lt;br /&gt;Make sure heartbeat and the service(s) you’re watching DO NOT start at boot, otherwise things get really ugly if when you screw up:&lt;br /&gt;chkconfig heartbeat off&lt;br /&gt;chkconfig httpd off&lt;br /&gt;/etc/init.d/httpd stop&lt;br /&gt;(on both machines)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Step 6.&lt;br /&gt;Alright, it’s finally time to test your failover configuration. First, we need to start heartbeat on the primary machine:&lt;br /&gt;TS93-55# /etc/init.d/heartbeat start&lt;br /&gt;Then, start it on the secondary machine&lt;br /&gt;TS94-56# /etc/init.d/heartbeat start&lt;br /&gt;&lt;br /&gt;You should now be able to ping the cluster IP (192.168.1.95). You can also check that the /dev/drbd0 filesystem is mounted on the primary node using df. Check the /var/log/messages file on either machine for debugging information&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;For more informations follow the links below&lt;br /&gt;http://gcharriere.com/blog/?p=1&lt;br /&gt;&lt;br /&gt;http://www.cb1inc.com/2008/05/18/installing-drbd-8.2.5-on-ubuntu-8.04-hardy-heron&lt;br /&gt;&lt;br /&gt;http://writequit.org/blog/?cat=61&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1799089414943341229-3724246948694471140?l=sanjayarun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sanjayarun.blogspot.com/feeds/3724246948694471140/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1799089414943341229&amp;postID=3724246948694471140' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1799089414943341229/posts/default/3724246948694471140'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1799089414943341229/posts/default/3724246948694471140'/><link rel='alternate' type='text/html' href='http://sanjayarun.blogspot.com/2009/04/high-availability-installing-drbd-and.html' title='High Availability-Installing DRBD and Hearbeat in Ubuntu'/><author><name>A r U n oN R a I L s</name><uri>http://www.blogger.com/profile/11075052794334935094</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_KXqD7tyTVE8/SgPAm-Cj21I/AAAAAAAAADo/JAWajtqBUE0/S220/DSC00442.JPG'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1799089414943341229.post-7849435318634565331</id><published>2008-12-04T09:57:00.000-08:00</published><updated>2008-12-04T10:18:31.169-08:00</updated><title type='text'>Import data from CSV or Excel in to database</title><content type='html'>Simple Way To Import CSV/Excel data.&lt;br /&gt;&lt;br /&gt;If u have excel file then save it as CSV file.&lt;br /&gt;Consider a table foo and it has two columns (name,status)&lt;br /&gt;Put ur CSV file in config folder&lt;br /&gt;Create a migration file.. Put the below code in ur self.up method&lt;br /&gt;&lt;br /&gt; def self.up&lt;br /&gt;    filename = "#{RAILS_ROOT}/config/Datafile.csv"&lt;br /&gt;    file=File.new(filename,"r")&lt;br /&gt;    while (line = file.gets)&lt;br /&gt;    c = Foo.new&lt;br /&gt;    columns = line.split(",")&lt;br /&gt;    c.name=columns[1]&lt;br /&gt;    c.status=columns[2]&lt;br /&gt;    c.save&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;Run the migration using rake command 'rake db:migrate --trace'&lt;br /&gt;and thats it..!! You Got Ur Table Loaded With Data u Need..!!&lt;br /&gt;&lt;br /&gt;Cheers..!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1799089414943341229-7849435318634565331?l=sanjayarun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sanjayarun.blogspot.com/feeds/7849435318634565331/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1799089414943341229&amp;postID=7849435318634565331' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1799089414943341229/posts/default/7849435318634565331'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1799089414943341229/posts/default/7849435318634565331'/><link rel='alternate' type='text/html' href='http://sanjayarun.blogspot.com/2008/12/import-data-from-csv-or-excel-in-to.html' title='Import data from CSV or Excel in to database'/><author><name>A r U n oN R a I L s</name><uri>http://www.blogger.com/profile/11075052794334935094</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_KXqD7tyTVE8/SgPAm-Cj21I/AAAAAAAAADo/JAWajtqBUE0/S220/DSC00442.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1799089414943341229.post-8971411245088927268</id><published>2008-12-03T02:34:00.000-08:00</published><updated>2008-12-04T09:50:59.876-08:00</updated><title type='text'>How to Improve Performace in Rails Application</title><content type='html'>1.Do not use dynamic finders like find_by_name.. find_by_columnname..&lt;br /&gt;This will internally call a method named 'method_missing' in activerecord then it will construct a query and execute it.&lt;br /&gt;&lt;br /&gt;2.Do not use rails helpers like link_to&lt;br /&gt;&lt;br /&gt;3.Avoid associations&lt;br /&gt;&lt;br /&gt;4.Avoid too many before_filters&lt;br /&gt;&lt;br /&gt;5.While writing query for eg. Model.find(:all)&lt;br /&gt;try to use select in this so that u limit only the required rows from the database&lt;br /&gt;&lt;br /&gt;6.Move your javascript and css to the bottom of ur page..&lt;br /&gt;&lt;%=javascript_include_tag "prototype"%&gt;&lt;br /&gt;&lt;br /&gt;7.If u r using n-1 relation then it can be optimized thru piggy back technique http://railsexpress.de/blog/articles/2005/11/06/the-case-for-piggy-backed-attributes&lt;br /&gt;&lt;br /&gt;8.Also do indexing in your database.&lt;br /&gt;&lt;br /&gt;What is Indexing and why Indexing?&lt;br /&gt;In a database, you have a few different kinds of objects. You’ve got tables, which are just big containers in which you put your data. The data is not sorted, so if you want to find something in a table, you need to look through everything until you find what you want.&lt;br /&gt;&lt;br /&gt;You also have indexes. An index is a sorted list of rows in a table. It contains a small subset of the table’s data, just enough to sort the data and point to the real data rows in the real table. So, when you want to find something in a table, you look at a suitable index, not the table. The index will point to the rows of the table that match what you are looking for.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;9.Monitor ur rails app  performance using tools like RPM,Production Log Analyzer (http://rails-analyzer.rubyforge.org/pl_analyze/),clientperf(http://austinentrepreneur.wordpress.com/2008/06/21/announcing-clientperf-simple-client-side-rails-performance/)&lt;br /&gt;&lt;br /&gt;10.Also check for any memory leak in ur application since ruby is prone to it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1799089414943341229-8971411245088927268?l=sanjayarun.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sanjayarun.blogspot.com/feeds/8971411245088927268/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1799089414943341229&amp;postID=8971411245088927268' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1799089414943341229/posts/default/8971411245088927268'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1799089414943341229/posts/default/8971411245088927268'/><link rel='alternate' type='text/html' href='http://sanjayarun.blogspot.com/2008/12/how-to-improve-performace-in-rails.html' title='How to Improve Performace in Rails Application'/><author><name>A r U n oN R a I L s</name><uri>http://www.blogger.com/profile/11075052794334935094</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://4.bp.blogspot.com/_KXqD7tyTVE8/SgPAm-Cj21I/AAAAAAAAADo/JAWajtqBUE0/S220/DSC00442.JPG'/></author><thr:total>3</thr:total></entry></feed>
