lost and found ( for me ? )

CentOS 6.7 : ethtool “rx_discards” errors

Here is a memo about “rx_discards” error.

Reference
http://wiki.centos.org/Events/Dojo/Bangalore2014
(Topic: Network Debugging -> Slides: Network-jkalliyat.pdf )

# cat /etc/centos-release
CentOS release 6.7 (Final)

# uname -ri
2.6.32-573.3.1.el6.x86_64 x86_64

I found a number of “rx_discards” is counting up on one of interfaces, which processes approximately 300,000 UDP packet / sec.

In my case, I was able to solve that by increasing buffers on that interface.

rx_discards errors on interface ‘eth0’
# while :; do ethtool -S eth0 | grep discard ; sleep 1; done     
tx_discards: 0
    rx_discards: 49070
    tx_discards: 0
    rx_discards: 49071

Red line: current setting
# ethtool -g eth0
Ring parameters for eth0:
Pre-set maximums:
RX:             2047
RX Mini:        0
RX Jumbo:       0
TX:             511
Current hardware settings:
RX:             200
RX Mini:        0
RX Jumbo:       0
TX:             511

Increase RX buffers to 2047 from 200
# ethtool -G eth0 rx 2047

After increasing buffers.
# ethtool -g eth0
Ring parameters for eth0:
Pre-set maximums:
RX:             2047
RX Mini:        0
RX Jumbo:       0
TX:             511
Current hardware settings:
RX:             2047
RX Mini:        0
RX Jumbo:       0
TX:             511

Here are my kernel parameters.
sysctl -w net.ipv4.tcp_rmem="4096 873800 4194304"
sysctl -w net.ipv4.tcp_wmem="4096 873800 4194304"
sysctl -w net.ipv4.tcp_mem="5194304 5194304 5194304"
sysctl -w net.core.rmem_default=4194304
sysctl -w net.core.wmem_default=4194304
sysctl -w net.core.rmem_max=4194304
sysctl -w net.core.wmem_max=4194304
sysctl -w net.core.optmem_max=20480
/sbin/ethtool -G eth0 rx 2047

create a temporary text file under directory or in memory

small tips.
Here is how to create a temporary text file with python ‘tempfile’ module.

the first one is creating a temporary text file under /tmp directory and the second one is in memory
mint-note untitled # cat virtual_file01.py
__author__ = 'root'

import tempfile
import os

# create a temporary text file under /tmp directory
temp_file = tempfile.NamedTemporaryFile(mode='w+t',suffix='_suffix',prefix='prefix_',dir='/tmp')

try:
   temp_file.writelines(['first\n','second\n'])
   temp_file.seek(0)

   print temp_file
   print temp_file.name

   for line in temp_file:
       print line.rstrip()
finally:
   temp_file.close()

# create a virtual text file in memory
temp_memory_file = tempfile.SpooledTemporaryFile(mode='w+t',max_size=10000,prefix='prefix_',suffix='_suffix')

try:
   temp_memory_file.writelines(['first\n','second\n'])
   temp_memory_file.seek(0)

   print temp_memory_file
   print temp_memory_file.name

   for line in temp_memory_file:
       print line.rstrip()

finally:
   temp_memory_file.close()

mint-note untitled # python virtual_file01.py
<open file '<fdopen>', mode 'w+t' at 0x7f2179c1c4b0>
/tmp/prefix_qONxA9_suffix
first
second
<tempfile.SpooledTemporaryFile instance at 0x7f2179bde878>
None
first
second

install docker on Ubuntu 14.04 running within virtualbox

Here are trial and error logs when installing docker on Ubuntu 14.04 which is running within virtualbox as a virtual machine.

I used vagrant to prepare VMs for docker testing environment.
I already downloaded some boxes in my machine and used trusty64(virtualbox).
$ vagrant box list
centos60      (virtualbox, 0)
coreos-alpha  (virtualbox, 752.1.0)
coreos-stable (virtualbox, 717.3.0)
trusty64      (libvirt, 0)
trusty64      (virtualbox, 0)

initialize a new vagrant environment for docker testing environment.
$ vagrant init trusty64

Here is a Vagrantfile.
I prepared two VMs for a clustering test( I will evaluate that later)  and each VM has three vNICs.
$ cat Vagrantfile
Vagrant.configure(2) do |config|
 config.vm.box = "trusty64"
 config.vm.provider "virtualbox" do |v|
   v.memory = 2048
   v.cpus = 1
 end

 config.vm.define :ubuntu01 do |ubuntu01|
   ubuntu01.vm.hostname = "ubuntu01"
   ubuntu01.vm.network :private_network, ip: "192.168.33.10"
   ubuntu01.vm.network :private_network, ip: "192.168.34.10"
   ubuntu01.vm.network :private_network, ip: "192.168.35.10"
 end

 config.vm.define :ubuntu02 do |ubuntu02|
   ubuntu02.vm.hostname = "ubuntu02"
   ubuntu02.vm.network :private_network, ip: "192.168.33.20"
   ubuntu02.vm.network :private_network, ip: "192.168.34.20"
   ubuntu02.vm.network :private_network, ip: "192.168.35.20"
 end
end

start the VMs
$ vagrant up

$ vagrant status
Current machine states:

ubuntu01                  running (virtualbox)
ubuntu02                  running (virtualbox)

access to the “ubuntu01” VM
$ vagrant ssh ubuntu01


vagrant@ubuntu01:~$ ifconfig -a | grep 192
         inet addr:192.168.33.10  Bcast:192.168.33.255  Mask:255.255.255.0
         inet addr:192.168.34.10  Bcast:192.168.34.255  Mask:255.255.255.0
         inet addr:192.168.35.10  Bcast:192.168.35.255  Mask:255.255.255.0

install docker within this virtual machine(ubuntu01).
vagrant@ubuntu01:~$ sudo apt-get update

vagrant@ubuntu01:~$ sudo apt-get install docker.io

vagrant@ubuntu01:~$ docker --version
Docker version 1.0.1, build 990021a

docker.io is a symbolic link file of docker.
Googling docker installation tutorials, it seems that we need to create a symbolic link manually, however, in my case, I do not need to do that.
The symbolic link was created automatically.
vagrant@ubuntu01:~$ ls -l /usr/bin/docker*
-rwxr-xr-x 1 root root 15240483 Aug 21  2014 /usr/bin/docker
lrwxrwxrwx 1 root root        6 Aug 21  2014 /usr/bin/docker.io -> docker

confirm docker is running as a background process.
vagrant@ubuntu01:~$ sudo service docker.io status
docker.io start/running, process 26735

start docker.io when a server boots up.
vagrant@ubuntu01:~$ sudo update-rc.d docker.io defaults

download a docker container
vagrant@ubuntu01:~$ sudo docker pull ubuntu

run a docker container.
vagrant@ubuntu01:~$ sudo docker run -i -t ubuntu /bin/bash
root@84bf7f3be749:/#

open another terminal
list containers running.
vagrant@ubuntu01:~$ sudo docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS              PORTS               NAMES
84bf7f3be749        ubuntu:14.04        /bin/bash           About a minute ago   Up About a minute                       furious_curie       
vagrant@ubuntu01:~$

stop the container
vagrant@ubuntu01:~$ sudo docker stop 84bf7f3be749
84bf7f3be749

vagrant@ubuntu01:~$ sudo docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
vagrant@ubuntu01:~$

Reference
http://www.liquidweb.com/kb/how-to-install-docker-on-ubuntu-14-04-lts/