I have encountered this error, which to my surprise occurred on a slave database.
mysql> SHOW SLAVE STATUS\G
error ‘Duplicate entry ’4534534′ for key 1′ on query ‘ INSERT INTO customer_history (DateStamp) VALUES (NOW())
solution :
mysql> set global sql_slave_skip_counter = 1;
Query OK, 0 rows affected (0.01 sec)
mysql> slave start;
Query OK, 0 rows affected (0.00 sec)
This will skip the error and continue replicating from the master
Pretty straightforward
To compress mysqldump output :
mysqldump -uroot -psome_password db_name| gzip -c > db_name.gz |
or alternatively, to compress it to a file on another host
mysqldump -uroot -psome_password dbname | gzip -c | ssh user@host -p22 'cat > /root/db_name.sql.gz' |
To restore a database from a compressed file
gunzip < db_name.gz | mysql -uroot -psome_password db_name |
Previously I was using SMS for notifications of failures on certain mission critical business servers. I recently decided to use twitter instead. The main reason being that twitter is free, and with the twitter for iphone app, I get push notifications immediately (actually faster than SMS).
Twitter API uses OAUTH, so its a little tricky, but not wildly complex – anyone with basic PHP knowledge should be able to implement it
Heres how to do it
* go to dev.twitter.com – sign in with the username you want to send notifications from
* click on “Register an app”
* Fill in the fields – dont worry about a callback url – we wont be using it
* change access type to “Read & Write”
* once you have completed the registration, click “view your applications” on the right hand side
* click “edit details”
* click “application detail” on the right
* copy “consumer key” and “consumer secret”
* click on “My access token”
* copy “Access token” and “Access token secret”
Ok – now we have all the info needed to start.
For the twitter integration we will use Abraham Twitter OAuth library
The only 2 files you need are “twitteroauth/OAuth.php” and “twitteroauth/twitteroauth.php”. Stick these wherever you want. For purposes of this demo, I’m putting them in the same folder as my index.php
<?php require_once 'TwitterOAuth.php'; $CONSUMER_KEY = "????"; $CONSUMER_SECRET = "????"; $OAUTH_TOKEN = "????"; $OAUTH_SECRET = "????"; //create connection $connection = new TwitterOAuth($CONSUMER_KEY, $CONSUMER_SECRET, $OAUTH_TOKEN, $OAUTH_SECRET); //verify account $content = $connection->get('account/verify_credentials'); //post status update $connection->post('statuses/update', array('status' => "My first status update via twitter")); //mention someone $connection->post('statuses/update', array('status' => "@zayinkrige thanks for the blogpost")); //DM someone $connection->post('statuses/update', array('status' => "D zayinkrige thanks for the blogpost")); ?> |
Thats pretty much all there is to using twitter. For a full list of twitter api functions, visit http://api.twitter.com

Categories
Tag Cloud
Blog RSS
Comments RSS
Last 50 Posts
Back
Void « Default
Life
Earth
Wind
Water
Fire
Light 