Hi,
Sorry for not updating blog such a long time. May be I was just too lazy to do it. But I will try to not to be so lazy from nowon ;)
Lucene is a framework which allows you to store some data that cab be indexed so that fast search operations can be performed on it. This data can actually from from any source like file system, Database, http etc.
Data is stored in a "Document" form within by Lucene. Its is programmer's responsibility to get the data and create documents. Lucene takes responsibility to index it and make them searchable.
Was reading on some articles to confirm the Lucene implementation in my Grails app is proper or not. Came across following few very good links for starters.
http://www.ibm.com/developerworks/web/library/wa-lucene2/?S_TACT=105AGX52&S_CMP=cn-a-web
http://www.darksleep.com/lucene/
http://www.javaranch.com/journal/2004/04/Lucene.html
Thursday, July 15, 2010
Thursday, November 12, 2009
MySQL Server Replication (5.0.84)
Hi all,
Today I tried setting-up MySQL server replication for 5.0.84. Must say its kind of really easy to setup a simple replication between 2 MySQL server instances. Putting down some key points to be followed.
Note: Make sure that no processes are updating master server while we perform underlying operations.
Steps provided in this blog are applicable to both 32 bit and 64 bit version of MySQL.
Goal:
Setup a replication of a Database "nba_hiber_test" on Master server on other Slave Server with same DB name over there.
Pre-Requisties:
If you are making Master slave for a fresh DB, where there is nothing on the Master, just create DBs on both Master and Slave DB and directly go to Step 3.
#1. Take Backup Dump of Master DB :
If Source (Master) database is already there on some DB which is still going to act as Master server in replication environment, please export Master database using command at shell prompt as below:
mysqldump --add-drop-table -h 192.168.100.124 -u zuber -p nba_hiber_test | bzip2 -c > nba_hiber_test12Nov09_with_data.sql.bz2
Here 192.168.100.124 was the machine on which my existing Master database is located, and that DB's name is "nba_hiber_test". This will create a compressed bzip2 file of SQL file and store it at the present working directory.
#2. Import DB on the slave DB:
Transfer "nba_hiber_test12Nov09_with_data.sql.bz2" to the slave machine.
We need to put the exact copy of the Master database on the slave server before we can enable replication. To do that, import the database on the slave machine from "nba_hiber_test12Nov09_with_data.sql.bz2"
a. Decompress "nba_hiber_test12Nov09_with_data.sql.bz2" :
bzip2 -d nba_hiber_test12Nov09_with_data.sql.bz2
b. Login to the MySQL on slave box and Create DB with same name as on the Master server (here "nba_hiber_test"):
create database nba_hiber_test;
c. Assuming you started MySQL client from at the same location where u ran command 2.a, run that SQL fil against "nba_hiber_test" on slave box:
# start using target slave DB
use nba_hiber_test;
# Run SQLs in "nba_hiber_test12Nov09_with_data.sql"
source nba_hiber_test12Nov09_with_data.sql;
This import may take time depending upon the size of the database and the hardware on which you are running MySQL. Use that time to go thru this whole document rather than waiting and looking curiously on the black screen ;)
#3. What we did? :
At this point, we have identical copy of Master and Slave dbs on bothe machines.
#4. Configure Master server to generate bin logs that can be used pass replication info:
This will be needed only if you are starting using this server as Master in a replication environment fpr the first time
To confirm if server is acting as Master or not fir "SHOW MASTER STATUS;" command on mysql prompt. If no records returns, means you have to configure it for master.
Add following lines inside [mysqld] of "my.cnf" file.
# folder path whre mysql will store its log-bin files
log-bin=/var/lib/mysqllogs/bin-log
# databases for which the replication info (log-bins) to be generated
replicate-do-db=nba_dev
#Change server id to some unique number in the range of 0 to 2^32 - 1
server-id = 1
Most of the time "my.cnf" is located in "/etc" folder. You will need root access to change the file and restart the server.
#5. Restart Master DB:
/etc/init.d/mysqld restart
#6. Confirm that bin logs are getting created:
Login to Master DB and fire:
SHOW MASTER STATUS;
Assume its running fine if you see something like:
mysql> show master status;
+---------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+---------------------+----------+--------------+------------------+
| bin-log.000001 | 98 | | |
+---------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
#7. Find out the log position on which Master server points to right now :
KEEP A NOTE OF THIS HADY to provide it to slave later:
SHOW MASTER STATUS
#8. Create replication user on the Master server to be used by slves to connect to do replication:
CREATE USER 'repl'@'%' IDENTIFIED BY 'passwd';
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%';
#9. Configure Slave server to give details of what all databases on this server are to be popullated with replication.
Add following lines inside [mysqld] of "my.cnf" file.
skip-slave
#Change server id to some unique number in the range of 0 to 2^32 - 1
server-id = 2
#10. Restart Slave DB:
/etc/init.d/mysqld restart
#11. Stop any existing Slave threads on Slave Server:
STOP SLAVE
#12. Setup the Master info on Slave DB:
Note that we pass same values of "file" and "Position" in this command as found on step 7.
CHANGE MASTER TO
MASTER_HOST = '192.168.100.124',
MASTER_USER = 'repl',
MASTER_PASSWORD = 'passwd',
MASTER_LOG_FILE = 'bin-log.000001',
MASTER_LOG_POS = 98;
#13. Chkeck the Slave thread status to see if is able to connect to the Master DB or not:
SHOW SLAVE STATUS \G
This commend should give you something like this as result:
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.100.124
Master_User: repl
Master_Port: 3306
Connect_Retry: 10
Master_Log_File: bin-log.000003
Read_Master_Log_Pos: 41435
Relay_Log_File: mysqld-relay-bin.000006
Relay_Log_Pos: 41570
Relay_Master_Log_File: bin-log.000003
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: nba_hiber_test
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: 41435
Relay_Log_Space: 41570
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
1 row in set (0.00 sec)
#14. Test:
Now try creating some records in the Master table, and check its getting reflected in the Slave server in some interval.
Wish you Happy Replication
Today I tried setting-up MySQL server replication for 5.0.84. Must say its kind of really easy to setup a simple replication between 2 MySQL server instances. Putting down some key points to be followed.
Note: Make sure that no processes are updating master server while we perform underlying operations.
Steps provided in this blog are applicable to both 32 bit and 64 bit version of MySQL.
Goal:
Setup a replication of a Database "nba_hiber_test" on Master server on other Slave Server with same DB name over there.
Pre-Requisties:
If you are making Master slave for a fresh DB, where there is nothing on the Master, just create DBs on both Master and Slave DB and directly go to Step 3.
#1. Take Backup Dump of Master DB :
If Source (Master) database is already there on some DB which is still going to act as Master server in replication environment, please export Master database using command at shell prompt as below:
mysqldump --add-drop-table -h 192.168.100.124 -u zuber -p nba_hiber_test | bzip2 -c > nba_hiber_test12Nov09_with_data.sql.bz2
Here 192.168.100.124 was the machine on which my existing Master database is located, and that DB's name is "nba_hiber_test". This will create a compressed bzip2 file of SQL file and store it at the present working directory.
#2. Import DB on the slave DB:
Transfer "nba_hiber_test12Nov09_with_data.sql.bz2" to the slave machine.
We need to put the exact copy of the Master database on the slave server before we can enable replication. To do that, import the database on the slave machine from "nba_hiber_test12Nov09_with_data.sql.bz2"
a. Decompress "nba_hiber_test12Nov09_with_data.sql.bz2" :
bzip2 -d nba_hiber_test12Nov09_with_data.sql.bz2
b. Login to the MySQL on slave box and Create DB with same name as on the Master server (here "nba_hiber_test"):
create database nba_hiber_test;
c. Assuming you started MySQL client from at the same location where u ran command 2.a, run that SQL fil against "nba_hiber_test" on slave box:
# start using target slave DB
use nba_hiber_test;
# Run SQLs in "nba_hiber_test12Nov09_with_data.sql"
source nba_hiber_test12Nov09_with_data.sql;
This import may take time depending upon the size of the database and the hardware on which you are running MySQL. Use that time to go thru this whole document rather than waiting and looking curiously on the black screen ;)
#3. What we did? :
At this point, we have identical copy of Master and Slave dbs on bothe machines.
#4. Configure Master server to generate bin logs that can be used pass replication info:
This will be needed only if you are starting using this server as Master in a replication environment fpr the first time
To confirm if server is acting as Master or not fir "SHOW MASTER STATUS;" command on mysql prompt. If no records returns, means you have to configure it for master.
Add following lines inside [mysqld] of "my.cnf" file.
# folder path whre mysql will store its log-bin files
log-bin=/var/lib/mysqllogs/bin-log
# databases for which the replication info (log-bins) to be generated
replicate-do-db=nba_dev
#Change server id to some unique number in the range of 0 to 2^32 - 1
server-id = 1
Most of the time "my.cnf" is located in "/etc" folder. You will need root access to change the file and restart the server.
#5. Restart Master DB:
/etc/init.d/mysqld restart
#6. Confirm that bin logs are getting created:
Login to Master DB and fire:
SHOW MASTER STATUS;
Assume its running fine if you see something like:
mysql> show master status;
+---------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+---------------------+----------+--------------+------------------+
| bin-log.000001 | 98 | | |
+---------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
#7. Find out the log position on which Master server points to right now :
KEEP A NOTE OF THIS HADY to provide it to slave later:
SHOW MASTER STATUS
#8. Create replication user on the Master server to be used by slves to connect to do replication:
CREATE USER 'repl'@'%' IDENTIFIED BY 'passwd';
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%';
#9. Configure Slave server to give details of what all databases on this server are to be popullated with replication.
Add following lines inside [mysqld] of "my.cnf" file.
skip-slave
#Change server id to some unique number in the range of 0 to 2^32 - 1
server-id = 2
#10. Restart Slave DB:
/etc/init.d/mysqld restart
#11. Stop any existing Slave threads on Slave Server:
STOP SLAVE
#12. Setup the Master info on Slave DB:
Note that we pass same values of "file" and "Position" in this command as found on step 7.
CHANGE MASTER TO
MASTER_HOST = '192.168.100.124',
MASTER_USER = 'repl',
MASTER_PASSWORD = 'passwd',
MASTER_LOG_FILE = 'bin-log.000001',
MASTER_LOG_POS = 98;
#13. Chkeck the Slave thread status to see if is able to connect to the Master DB or not:
SHOW SLAVE STATUS \G
This commend should give you something like this as result:
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.100.124
Master_User: repl
Master_Port: 3306
Connect_Retry: 10
Master_Log_File: bin-log.000003
Read_Master_Log_Pos: 41435
Relay_Log_File: mysqld-relay-bin.000006
Relay_Log_Pos: 41570
Relay_Master_Log_File: bin-log.000003
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: nba_hiber_test
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: 41435
Relay_Log_Space: 41570
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
1 row in set (0.00 sec)
#14. Test:
Now try creating some records in the Master table, and check its getting reflected in the Slave server in some interval.
Wish you Happy Replication
Sunday, September 27, 2009
Sunday, September 13, 2009
Hibernate: Easy to JUST Use...But HARD to use in Right way
Hi,
Recently started working on migration of one of our application to port on Hibernate. To be frank, I dont know much of hibernate. At the same time, from bottom of heart, am not all that big fan of Hibernate as well !!
But yes, taking this as an opportunity to learn hibernate and looking for some concrete reasons to LOVE or HATE it :p
So started looking around for some good online articles to get booted up. At first glance simple ORM looked so straight forward that I felt like in heaven to be a developer using Hibernate. But soon, realized a devil a residing in the heaven. That is why the title of the post is "Hibernate: Easy to JUST Use...But HARD to use in Right way" !!
Yes, this is what I have felt so far, I may change my opinion later :p
One of the main reason why I felt so is the way we use "OneToMany" association with "inverse" attribute and "cascade" attribute.
I definitely want to thank all smart poeple who put their articles to help newbie like me to understand Hibernate. Giving some links below in the order of my likings towards the explanation :
http://www.neeraj.name/blog/ articles/43-hibernate- association-behind-the-scene- action
http://simoes.org/docs/ hibernate-2.1/155.html
http://www.devx.com/dbzone/ Article/29685
http://www.javalobby.org/java/ forums/t48846.html
http://www.jeevanchaaya.com/ 2008/10/17/improving- performance-in-hibernate/
http://java.dzone.com/ articles/hibernate- performance-tuning
http://bigapplezlp.wordpress. com/2008/05/07/hibernate- performance-tuning/
http://acupof.blogspot.com/ 2008/01/background-hibernate- comes-with-three.html
http://hibernatebp.blogspot. com/
http://jroller.com/jcarreira/ date/20050223#hibernate_tips
http://www.javabeat.net/ articles/37-introduction-to- hibernate-caching-1.html
Recently started working on migration of one of our application to port on Hibernate. To be frank, I dont know much of hibernate. At the same time, from bottom of heart, am not all that big fan of Hibernate as well !!
But yes, taking this as an opportunity to learn hibernate and looking for some concrete reasons to LOVE or HATE it :p
So started looking around for some good online articles to get booted up. At first glance simple ORM looked so straight forward that I felt like in heaven to be a developer using Hibernate. But soon, realized a devil a residing in the heaven. That is why the title of the post is "Hibernate: Easy to JUST Use...But HARD to use in Right way" !!
Yes, this is what I have felt so far, I may change my opinion later :p
One of the main reason why I felt so is the way we use "OneToMany" association with "inverse" attribute and "cascade" attribute.
I definitely want to thank all smart poeple who put their articles to help newbie like me to understand Hibernate. Giving some links below in the order of my likings towards the explanation :
http://www.neeraj.name/blog/
http://simoes.org/docs/
http://www.devx.com/dbzone/
http://www.jeevanchaaya.com/
http://java.dzone.com/
http://bigapplezlp.wordpress.
http://acupof.blogspot.com/
http://jroller.com/jcarreira/
http://www.javabeat.net/
Tuesday, August 25, 2009
Friday, August 14, 2009
Independence "In-Deep-Essence" to me
62 Years of so-called "Independence" !!
Yes, this is what I feel when I see people feeling happy that they got their nation from Britishers, who looted us just like mankind loots honeybees.
But are we able to digest this Independence??
I always ask this Question to me.....What this Independence really means to me ??
> Does it just mean to throw Ruling Britishers out of the country and let our own corrupted people to loot us?
> Does it mean to break our own country, friendship and create India , Pakistan, Bangladesh, Kashmir, POK ?
> Does it mean to break Indians into caste (SC / ST / NT / OBC ), religion, and state ?
> Does it mean to remember and give respect to flag, national anthem for a day and then throw in dustbin on next day?
If answer is yes, then I am sorry to say, but I would have been happy to see Britishers only to rule me and my nation !! Yes, because in that case atleast we, all Indians would have been together forgetting caste, religion and states. We (Post Independence) as a generation got Independence for free, may be that is why we dont value it.
We say that we are one of biggest democracy in place. But what is use of such democracy where we are only in power just during election time. We elect our representative. Then for next five years they will suck us with all their power. Nothing happens as common man wants. Still we call it democracy.
I thought Independent country has aware civilians. And civilians are as aware as media over there is. But thankfully our media is too busy capturing child in hole, sexy actresses in movies, thug baba's bahvishyawanis and cricketer's favorite food.
We can't even blame politicians only for all this. We as individuals, care for personal benifit more than that of country and more broadly for every living being.
> Why we want to diffenetiate poeple based on caste during any procedure?
> Why we want reservation?
> Why we want to break indians based on their native state?
Politicians shows us dreams, breaks it everyrime, and we still support them everytime.
To me, we have just got Independence from one perspective. There are still having challanges from many enemies of ours whom we are still slaves to !!! These are bigger than and much powerful than what britishers were. To my small mind, following are those, but there might be many others....
1. Corruption
2. Racism
3. High valie of Money infront of value of any living being's life
4. Selfish outlook / politics
Dont forget, "Together we stand, alone we fall". To f*ck all above enemies, we have to come together. We have to play our role. We may differ in our way of fighting, but our goal will be same and noble. Are you fighting for your self ? For your family ? For your country ? For every one who breaths ?
Yes, this is what I feel when I see people feeling happy that they got their nation from Britishers, who looted us just like mankind loots honeybees.
But are we able to digest this Independence??
I always ask this Question to me.....What this Independence really means to me ??
> Does it just mean to throw Ruling Britishers out of the country and let our own corrupted people to loot us?
> Does it mean to break our own country, friendship and create India , Pakistan, Bangladesh, Kashmir, POK ?
> Does it mean to break Indians into caste (SC / ST / NT / OBC ), religion, and state ?
> Does it mean to remember and give respect to flag, national anthem for a day and then throw in dustbin on next day?
If answer is yes, then I am sorry to say, but I would have been happy to see Britishers only to rule me and my nation !! Yes, because in that case atleast we, all Indians would have been together forgetting caste, religion and states. We (Post Independence) as a generation got Independence for free, may be that is why we dont value it.
We say that we are one of biggest democracy in place. But what is use of such democracy where we are only in power just during election time. We elect our representative. Then for next five years they will suck us with all their power. Nothing happens as common man wants. Still we call it democracy.
I thought Independent country has aware civilians. And civilians are as aware as media over there is. But thankfully our media is too busy capturing child in hole, sexy actresses in movies, thug baba's bahvishyawanis and cricketer's favorite food.
We can't even blame politicians only for all this. We as individuals, care for personal benifit more than that of country and more broadly for every living being.
> Why we want to diffenetiate poeple based on caste during any procedure?
> Why we want reservation?
> Why we want to break indians based on their native state?
Politicians shows us dreams, breaks it everyrime, and we still support them everytime.
To me, we have just got Independence from one perspective. There are still having challanges from many enemies of ours whom we are still slaves to !!! These are bigger than and much powerful than what britishers were. To my small mind, following are those, but there might be many others....
1. Corruption
2. Racism
3. High valie of Money infront of value of any living being's life
4. Selfish outlook / politics
Dont forget, "Together we stand, alone we fall". To f*ck all above enemies, we have to come together. We have to play our role. We may differ in our way of fighting, but our goal will be same and noble. Are you fighting for your self ? For your family ? For your country ? For every one who breaths ?
Subscribe to:
Posts (Atom)