Showing posts with label Howto. Show all posts
Showing posts with label Howto. Show all posts

Tuesday, August 19, 2008

How To Repair MySQL Replication

How To Repair MySQL Replication

Submitted by falko (Contact Author) (Forums) on Fri, 2008-06-06 12:10. :: MySQL

How To Repair MySQL Replication

Version 1.0
Author: Falko Timme
Last edited 05/29/2008

If you have set up MySQL replication, you probably know this problem: sometimes there are invalid MySQL queries which cause the replication to not work anymore. In this short guide I explain how you can repair the replication on the MySQL slave without the need to set it up from scratch again.

I do not issue any guarantee that this will work for you!

1 Identifying The Problem

To find out whether replication is/is not working and what has caused to stop it, you can take a look at the logs. On Debian, for example, MySQL logs to /var/log/syslog:

grep mysql /var/log/syslog

server1:/home/admin# grep mysql /var/log/syslog

May 29 09:56:08 http2 mysqld[1380]: 080529 9:56:08 [ERROR] Slave: Error 'Table 'mydb.taggregate_temp_1212047760' doesn't exist' on query. Default database: 'mydb'. Query: 'UPDATE thread AS thread,taggregate_temp_1212047760 AS aggregate
May 29 09:56:08 http2 mysqld[1380]: ^ISET thread.views = thread.views + aggregate.views
May 29 09:56:08 http2 mysqld[1380]: ^IWHERE thread.threadid = aggregate.threadid', Error_code: 1146
May 29 09:56:08 http2 mysqld[1380]: 080529 9:56:08 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'mysql-bin.001079' position 203015142
server1:/home/admin#

You can see what query caused the error, and at what log position the replication stopped.

To verify that the replication is really not working, log in to MySQL:

mysql -u root -p

On the MySQL shell, run:

mysql> SHOW SLAVE STATUS \G

If one of Slave_IO_Running or Slave_SQL_Running is set to No, then the replication is broken:

mysql> SHOW SLAVE STATUS \G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 1.2.3.4
Master_User: slave_user
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.001079
Read_Master_Log_Pos: 269214454
Relay_Log_File: slave-relay.000130
Relay_Log_Pos: 100125935
Relay_Master_Log_File: mysql-bin.001079
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB: mydb
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 1146
Last_Error: Error 'Table 'mydb.taggregate_temp_1212047760' doesn't exist' on query. Default database: 'mydb'.
Query: 'UPDATE thread AS thread,taggregate_temp_1212047760 AS aggregate
SET thread.views = thread.views + aggregate.views
WHERE thread.threadid = aggregate.threadid'
Skip_Counter: 0
Exec_Master_Log_Pos: 203015142
Relay_Log_Space: 166325247
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: NULL
1 row in set (0.00 sec)

mysql>

2 Repairing The Replication

Just to go sure, we stop the slave:

mysql> STOP SLAVE;

Fixing the problem is actually quite easy. We tell the slave to simply skip the invalid SQL query:

mysql> SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;

This tells the slave to skip one query (which is the invalid one that caused the replication to stop). If you'd like to skip two queries, you'd use SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 2; instead and so on.

That's it already. Now we can start the slave again...

mysql> START SLAVE;

... and check if replication is working again:

mysql> SHOW SLAVE STATUS \G

mysql> SHOW SLAVE STATUS \G


*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 1.2.3.4
Master_User: slave_user
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.001079
Read_Master_Log_Pos: 447560366
Relay_Log_File: slave-relay.000130
Relay_Log_Pos: 225644062
Relay_Master_Log_File: mysql-bin.001079
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: mydb
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: 447560366
Relay_Log_Space: 225644062
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)

mysql>

As you see, both Slave_IO_Running and Slave_SQL_Running are set to Yes now.

Now leave the MySQL shell...

mysql> quit;

... and check the log again:

grep mysql /var/log/syslog

server1:/home/admin# grep mysql /var/log/syslog

May 29 09:56:08 http2 mysqld[1380]: 080529 9:56:08 [ERROR] Slave: Error 'Table 'mydb.taggregate_temp_1212047760' doesn't exist' on query. Default database: 'mydb'. Query: 'UPDATE thread AS thread,taggregate_temp_1212047760 AS aggregate
May 29 09:56:08 http2 mysqld[1380]: ^ISET thread.views = thread.views + aggregate.views
May 29 09:56:08 http2 mysqld[1380]: ^IWHERE thread.threadid = aggregate.threadid', Error_code: 1146
May 29 09:56:08 http2 mysqld[1380]: 080529 9:56:08 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'mysql-bin.001079' position 203015142
May 29 11:42:13 http2 mysqld[1380]: 080529 11:42:13 [Note] Slave SQL thread initialized, starting replication in log 'mysql-bin.001079' at position 203015142, relay log '/var/lib/mysql/slave-relay.000130' position: 100125935
server1:/home/admin#

