Monthly Archives: July 2012

How to create ramdrive linux

Sometimes OPS need RAM drives.

I use one for nginx cache at my CDN servers

mount -t tmpfs -o size=sizeM tmpfs /mnt/ramdrive/

Add required lines to PH host fstab and to LXC fstab

tmpfs /mnt/ramdrive tmpfs size=2000M,mode=0777

How to resize ram drive:

mount -o remount,size=new-sizeM /mnt/ramdrive/

phpmyadmin #1045 Cannot log in to the MySQL server

Our developers really crazy about phpmyadmin 🙂 and ask me to setup one.
I really prefer console…
Setup in ubuntu is easy just use aptitude, Luke…
Only change I did is to add Basic Auth to phpmyadmin url, to prevent ugly internet bots from trying to bruteforce my databases.

htpasswd /etc/phpmyadmin/htpasswd.setup developers

But when I try to login to my DB interface I`v got this damned error.
#1045 Cannot log in to the MySQL server
Very very strange! I can login via console with this username…
I create user with following credentials:

mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,CREATE ROUTINE,
       CREATE TEMPORARY TABLES,CREATE VIEW,EXECUTE,INDEX,SHOW VIEW, ALTER ROUTINE
       on *.* to 'developer'@'%' IDENTIFIED by 'MEGASECUREPASSWORD';

phpmyadmin refuse this user. I turn on mysql debugging.
Read more »

How to mount disk to LXC container

It`s rather simple.
just mount disk via fstab to host system:

root@sfa2 ~ # cat /etc/fstab | grep sdc1
/dev/sdc1       /mnt/sdc1   ext4     noatime,nodiratime      0 0

and add mount with bind to your LXC fstab, usually located at

root@sfa2 ~ # cat /var/lib/lxc/dbslave1-1/config | grep fstab
lxc.mount
.entry
= /var/lib/lxc/dbslave1-1/fstab

Now restart container and enjoy.

root@sfa2 ~ # cat /var/lib/lxc/dbslave1-1/fstab
proc            proc         proc    nodev,noexec,nosuid 0 0
sysfs           sys          sysfs defaults  0 0
/mnt/sdc1       /var/lib/lxc/dbslave1-1/rootfs/sdc1  none bind     0 0

BTW: Your cannot see remained space via df -h. I don`t know how to solve this issue 🙁 🙁 🙁

My mysq server databases backup script with Percona

Simple, but working o.k.

#!/bin/bash
BDIR="/home/backup/mysql"
#DATAPATH=`date +%m%d%Y%H%M%S`

# Run backup
/usr/bin/innobackupex --user=root --password=MEGASECUREPASSWORD --slave-info $BDIR

LASTBACKUP=`ls -1 -t  $BDIR | head -n 1`

/usr/bin/innobackupex --user=root --password=MEGASECUREPASSWORD  --apply-log $BDIR/$LASTBACKUP

How to Install Percona XtraBackup and innobackupex Ubuntu 12

Percona has it`s own repo.
What is XtraBackup – damn, it`s very powerful backup tool for mysql from percona.
http://www.percona.com/doc/percona-xtrabackup/index.html
innobackupex – is a part of percona-xtrabackup package

  apt-key adv --keyserver keys.gnupg.net --recv-keys 1C4CBDCDCD2EFD2A
  echo "deb http://repo.percona.com/apt precise main" >> /etc/apt/sources.list
  cat /etc/apt/sources.list
  vi /etc/apt/sources.list
  aptitude update
  aptitude install percona-xtrabackup

How to reset qmailadmin password. And do bulk user deletion.

Today nobody can revise password to our corporate mail server Control Pannel. Powered by qmail. With qmailadmin as WEB frontend.

How to change password to postmaster@randomthemes.com
/usr/local/vpopmail/bin/vpasswd postmaster@randomthemes.com

And other issue:
Where to write rcpthosts – /usr/local/qmail/control/rcpthosts

How to make a bulk user deletion:
issue was to delete 80 000 users 🙂

mysql> select pw_name from vpopmail_randomthemes.vpopmail where pw_domain='randomthemes.com';
add users to file vpusers.txt and delete using vdeluser
# for i in `cat vpusers.txt | awk {'print $1 "@randomthemes.com"'}`; do /usr/local/vpopmail/bin/vdeluser $i; done;

How can I run dnsmasq DHCP/TFTP-only.

I mean disable DNS caching feature.
dnsmasq required by lxc to configure network, but I prefer to use bind, to provide DHCP resolver.
So use force, Luke! I mean read man.

-p, --port=<port>

Listen on <port> instead of the standard DNS port (53). Setting this to zero completely disables DNS function, leaving only DHCP and/or TFTP.

vi /etc/dnsmasq.d/lxc
port=0