NO SENSE NEWS FROM THE WEB
How-to
How to (video and images)
Howto – Avoid MySQL swapping on multi core CPUs
Jul 31st
What is swap?
Swap space is the area on a hard disk which is part of the Virtual Memory of your machine, which is a combination of accessible physical memory (RAM) and the swap space. Swap space temporarily holds memory pages that are inactive. Swap space is used when your system decides that it needs physical memory for active processes and there is insufficient unused physical memory available. If the system happens to need more memory resources or space, inactive pages in physical memory are then moved to the swap space therefore freeing up that physical memory for other uses. Note that the access time for swap is slower therefore do not consider it to be a complete replacement for the physical memory. Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap
files.
Why do I need swap?
Memory consuming programs Sometimes, a large program (like MySQL) make the entire system need extra memory. A significant number of the pages used by these large programs during its startup may only be used for initialization and then never used again. The system can swap out those pages and free the memory for other programs or even for the disk cache. In these cases, swap will be used to help the system handle any extra load.
Hibernation (suspend-to-disk) The hibernation feature (suspend-to-disk) writes out the contents of RAM to the swap partition before turning off the machine. Therefore, your swap partition should be at least as big as your RAM size. The hibernation implementation currently used in Ubuntu, swsusp, needs a swap or suspend partition. It cannot use a swap file on an active file system.
Unforeseeable Circumstances Unforeseeable events can and will happen (a program going crazy, some action needing much more space than you thought, or any other unpredictable combination of events). In these cases, swap can give you an extra delay to figure out what happened, or to finish what you are working on.
Symptoms
MySQL is being slow and when we run programs like ‘top’ we can see that our process (or server) is using a large quantity of swap.
What is this affecting the MySQL performance ?
MySQL will change the way works since it will replace the internal algorithms to be optimized for Disk I/O due the navy use of swap. This will make the system slower.
What we can do ?
First we need to figure out how much swap is the system using and how much free memory does it have.
1) The first trick we can do is to drop disk caches, this will free some more memory:
echo 3 > /proc/sys/vm/drop_caches
2) If we can move the swap into real memory (swap usage < free memory) we can run:
swapoff -a (to disable the swap usage, this will force to move data to memory)
swapon -a (will re-enable use of swap)
3) Check to see how aggressive is the system setup to use swap by using:
cat /proc/sys/vm/swappiness
I personally prefer to have this value around 10 (0 no not use swap – 100 use swap)
to change this
edit /etc/sysctl.conf and add a new line “vm.swappiness=10“. Save the file and run
sysctl -f /etc/sysctl.conf
4) Make sure that mysql is allocating memory close to equal for each physical CPU (not core), you may check this by typing
numactl –hardware
due the NUMA architecture this may be one of the main issue why mysql is swapping in the first place.
Howto – Compile Debian/Ubuntu kernel
Mar 4th
Compile Ubuntu kernel
get the tools for building the kernel
apt-get -y install build-essential libncurses5-dev fakeroot kernel-package linux-source
the kernel source code will be in /usr/src/
go to /usr/src and decompress the kernel
tar -xjf linux-source-2.6.28.tar.bz2
and make a symlink
ln -s /usr/src/linux-source-2.6.28 linux
now go the the kernel menu and select what options do you want to compile in your kernel
make menuconfig
next, rebuild the kernel
cd /usr/src/linux
fakeroot make-kpkg --initrd --revision=subzero.1.0 kernel_image
Howto – Cleanup mac ports
Mar 4th
Did you use mac ports, and after each update your ports are getting bigger and bigger ? Do you want to cleanup a few hundred of MB ? This is how you do it!
In order to see what is installed on your machine
port installed
to checkout the last version of the ports from the repository
sudo port -v selfupdate
howto update the ports
sudo port upgrade outdated
now to clean all the old version
sudo port clean --all installed
Howto Mount Remote Filesystem using SSH
Mar 4th
You can access a remote file system securely using sshfs and fuse which is a command to mount a remote filesystem encrypted through ssh.
This way you will be able to access remote files as if they were on you machine, just remember that if the connection between the computers is slow, the access will also be pretty slow
Package needed
sshfs
fuse-utils
Installation
Get the packages
For Debian: apt-get install fuse-utils sshfs
For Ubuntu: sudo apt-get install fuse-utils sshfs
For Fedora and Centos: yum install fuse-utils sshfs
For Mandriva: urpmi: urpmi fuse-utils sshfs
Next step is to mount the fuse module
modprobe fuse
Next create the mount point
mkdir /mnt/remote-fs
chown [your-user]:[your-group] /mnt/remote-fs/
Add yourself to the fuse group
adduser [your-user] fuse
Untill here all the command should be issued as root, now switch to your users and mount the remote filesystem.
sshfs remote-user@remote.server:/remote/directory /mnt/remote-fs/
It will now ask you accept the key if this is the first time you connect to that PC using ssh, and then the password, or only the password if this is not the first time you use ssh to connect to the remote server . That should be all.
How to find all local IP addresses in python
Jul 26th
I was trying to get all the local IP addresses (public and private) in python , and the standard socket library seems to provide only information about the IP that resolve your hostname. Here is a quick way how to list all your ip from all interfaces in python.
First you need to install the python netifaces module:
On a debian system you can install the module like this:
sudo apt-get install python-netifaces
You’re done, now you can write the code:
from netifaces import interfaces, ifaddresses, AF_INET
for ifaceName in interfaces():
addresses = [i['addr'] for i in ifaddresses(ifaceName)[AF_INET]]
print ‘%s: %s’ % (ifaceName, ‘, ‘.join(addresses))
on my computer I have an output like this:
lo: 127.0.0.1
eth0: 1.1.1.1
eth1: 192.168.0.1
No Sense ?
How to setup a serial connection on MacBook Pro
Jul 18th
An DB9/RJ45 adapter, free USB port, mac ports installed.
Installing
After the serial port is plugged in you USB port you would be able to see the adapter on Apple>About This Mac>More Info
Next we need some drivers for the adapter.
More >
How to create a cisco console cable
Jul 18th
For this operation you need an RJ45 cable and a DB9 adapter.
RJ45 cable
This adapter works with the RJ45 serial port found on most Cisco routers. It also works on some Sun servers.
This is pretty much just like the crossover cable but with a different pinout:
1 – 6
2 – 5
3 – 3
4 – 8
5 – 7
6 – 4
7 – 1
8 – 2
- the other side
DB9 adapter
This is the trickiest part. In order to make your cable compatible with the largest number of serial devices possible, you need to combine a couple pins and split another one. Here is the pinout:
More >







Recent Comments