Archive for November, 2009

How to set up Mysql Master-Slave Replication

Replication consists of following 3 parts….

  • The master records changes to its data in its binary log (Binary Log Events).
  • The slave copies the master’s binary log events to its relay log.
  • The slave replays the events in the relay log, applying the changes to its own
    data using Slave Thread.

The basic steps to set up replication are…

  • Set up replication accounts on master server.
  • Configure the master and slave.
  • Instruct the slave to connect to and replicate from the master.

Here are few assumptions….

Master IP Address: 192.168.1.215
Slave IP Address:
  192.168.1.203
Replication User:
replication
User Password: slave

The I/O Slave Thread (it runs on Slave Server) makes a TCP/IP connection to the master. Thats why we need to create an user account on Master Server with proper privileges.

Now run the following query on Master to create a Slave account….
mysql>  GRANT REPLICATION SLAVE ON *.* TO ‘replication‘@’192.168.1.203′ IDENTIFIED BY ’slave’;

Now edit my.cnf file on Master accordingly.

[mysqld]
server-id                       = 1
log-bin                          = mysql-bin
log-bin-index                = mysql-log-bin.index
relay-log                       = mysql-relay-bin
relay-log-index             = mysql-relay-bin.index
expire_logs_days         = 10
max_binlog_size          = 100M
binlog_do_db               = [Database Name to be Replicated]
binlog_ignore_db         = [Database Name not to be Replicated]
#binlog_ignore_db       = [Database Name not to be Replicated] (for more than one data base which is not supposed to be replicated)
datadir                          = /var/lib/mysql
tmpdir                           = /tmp

Now restart Master mysql server and run the following query…

mysql>  SHOW MASTER STATUS;

screenshot-1.png

Now edit my.cnf file on Slave accordingly…..

[mysqld]

server_id                = 2
master_host            = 192.168.1.215
master_user            = replication
master_password   = slave
master_port            = 3306
relay_log                = mysql-relay-bin
relay-log-index       = mysql-relay-bin.index

We can set the value for master_host, master_user and master_password using mysql query. So it is better to avoid setting those values  directly from configuration file.

If master is having data already, insert the data from master server to slave server database or each of the databases.
Copy master database back up inside slave server and run  the following command on slave….

mysql -u[username] -p[password] [database name] < directory_path/[database.sql]

Now Restart Mysql Slave server and  run following query to synchronize master and slave….

mysql> CHANGE MASTER TO MASTER_HOST=’192.168.1.215′, MASTER_USER=’replication’, MASTER_PASSWORD=’slave’, MASTER_LOG_FILE=’mysql-bin.000004′, MASTER_LOG_POS=570;

Note: MASTER_LOG_FILE and MASTER_LOG_POS values have been taken from the result of SHOW MASTER STATUS

If a Slave is already running on your Slave Server,  Mysql Server will throw a error like…
ERROR 1198 (HY000): This operation cannot be performed with a running slave; run STOP SLAVE first

So run..
mysql> STOP SLAVE;
And  run the query for CHANGING MASTER again.

If it shows an error like..
ERROR 1201 (HY000): Could not initialize master info structure; more error messages can be found in the MySQL error log

Run
mysql> RESET SLAVE;

And  run the query for CHANGING MASTER again.

Finally start slave on slave server using..

mysql> START SLAVE;
mysql> SHOW SLAVE STATUS\G

screenshot.png

Congrats! Mysql Master-Slave Replication has been set up :)

Also we will be able to see the Replication Threads in the process list on both the Master and the Slave.

So simply run…

mysql> SHOW PROCESSLIST.


Random differences between CodeIgniter and symfony

1) CodeIgniter is sleek, easy to learn compared to symfony.

2) CodeIgniter project set up time is very less compared to symfony.

3) CodeIgniter works well for something quick and small, symfony hits when it comes for complicated projects.

4) As CodeIgniter does not accept arguments via the command line, you can not call a specific controller or function, a work around should be adopted but it’s not the case with symfony as it provides a concept called task.

5) CodeIgniter does not have any code generators like symfony which completely rocks symfony.

6) Working with fixtures makes life easier in symfony during development phasem, this is missing in codeIgniter again a run  around should be done.

7) Symfony allows to view the queries fired through development environment but codeIgniter has no such option.

1 Comment more...

Team Outing at The Rappa!


