Speed up mysql restoring

Increase key buffer size as much as you can

Add this header in your dump file

SET @OLD_AUTOCOMMIT=@@AUTOCOMMIT, AUTOCOMMIT = 0;
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS = 0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS = 0;

 

Add this in the end

 

SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
SET AUTOCOMMIT = @OLD_AUTOCOMMIT;

Leave a comment

Amazon AWS xennet: skb rides the rocket

Saw some time ago this problem in one server

 

 xennet: skb rides the rocket

 

Seems like we had  some kernel driver or hardware interaction problem when dealing with lots of sockets or jumbo frames.

 

To solve that, I had configured MTU to 1500 and 

ethtool -K eth0 gso off

ethtool -K eth0 tso off

 

Leave a comment

Ubuntu+Shinken+NRPE

cd /usr/local/src/
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.15.tar.gz
tar -zxf nrpe-2.15.tar.gz
cd nrpe-2.15

./configure –with-nagios-user=shinken –with-nagios-group=shinken –libexecdir=/usr/local/shinken/libexec –enable-libtap –enable-extra-opts –enable-perl-MODULES –with-ssl=/usr/bin/openssl –with-ssl-lib=/usr/lib/x86_64-linux-gnu

make all
make install-plugin

Leave a comment

Shinken and Mongdb

The debian/ubuntu default mongo does not work on shinken default installation.

to solve this

apt-get install mongodb-10gen=2.2.3

apt-mark hold mongodb-10gen

Leave a comment

Bind error (network unreachable) resolving

This problem usually occurs when bind is unable to query using a IPV6 network.

 

Apr 3 12:01:58 localhost named[5457]: error (network unreachable) resolving ‘static.ak.facebook.com.edgesuite.net/A/IN': 2600:1401:2::2#53
Apr 3 12:01:58 localhost named[5457]: error (network unreachable) resolving ‘w.soundcloud.com/A/IN': 2001:500:90:1::20#53

To avoid this:

-use an IPv6 network

or

-disable IPv6 in Bind

 

Disabling IPV6 in Bind:

/etc/default/bind9

# run resolvconf?
RESOLVCONF=yes

# startup options for the server
OPTIONS=”-4 -u bind”

Leave a comment

Checking dd status

kill -USR1 PID

Example:

hamilton@gothan:/tmp$ dd if=/dev/urandom of=/tmp/aa &
[1] 6832
hamilton@gothan:/tmp$
hamilton@gothan:/tmp$ kill -USR1 6832
hamilton@gothan:/tmp$ 246665+0 records in
246664+0 records out
126291968 bytes (126 MB) copied, 8,05584 s, 15,7 MB/s

hamilton@gothan:/tmp$ kill -USR1 6832
321788+0 records in
321788+0 records out
164755456 bytes (165 MB) copied, 10,4801 s, 15,7 MB/s
hamilton@gothan:/tmp$ kill -USR1 6832
390472+0 records in
390471+0 records out
199921152 bytes (200 MB) copied, 12,7041 s, 15,7 MB/s

Leave a comment

Debian MRTG

sudo apt-get install apache2 snmpd
sudo vi /etc/snmp/snmpd.conf

smuxsocket 127.0.0.1
rocommunity setMeHere
com2sec local localhost public
group MyRWGroup v1 local
group MyRWGroup v2c local
group MyRWGroup usm local
view all included .1 80
access MyRWGroup “” any noauth exact all all none
com2sec notConfigUser default mrtg
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.25.1.1
view systemview included .1 80
access notConfigGroup “” any noauth exact systemview none none
syslocation Athens Greece
syscontact Ubuntu.grinfo@ubuntu.gr>

 

 sudo /etc/init.d/snmpd restart

sudo apt-get install mrtg

sudo updatedb && locate mrtg

sudo mkdir /etc/mrtg && sudo mv /etc/mrtg.cfg /etc/mrtg

sudo cfgmaker –output=/etc/mrtg/mrtg.cfg public@127.0.0.1

 

Next, open /etc/mrtg/mrtg.cfg in a text editor and make sure under Global Configuration Options that the lines “WorkDir: /var/www/mrtg” (under Debian), and “Options[_]: growright, bits” (under Global Defaults) are uncommented. Finally, add the following lines under the Global Defaults section:

RunAsDaemon: Yes
Interval: 5
Logdir: /var/log/
EnableIPv6: no

 

sudo mkdir /var/www/mrtg
sudo indexmaker –output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg

sudo env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg

#! /bin/sh
### BEGIN INIT INFO
# Provides:          mrtg
# Required-Start:    
# Required-Stop:     
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: mrtg init script
# Description:       This file is used to start, stop, restart, 
#					 and determined status of the mrtg daemon.
# Author: 			 iasptk.com ;
### END INIT INFO
### START OF SCRIPT
set -e
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="mrtg"
NAME=mrtg
DAEMON=/usr/bin/$NAME
DAEMON_ARGS="/etc/mrtg/mrtg.cfg"
PIDFILE=/etc/mrtg/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
# Exit if the mrtg package is not installed
[ -x "$DAEMON" ] || exit 0
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
# Function that starts the mrtg daemon
start()
{
	env LANG=C start-stop-daemon --start --quiet \
	--exec $DAEMON -- $DAEMON_ARGS
}
# Function that stops the mrtg daemon
stop()
{
	start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \
	--pidfile $PIDFILE 
}
case "$1" in
  start)
	log_daemon_msg "Starting $DESC" 
	start
	case "$?" in
		0) log_end_msg 0 ;;
		1) log_end_msg 1 ;;
	esac
	;;
  stop)
	log_daemon_msg "Stopping $DESC"
	stop
	case "$?" in
		0) log_end_msg 0 ;;
		1) log_end_msg 1 ;;
	esac
	;;
  restart|force-reload)
	log_daemon_msg "Restarting $DESC" 
	stop
	case "$?" in
	  0|1)
		start
		case "$?" in
			0) log_end_msg 0 ;;
			1) log_end_msg 1 ;; 
		esac
		;;
	esac
	;;
	status)
    status_of_proc "$DAEMON" "$NAME"  
    ;;
  *)
	echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" 
	;;
