Tips

How do I kill all the processes in Mysql “show processlist”?

When MariaDB Galera Master/Master replication facing deadlock, new connection may not able to process and so looks killed. This can be checked by:

mysql -e 'show processlist'

Temporary Solution

If you see some tables are in status of "Waiting for table metadata lock", then you need to kill all process with:

mysqladmin processlist | \
awk '$2 ~ /^[0-9]/ {print "KILL "$2";"}' | \
mysql

How to Prevent Deadlock?

I am still trying to figure out a long term solution, and now trial with following my.cnf variables, which at least able to pass stress (ab) and availability (httrack) test for 4+ hours continuously:

innodb_stats_on_metadata = 0
wsrep_retry_autocommit = 0

Reference

Tips for Remove Legacy Kernel Image for Debian/Ubuntu

After numbers of update to your Debian/Ubuntu installation, usually a lot of legacy kernel image are keep inside your box, so you may hope to remove all of them. Just execute following command (i.e. after aptitude -y full-upgrade && reboot):

dpkg -l 'linux-*' | \
  sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | \
  xargs sudo apt-get -y purge

Tips for Hard Reboot Linux from Remote SSH

For example you only have remote SSH access to a Linux, but running "reboot" command doesn't work, what can you do?

Run following command for hard reboot:

echo 1 > /proc/sys/kernel/sysrq
echo b > /proc/sysrq-trigger

Or running this for hard shutdown:

echo 1 > /proc/sys/kernel/sysrq
echo o > /proc/sysrq-trigger

NOTE: By running above command no service shutdown script will be execute, not even any disk I/O write back, so only use it for critical issue.

Pngcrush a Directory Recursively

By default pngcrush (http://pmt.sourceforge.net/pngcrush/) only able to optimize single PNG file. The following script make it works with a folder recursively:

Update all GIT managed document folders

My team use GIT to manage all project related documents, including quotation, sales order, invoice, SOW, module, theme, features, etc... So how to update all local GIT clone as update with other team members become a nightmare...

This script simply solve this problem:

Tips for Resolve Apache VirtualHost + mod_userdir URL Conflict with mod_rewrite

During revamp and reinstall with my server I decide to update my Drupal 7.x blog's folder under my own ~/public_html, e.g. ~/public_html/edin.no-ip.com/. BTW this also generate another issue which conflict with Apache mod_userdir setup, as my ~/public_html will able to access from http://edin.no-ip.com/~hswong3i/.

OK a quick checklist of my setup (under Debian Squeeze):

HOWTO Convert MySQL database into SQLite

Just reinstall the entire server with Debian Squeeze and virtualization with libvirt (hope to use Eucalyptus as cloud computing later), so now going to migrate my Trac system from MySQL backend to (yes, back to...) SQLite for simplified management. Therefore the question is: how to convert the databases?

Refer to http://www.jbip.net/content/how-convert-mysql-sqlite a very useful conversion script which is functioning. First of all, the script mysql-to-sqlite.sh (with a bit changes from original version):

Tips: search and replace all lowercase CSS color code as uppercase with VIM

Refer to http://www.lefred.be/?q=node/75 I give some transform so the VIM command will only search and replace all lowercase CSS color code as uppercase. This is very useful during my theme development for Drupal:

:%s/#[0-9a-f]\{3,6\}/\U&/g

How to fix your Debian file system with fsck

Today my server is suddently report with file system error (ext4) after reboot. Some partition is not able to mount automatically and require for fsck. Here are some simple sharing about how to fix it safely.

Pages

Subscribe to RSS - Tips