Saturday, August 13, 2011

Remove MySQL Binary Log with PURGE BINARY LOGS Statement

A while ago I had a problem whereby on a very busy mysql cluster,
I had a problem whereby mysql was filling up /var. 
To fixed the problem, I made use of Linux's find and its ability to find 
all mysqls binary logs older than a certain date. 

Ive now discovered 'PURGE BINARY LOGS'.  
Heres my examples:

mysql -u username -p
mysql>PURGE BINARY LOGS TO 'mysql-bin.000005';
 
shell> mysql -u username -p
mysql> PURGE BINARY LOGS BEFORE '2011-08-13 00:00:00';


For more information. 
http://dev.mysql.com/doc/refman/5.0/en/purge-binary-logs.html 

Encrypt a file with a password

This will add an encrypted file called [filename].gpg.
gpg --cipher-algo AES -c [filename]
(passphrase will be prompted) 
This will create the decrypted file called [filename].
gpg -o [filename] -d [filename].gpg

Thursday, August 11, 2011

Problems with Apache over NFS (Or maybe any other network file system for that matter), maybe look at

http://httpd.apache.org/docs/2.2/mod/core.html#enablemmap
http://httpd.apache.org/docs/2.2/mod/core.html#enablesendfile

Long story short, disable these.
I.e.
vi /etc/apache2/conf.d/mmap.conf
add

EnableMMAP off
EnableSendfile off


HTH

Brent

*Update*
Just to add. I just came across these links.

http://www.cyberciti.biz/tips/apache-223-corrupt-file-download-issue.html
http://www.scribd.com/doc/7234985/Scaling-Apache-Handout

Wednesday, August 3, 2011

Debugging NFS

Debugging nfs problems can be frustrating. I just found on stackoverflow,
that this helps you get more info from the logs:
 
* RPC debugging:
       echo 2048 > /proc/sys/sunrpc/rpc_debug
       grep . /proc/net/rpc/*/content
       ls -l /proc/fs/nfsd
       cat /proc/fs/nfs/exports 
* NFS debugging:
      # turn on linux nfs debug
      echo 1 > /proc/sys/sunrpc/nfs_debug
      # turn off linux nfs debug
      echo 0 > /proc/sys/sunrpc/nfs_debug 
 
HTH 

Secure Apache2

Im fortunate that, in the past, I've been audited for PCI Compliancy and gained extended experience in server hardening.

One of the key things I see that most don't do is a simple Apache config change to help secure ones self.

Just:
vim /etc/apache2/conf.d/security 
and add

ServerTokens Prod
ServerSignature Off
TraceEnable Off
 
/etc/init.d/apache2 restart

Mysql : Problems with debian-sys-maint db user.

I recently restored a Mysql full database backup to a new server. As a result I had a problem with the system user (i.e. debian-sys-maint ).

The quickest way to get 'debian-sys-maint' working on the new server is:

1) /etc/mysql/debian.cnf and get the password.
2) Run mysql -u root -p
3) Run GRANT ALL PRIVILEGES ON *.* \
TO 'debian-sys-maint'@'localhost' \
IDENTIFIED BY 'passwordIndebian.cnf' WITH GRANT OPTION;
 
HTH
Brent 

Thursday, April 14, 2011

I love performance and optimising tuning.

I recently came across another MySQL tuning tool.
http://www.day32.com/MySQL/tuning-primer.sh

(You will need to first install bc)

HTH

Brent