What is swappiness and how to change

linux, swappiness

In Linux it is very easy to configure the use of virtual memory used by the kernel. Swappiness controls the tendency of the linux kernel to move a process out of physical memory and start using swap. Disk is slower than RAM and thus can lead to a slower response time for the application itself, therefore swappiness controls how often processes are moved into the swap cache.

For example, if swappiness is set to 0, the kernel will avoid moving processes into the swap cache.

If swappiness is set to 100, the kernel will regularly use the swap cache.

By default, this setting is normally held at 60.

On a virtualised node, a good swappiness parameter to use is 010, that is because a VM has shared disk IO and it is important for the overall system to use less disk utilization.

How to change?

Find out how much swappiness is being used by running : cat /proc/sys/vm/swappiness
Adjust the parameter by changing/adding this parameter (vm.swappiness = 0) and save in: /etc/sysctl.conf
To get the change live without a restart or sysctl reload, you can run this: echo 0 > /proc/sys/vm/swappiness

Linux locale setting failure

linux

When your locales are screwed, you’re going to notice a lot of problems even trying to curl from the command line, for e.g.:
Sorry, command-not-found has crashed! Please file a bug report at:

If you see an error message like this:
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = “UTF-8”,
LANG = “en_US.UTF-8”

root@mwtokyo3:~# dpkg-reconfigure locales
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = “UTF-8”,
LANG = “en_US.UTF-8”
are supported and installed on your system.
perl: warning: Falling back to the standard locale (“C”).
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Generating locales…
en_AG.UTF-8… up-to-date
en_AU.UTF-8… up-to-date
en_BW.UTF-8… up-to-date
en_CA.UTF-8… up-to-date
en_DK.UTF-8… up-to-date
en_GB.UTF-8… up-to-date
en_HK.UTF-8… up-to-date
en_IE.UTF-8… up-to-date
en_IN.UTF-8… up-to-date
en_NG.UTF-8… up-to-date
en_NZ.UTF-8… up-to-date
en_PH.UTF-8… up-to-date
en_SG.UTF-8… up-to-date
en_US.UTF-8… up-to-date
en_ZA.UTF-8… up-to-date
en_ZM.UTF-8… up-to-date
en_ZW.UTF-8… up-to-date
Generation complete.

Just add this to your ~/.profile and ~/.bashrc
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8

Then:
source ~/.profile
source ~/.bashrc

Then try again, all should be good.

puppet failures due to “dnsdomainname: Unknown host”

linux, puppet, selinux

When I was trying to start puppet, I had the following message:
[root@m03 puppet]# service puppet start
Starting puppet: dnsdomainname: Unknown host
dnsdomainname: Unknown host

Even though puppet started successfully. I checked my /etc/hosts file as puppet looks up DNS from there, everything looked fine. I also disabled selinux as that had been recommended on another blog. That might work for you, but didn’t do much for me.

Trying to sign my certificate was proving to be the same issue as well, rendering my puppet setup completely useless:
/usr/sbin/puppetd –waitforcert 30
dnsdomainname: Unknown host
dnsdomainname: Unknown host

I decided to check on the puppet master to see if my signature request had successfully hit the master:
puppet cert list –all | grep -i m03
…but no joy there.

When the dnsdomainname error comes up, the obvious answer is that the DNS is not resolving and it turns out that my puppet install is using an extra DNS entry to connect to the master. I compared an entry on another machine in /etc/resolv.conf, added that to the new machine; ran:
/usr/sbin/puppetd –waitforcert 30

…then the catalog ran successfully.

tar – argument list too long

post

Found some files that you want to zip/tar up, but you’re hit with the argument list too long message? “tar – argument list too long”

The easiest way to get around this would be to use find, and output a list of those files to one solo file:

find . -type f -mtime -1 -size 100k -print > ./some-list-of-files
tar -cf allfiles.tgz –files-from ./some-list-of-files

The file “some-list-of-files” will print every file into a list, and then tar all the files within that list.