Repair a Mysql database

When we try to repair a MySQL database we can stop the service. If you are using the MyISAM engine I recommend using myisamchk. A basic repair sentence could be like this:

myisamchk -r -q -p -v –sort_buffer_size=2000M /var/lib/mysql/database/table.MYI

The used parameters are the following:

* -r recovery mode
* -q quick recovery, the most common one. If this mode does not work you will have to make some research on your own.
* -p creates the keys to be repared in parallel threads.
* -v verbose mode
* –sort_buffer_size= use this to indicate the size of the buffer to sort the keys. If you do not specify this value, or the value you specify is too small, then you will see something like this myisamchk: error: myisam_sort_buffer_size is too small. To solve this just increment the size of the buffer to be used, if the error always appear then you have a extremely big table.

Clone an EC2 instance

These days Amazon sent me an email saying that the a instance that I’m using is on a server that is
failing. To clone I had to:

1. Install ec2-api-tools from http://s3.amazonaws.com/ec2-downloads/ec2-api-tools.zip on the failing instance
2. Install Java from http://javadl.sun.com/webapps/download/AutoDL?BundleId=39484 (I’m using a small instance)
3. Set .bashrc as follows:

export EC2_HOME=~/ec2
export PATH=$PATH:$EC2_HOME/bin
export EC2_PRIVATE_KEY=$EC2_HOME/pk.pem
export EC2_CERT=$EC2_HOME/cert.pem
export JAVA_HOME=/usr

Run :

source /root/.bashrc

4. Create a directory for the bundled files (/mnt/myimage in my case)
5. Bundle the actual instance using:

ec2-bundle-vol –cert ec2/cert.pem –privatekey ec2/pk.pem -s 2048 -u Your_AWS_Account_ID -d /mnt/myimage/

-u : AWS Account ID is taken from AWS page Security Credentials, e.g: 1234-5678-9012-3456. Make sure to skip the “-” when using it.
-s : size of the image
-d : directory from step 4

6. Upload the files to a S3 account using:

ec2-upload-bundle -a access_key -s secret_key -b bucket_name –manifest /mnt/myimage/image.manifest.xml

-a : access_key from Security Credentials page
-s : secret_key from Security Credentials page
-b : bucket name
–manifest : name of the manifest file

7. Register the AMI by going to your AWS EC2 console->AMI->Images->Register new AMI and enter:
bucket_name/image.manifest.xml
8. Create a new EC2 instance by using the newly registered AMI

Note that you will need the [pk,cert].pem files too.

Install Dante socks proxy

Dante socks install :

Download Dante from : ftp://ftp.inet.no/pub/socks/dante-1.2.0.tar.gz

tar zxvf dante-1.2.0.tar.gz
cd dante-1.2.0
yum install gcc make
./configure
make -j4
make install

ifconfig -a |  grep inet | awk ‘{print $2}’ | awk -F ‘:’ ‘{print $2}’ | grep -v 127.0.0.1 >  /root/ips

for i in cat ips ;do echo “internal: $i port = 6060” >> /root/sockd.conf ;done

Example of sockd.conf :

logoutput: stderr
method: username none
external: externalIPtouse
client pass {
from: 0.0.0.0/0 port 1-65535 to: 0.0.0.0/0
}
pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
method: username
protocol: tcp udp
}

Launch using :

sockd -f /root/sockd.conf -d

Skip i386 packages on a x64_86 system

I have just installed Centos 5.5 by using the Netinstall version. Seems that on my x64_86 system I have a lot of i386 packages installed. To remove them I had to :

yum -C list installed | grep i386 | awk ‘{print $1}’ | xargs yum remove -y

Also edit /etc/yum.conf and add :

exclude=*.i386 *.i486 *.i586 *.i686 *.athlon