esac
exit 0
### END OF SCRIPT

sudo chmod +x mrtg
sudo mv mrtg /etc/init.d/


sudo update-rc.d mrtg defaults

 

http://www.iasptk.com/667-ubuntu-multi-router-traffic-grapher-mrtg

Leave a comment

NTPD bind interface

Select the interfaces where ntpd should listen on, edit ntpd.conf and:

interface ignore wildcard
interface listen eth0
interface listen 127.0.0.1

Leave a comment

SNMPD opening service at random port

Just installed SNMPD in Debian 7 and checked that default installation opens a random port > 1024

root@SRVKARNAK:/etc/apache2# netstat -putan| grep snm

udp 0 0 0.0.0.0:39517                    0.0.0.0:* 9198/snmpd
udp 0 0 127.0.0.1:161                    0.0.0.0:* 9198/snmpd
udp 0 0 192.168.3.222:161           0.0.0.0:* 9198/snmpd

 

“udp 0 0 0.0.0.0:39517 ” a little concerned about security I wanted to remove this “unknown” trap.

Edit the snmpd.conf and remove the “trapsink” stuff from file, and restart the service

 

Now everything sounds good

root@SRVKARNAK:/etc/apache2# /etc/init.d/snmpd stop
Stopping network management services: snmpd snmptrapd.
root@SRVKARNAK:/etc/apache2# /etc/init.d/snmpd start
Starting network management services: snmpd.

root@SRVKARNAK:/etc/apache2# netstat -putan| grep snm

udp 0 0 127.0.0.1:161                       0.0.0.0:* 9214/snmpd
udp 0 0 192.168.3.222:161             0.0.0.0:* 9214/snmpd

 

 

Leave a comment

Gerrit on Debian

## How to build the package

* First make sure you have **build-essential** package installed on your system.
* Clone the package repository for [gerrit-debian](https://github.com/dnaeon/gerrit-debian)

Now building the package is easy as executing the command below:

$ cd /usr/local/src

$ git clone https://github.com/dnaeon/gerrit-debian.git

$ dpkg-buildpackage -us -uc

$ cd gerrit-debian

In this how to I want to use MySQL, so;

$ sudo apt-get install mysql-server mysql-client

 

Configure MySQL before start configuration:

CREATE USER 'gerrit'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON gerrit.* TO 'gerrit'@'localhost';
CREATE database gerrit;

$ sudo dpkg -i gerrit_2.4.2_all.deb

Configure Gerrit authentication is just a pain in the ass, to make thinks easy and secure I will use Apache Web Server as proxy, this way I can get more control about the whole thing.


HTTP-Client  <---> 80/443:Apache Web Server <---> 8081:Gerrit

#Gerrit configuration

cat /var/lib/gerrit/review_site/etc/gerrit.config

[gerrit]
basePath = git
canonicalWebUrl = http://git.mxt.com.br/gerrit/
[database]
type = MYSQL
hostname = localhost
database = gerrit
username = gerrit
[auth]
type = HTTP
[sendemail]
smtpServer = mail.maxtrack.com.br
smtpUser = gerrit
[container]
user = gerrit
javaHome = /usr/lib/jvm/java-6-openjdk-amd64/jre
[sshd]
listenAddress = 192.168.3.222:29418
[httpd]
listenUrl = proxy-http://127.0.0.1:8081/gerrit/
[cache]
directory = cache

Apache configuration

$cat /etc/apache2/sites-enabled/gerrit

<VirtualHost *:80>
ServerName hostname.com.br
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost On

<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location /gerrit/login/>
AuthType Basic
AuthName “Gerrit Code Review”
Require valid-user
AuthUserFile ‘/etc/apache2/gerrit.htpasswd’
</Location>

ProxyPass /gerrit/ http://127.0.0.1:8081/gerrit/
ProxyPassReverse /gerrit/ http://127.0.0.1:8081/gerrit/
</VirtualHost>

 

 

cat /etc/apache2/sites-enabled/gerrit-ssl
<IfModule mod_ssl.c>
<VirtualHost git.mxt.com.br:443>
ServerName git.mxt.com.br
ServerAdmin hamilton@maxtrack.com.br
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost On

<Proxy *>

Order deny,allow
Allow from all
</Proxy>
<Location /gerrit/login/>
AuthType Basic
AuthName “Gerrit Code Review”
Require valid-user
AuthUserFile ‘/etc/apache2/gerrit.htpasswd’
</Location>
ProxyPass /gerrit/ http://127.0.0.1:8081/gerrit/
ProxyPassReverse /gerrit/ http://127.0.0.1:8081/gerrit/
# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine on

SSLCertificateFile /etc/apache2/ssl/gerrit.crt
SSLCertificateKeyFile /etc/apache2/ssl/gerrit.key

BrowserMatch “MSIE [2-6]” \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
# MSIE 7 and newer should be able to use keepalive
BrowserMatch “MSIE [17-9]” ssl-unclean-shutdown

</VirtualHost>
</IfModule>

 

The following site has amazing information:

http://dachary.org/?p=1716

Leave a comment

Follow

Get every new post delivered to your Inbox.