Category Archives: Uncategorized - Page 2

Tomcat issues

How to disable ipv6 at tomcat
-Djava.net.preferIPv4Stack=true

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

Some mysql howto

This topic was done to skip googling in some cases.

How to get mysql database size:

mysql -uroot -pPASSWORD -D DATABASE_NAME -e "show table status\G"| egrep "(Index|Data)_length" | awk 'BEGIN { rsum = 0 } { rsum += $2 } END { print rsum }'

Source: http://eddnet.org/?p=1765

How to set mysql to read only mode:
Attention! root can do r/w regardless of read_only!

mysql> set GLOBAL read_only = true;

edit config

:/etc/mysql/conf.d# cat slave.cnf
[mysqld]

server-id = 18
innodb_buffer_pool_size = 200MB
read_only = true

How to drop user

DROP USER 'USERNAME'@'%';

How to find duplicate rows.

SELECT *,count(id) AS Num FROM clicks_log GROUP BY id HAVING (COUNT(id) > 1 );

How to delete duplicated Rows
I am not SQL guru, maybe there is another perfect way how to do it, but it`s works:

mysql> create table id_tmp AS (SELECT id FROM block_news_views_log GROUP BY id HAVING (COUNT(id) > 1) ) ;
mysql> DELETE  FROM block_news_views_log WHERE ( id IN (SELECT * from id_tmp ) );
mysql> DROP table id_tmp;
mysql> SELECT id FROM block_news_views_log GROUP BY id HAVING (COUNT(id) > 1) ;

How to solve long queue qmail.

Damn, I hate mail administration… And I really like google apps (gmail) or appriver mail hosting.

Today we have issue with our corporate qmail server, mail stalled.
To be clear – I change job a week ago and just 5 days as I take care of new infrastructure.
Corporate mail server powered by qmail. Thay have zabbix as monitoring software, but not enough configured, without queue monitorind and SMS escalation. Due to great number of urgent tasks, I really have no enough hands to fix all at once…

So Monday begins with great fuckup… 180 000 messages in queue…
First diagnostic steps:
Read more »

Find CPU and memory information FreeBSD and Linux

At Linux I use

#cat /proc/cpuinfo

at FreeBSD

ms3# sysctl -a | egrep -i 'hw.machine|hw.model|hw.ncpu|hw.physmem'
hw.machine: amd64
hw.model: Intel(R) Xeon(R) CPU           E5520  @ 2.27GHz  
hw.ncpu: 16
hw.machine_arch: amd64

Read more »