Last weekend we went to The Rappa -An Island Eco Resort located 210 kms away from Bangalore near Hassan. We left Bangalore on the 31st of October at 7.15am, families were also invited. The bus took the NICE Road till Magadi and we stopped at Kunigal for Breakfast. We played Dumb Charades, Cards, Housie and Antakshari during the journey. We were only few kms away from Rappa when we had to stop our bus as the road ahead was blocked due to temple inauguration in the village. We were invited to join in the festivities as it would take 2 hours to clear the road ……so we decided to do the 30 minutes walk in the afternoon sun accompanied by the cool breeze from the river to reach Rappa. We were welcomed by 3 lovely dogs -Shunti(Pomeranian), Brownie(Golden Retriever) , Shadow(Basset Hound) and another surprise awaiting us was Jack, a mighty horse which was brought to Rappa a month ago. We were so excited to check out our accommodations which were Machans, Tree houses and Swiss Tents spread beside the river. After the walk, we had all worked out a good appetite and so we enjoyed the lunch.

Nobody wanted to rest so we started with the games. We had four teams for each game which were divided earlier and each team came up with team names like Jinis, Shakalaka boom boom , Rainbow, TechJini Warriors, Parasites and Halloween. Yes, Amal we haven’t sensored ‘Shakalaka boom boom’ from being mentioned in this blog :)

We started with Lagori which was good fun and The Rainbow team won the game….. of course there were lot of fights which added to the fun. It was not tiring enough for few so we decided to play Cricket followed by Foot ball. I guess too much work and no play gave everyone too much energy :) we didn’t even want to take the tea break. The Sun was setting by then and we were surrounded by good music, chill breeze and everybody settled down on the sand around the campfire under the dark sky, full moon and stars shining bright (which we hardly get to see here due to city light). After soaking into the lovely atmosphere everybody started dancing and singing along with the music. We had hot hot bajjis and chicken kebab served during the campfire. The dancing did not stop till the fire went off and we had dinner around 12. People at Rappa had planned a Night trek for us. We drove 20 kms from Rappa to reach the point where we had to begin the climb to the top of the hill. We started the climb accompanied by the Shunti, Shadow and Brown with the help of Moon Light. There is a temple on top which is opened once a week to worship God. The view from atop was spectacular (Should be clear and better in day light) . We could see other range of hills, forest and Tipu’s Fort below. It was quiet, dark and very cold on top. We sat there, enjoyed the view and listened to the stories of Tipu Sultan and his secret underground path told to us by our Trek Guide(Nagesh). And yes how can I forgot Rohit and Santosh have lost their 4 hours of memory due to too much mixing of water and juice :)

We came back to Rappa at 4am to catch up on some sleep and were up by 6.30 to do Kayaking. The river is wide and long as it is a place were two rivers meet and there is an island in the middle of the river. Most of us went rowing till the island and some went swimming in the deep waters.

We had a good breakfast of bread, jam, butter, omelet , poori, saagu, orange juice,tea and coffee. We went by the river side to play team building games to encourage bonding among each other. Each team had 6 members in this game and one person was blindfolded. The blindfolded person would lead the line and rest stand behind to pass on the instructions given from the last person. The twist in the game was that no member was allowed to speak. Instructions were to be passed on only through actions. There was a start line and finish line and on the way three objects were placed. The blindfolded person had to pick up these objects and then move ahead to the finish line. The Rainbow team won this game as well. The second game we played was ‘Brick Game’. There were 6 members in each team and were given 4 bricks. Three people had to step only on the bricks and three would move the bricks to make sure those on bricks are moving ahead towards the finish line without stepping on the ground.

We were physically getting tired and people started complaining about body pain :) so the next game we played was ‘Create an Ad’ where each team had to Create an Ad on the given product , name the product and enact. The products given were Baby Nappies, Glue, Designer Saree, Hair Growth Cream, Fat losing Belt, Detergent Powder and Mouth Freshener. This was real fun and told us a lot about people’s personal life like how is Akshi as a wife, Amit Singh as a husband and how was Rohit’s childhood :D

It was lunch time by then and we had to check- out after lunch so we packed our bags had lunch and left Rappa half hearted.


© Copyright 2009 TechJini Solutions Private Limited. All Rights Reserved
iDream theme by Templates Next | Powered by WordPress