devnull

Man of many talents. Server janitor, Chief Googler, Vice President of Pencil Sharpening, Director of Turning Things Off and On Again. Technology Plumber using Linux for stuff like Satellite STB, home CCTV system, kitchen sound bar, workstations, even car onboard computer. And servers, oh yeah - lots of them. I've been a Linux Mercenary for quite a while now, often using information posted by kind strangers on the Internet to solve problems during this journey. This blog is a humble attempt to give something back to the community.

Jul 072016
 

A simple cron job removing old kernels.

You may find yourself in situation where linux kernels accumulated under/boot are starting to fill up disk space. Especially painful on older systems with small /boot partition. No automated solution out of the box on Debian/Ubuntu. Here is a workaround, removing all but two newest kernels:

crontab -l

10 23 * * 1 /root/bin/kernel-cleanup.sh

 

vim /root/bin/kernel-cleanup.sh

#!/bin/bash
echo "---------- Starting autoremove, we get rid of the old kernels eating /boot space"|logger
OLD=$(ls -tr /boot/vmlinuz-* | head -n -2 | cut -d- -f2- | awk '{print "linux-image-" $0}')
if [ -n "$OLD" ]; then
 apt-get -qy remove --purge $OLD
fi

 

Bonus hint – same thing for Centos machines

# we need yum-utils
yum install yum-utils

# add cronjob
crontab -e
0 2 * * Sat root /usr/bin/package-cleanup -y --oldkernels --count=2 |logger

On Centos you can also use *installonly_limit* in /etc/yum.conf

 

installonly_limit Number of packages listed in installonlypkgs to keep installed at the same time. Setting
to 0 disables this feature. Default is '3'. Note that this functionality used to be in the "installonlyn"
plugin, where this option was altered via tokeep. Note that as of version 3.2.24, yum will now look in the
yumdb for a installonly attribute on installed packages. If that attribute is "keep", then they will never
be removed.
Jun 222016
 

Intro

Cassandra is highly available (no SPOF) distributed database service for managing large amounts of structured data across many commodity servers.

Here is a quick recipe for starting a first Debian based Cassandra server in your Cassandra cluster.

 

Modify Debian repositories

 

  • Modify default apt sources and make sure you have Contrib in sources:
# vim /etc/apt/sources.list
deb http://http.debian.net/debian jessie main contrib non-free
deb-src http://http.debian.net/debian jessie main contrib non-free
deb http://http.debian.net/debian jessie-updates main contrib non-free
deb-src http://http.debian.net/debian jessie-updates main contrib non-free
deb http://security.debian.org/ jessie/updates main contrib non-free
deb-src http://security.debian.org/ jessie/updates main contrib non-free

 

  • Add Cassandra to sources:
# vim /etc/apt/sources.list.d/cassandra.list
deb http://www.apache.org/dist/cassandra/debian 37x main
deb-src http://www.apache.org/dist/cassandra/debian 37x main

 

Install Oracle Java JDK

Visit Oracle website and download Oracle JDK tar.gz package from Oracle website

http://www.oracle.com/technetwork/java/javase/downloads/index.html

 

 Install Java and Cassandra

sudo -i
apt-get update && apt-get install java-package && exit
apt install libgl1-mesa-glx libgtk2.0-0 libxxf86vm1 -y
make-jpkg jdk-8u51-linux-x64.tar.gz
dpkg -i oracle-java8-jdk_8u91_amd64.deb
update-alternatives --config java # and choose Oracle version
apt-get install cassandra -y

 

Is it running?

# systemctl status cassandra
cassandra.service - LSB: distributed storage system for structured data
Loaded: loaded (/etc/init.d/cassandra)
Active: active (running) since Wed 2016-06-22 13:23:54 UTC; 17min ago
CGroup: /system.slice/cassandra.service
└─17055 java -Xloggc:/var/log/cassandra/gc.log -ea -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -XX:+Heap

Working with Cassandra

cqlsh
nodetool status
nodetool info
nodetool tpstats

Example output:

$ cqlsh

Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.7 | CQL spec 3.4.2 | Native protocol v4]
Use HELP for help.
cqlsh> 

$ nodetool status

Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
--  Address    Load       Tokens       Owns (effective)  Host ID                               Rack
UN  127.0.0.1  105.98 KiB  256          100.0%            c1ad1f98-170a-4a29-a007-46fd1dda4506  rack1

Easy!