The last line says that replication has started again, and if you see no errors after that line, everything is ok.

3 Links

NTP + centos How to

CentOS Linux install and configure NTP to synchronize the system clock

Posted by Vivek Gite [Last updated: August 20, 2007]

Q. How do I install and configure NTP under CentOS Linux 5 server to synchronize the system clock?

A. You can easily install NTP (Network Time Protocol, a means of transmitting time signals over a computer network) using yum command under Redhat or CentOS/Fedora core Linux.

Procedure

Login as the root user

Type the following command to install ntp

# yum install ntp


Turn on service
# chkconfig ntpd on

Synchronize the system clock with 0.pool.ntp.org server:
# ntpdate pool.ntp.org

Start the NTP:
# /etc/init.d/ntpd start

Saturday, August 2, 2008

Virtual box in Ubuntu - Installation

Virtual box in Ubuntu - Installation

If you need to run other Operating System in Ubuntu, you have to use a Virtual Machine. There are few most used Virtual Machines available on the internet, Virtual Box is one of them.

I like to use Virtual Box because it’s easy to operate.

Installation

From Ubuntu Terminal screen (Applications > Accessories > Terminal), type:

taufanlubis@toshiba:~$ sudo apt-get install virtualbox

Reading package lists… Done

Building dependency tree

Reading state information… Done

Note, selecting virtualbox-ose instead of virtualbox

The following extra packages will be installed:

virtualbox-ose virtualbox-ose-modules-2.6.22-14-generic

Recommended packages:

virtualbox-ose-source

The following NEW packages will be installed:

virtualbox-ose virtualbox-ose-modules-2.6.22-14-generic

0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.

Need to get 6012kB of archives.

After unpacking 19.3MB of additional disk space will be used.

Do you want to continue [Y/n]? y

WARNING: The following packages cannot be authenticated!

virtualbox-ose-modules-2.6.22-14-generic virtualbox-ose

Install these packages without verification [y/N]? y

Get:1 http://archive.ubuntu.com gutsy/universe virtualbox-ose-modules-2.6.22-14-generic 6 [317kB]

Get:2 http://archive.ubuntu.com gutsy/universe virtualbox-ose 1.5.0-dfsg2-1ubuntu3 [5695kB]

Fetched 6012kB in 2m30s (40.0kB/s)

Selecting previously deselected package virtualbox-ose-modules-2.6.22-14-generic.

(Reading database … 152703 files and directories currently installed.)

Unpacking virtualbox-ose-modules-2.6.22-14-generic (from …/virtualbox-ose-modules-2.6.22-14-generic_6_i386.deb) …

Selecting previously deselected package virtualbox-ose.

Unpacking virtualbox-ose (from …/virtualbox-ose_1.5.0-dfsg2-1ubuntu3_i386.deb) …

Setting up virtualbox-ose-modules-2.6.22-14-generic (6) …

Installing new version of config file /etc/init.d/vboxdrv …

* Starting VirtualBox kernel module vboxdrv [ OK ]

Setting up virtualbox-ose (1.5.0-dfsg2-1ubuntu3) …

taufanlubis@toshiba:~$

How to run?

  • Before you run the Virtual Box, you must have a permisson, otherwise you will get an error.

  • Open System > Administration > Users and Groups > Manage Groups.

virtualbox00.png

Choose vboxusers then click Properties.

Mark on your user name and click OK.

Now, your user name has a permission to run Virtual Box.

virtualbox01.png

Now, your user name has a permission to run Virtual Box.

Open Applications > System Tools > Innotek Virtualbox.

Now, you are ready to use Virtual Box.

virtualbox02.png

Sunday, June 8, 2008

How to enable compiz fusion on Ubuntu 8.04

  • How do I install Compiz on Ubuntu 8.04?

    I have just installed Ubuntu onto my computer and now I want to install Compiz for it. This is my first time using a Linux OS, so im kinda new at this. Any detailed instructions that could help a noob out?

    Thanks
  • 2 days ago
Linux Ubuntu geek by Linux Ubuntu geek
A Top Contributor is someone who is knowledgeable in a particular category.
Member since:
May 27, 2007
Total points:
21995 (Level 6)
Badge Image:
A Top Contributor is someone who is knowledgeable in a particular category.
Contributing In:
Software

Best Answer - Chosen by Asker

To get Compiz Fusion up and running you need to install your Restricted Drivers.

System>Administration>Hardware Drivers

Restart your PC, then to enable Compiz Fusion open a terminal.

Applications>Accessories>Terminal then copy and paste

sudo aptitude install compizconfig-settings-manager

Then hit enter.

You may also like to install Emerald, again in the Terminal copy and paste

sudo apt-get install emerald

Then hit enter.

LUg.
  • 2 days ago