Tag Archives: debian

Setting up a 2-node GlusterFS filesystem

This will be a quick howto on how you would set up a 2-node GlusterFS filesystem. You may look up more information at http://www.gluster.org/.

Volume types for GlusterFS

– Distributed. Distributed volumes distributes files throughout the bricks in the volume
– Replicated. Replicated volumes replicates files across bricks in the volume
– Striped. Striped volumes stripes data across bricks in the volume
– Distributed Striped. Distributed striped volumes stripe data across two or more nodes in the cluster
– Distributed Replicated. Distributed replicated volumes distributes files across replicated bricks in the volume
– Distributed Striped Replicated. Distributed striped replicated volumes distributes striped data across replicated bricks in the cluster
– Striped Replicated. Striped replicated volumes stripes data across replicated bricks in the cluster

The high level overview of how the process will be is as follows

  • Installing the required software
  • Disable or add proper firewall rules
  • Adding nodes into the cluster
  • Preparing “bricks” for use on each server
  • Creating and starting the actual GlusterFS volume
  • Mounting the GlusterFS volume
  • Installing the required software

    I will be providing examples for CentOS, Fedora, Debian and Arch Linux. The examples for CentOS will work for RHEL and Scientific Linux as well.
    CentOS
    The following command will install all dependencies.

    # yum install glusterfs

    Fedora
    The following command will install all dependencies.

    # yum install glusterfs-server

    Debian
    The following command will install all dependencies.

    # apt-get install glusterfs-server

    Arch Linux
    The following command will install all dependencies.

    # pacman -S glusterfs

    Disable or add proper firewall rules

    You will need to open the following ports for GlusterFS.

    24007 – GlusterFS Daemon
    24008 – Management
    24009 - Each brick for every volume on your host requires it’s own port. For every new brick, one new port will be used starting at 24009. (For GlusterFS versions earlier than 3.4)
    49152 - Each brick for every volume on your host requires it’s own port. For every new brick, one new port will be used starting at 49152 (GlusterFS 3.4 and later)
    38465:38467 - This is required if you use the GlusterFS NFS service.
    

    CentOS
    Disabling the default firewall

    # chkconfig iptables off
    # service stop iptables

    Fedora

    systemctl disable firewalld
    systemctl stop firewalld

    Debian
    There are no default firewall installed on Debian.
    Arch Linux
    There are no default firewall installed on Arch Linux.

    Adding nodes into the cluster

    This is incredibly easy. You may do the following command from either server. In my example I am on server1. If you don’t have a solid DNS you should add each server to each others hosts file.

    # gluster peer probe server2
    Probe successful

    Preparing “bricks” for use on each server

    Nothing fanzy, you just need to create folders. It’s also important to note that you will need to use a folder, even if you intended to use a single disk.
    Execute the following on both of your servers

    # mkdir -p /data/brick>

    Creating and starting the actual GlusterFS volume

    Creating the GlusterFS volume
    Syntax:

    gluster volume create NEW-VOLNAME [replica COUNT] [transport [tcp | rdma | tcp,rdma]] NEW-BRICK...

    Example:

    # gluster volume create test-volume replica 2 transport tcp server1:/data/brick server2:/data/brick
    Creation of test-volume has been successful
    Please start the volume to access data.
    

    Starting the GlusterFS volume

    # gluster volume start test-volume

    Mounting the GlusterFS volume

    It’s important to note that you will need to mount the GlusterFS to use it. WARNING: Adding files directly to a brick will not be included in a GlusterFS volume.
    Syntax:

    # mount.glusterfs servername:volumename /mnt/mountpoint

    Examples:

    # mount.glusterfs server1:test-volume /mnt/glusterfs/

    OR

    # mount -t glusterfs server1:test-volume /mnt/glusterfs/

    References

    http://www.gluster.org/wp-content/uploads/2012/05/Gluster_File_System-3.3.0-Administration_Guide-en-US.pdf
    http://gluster.org/community/documentation/index.php/QuickStart

    // CrashMAG

    How to configure network bonding (LACP) on Debian Wheezy

    This process essentially consist of two steps. I will be detailing steps relevant for the Linux host.

    • Configuring the switch for LACP bonding.
    • Configuring the Linux host for LACP bonding.

    Prerequisites

    • ifenslave
    • Shut down the network after installing ifenslave.
    • Start the network once the configuration changes are in place.

    Steps

    This is a virtual package and will in reality install ifenslave-2.6

    # aptitude install ifenslave

    Stop the network. Make sure you’re not connected via SSH while doing this.

    # /etc/init.d/networking stop

    Debian Kernel Module Configuration

    File: /etc/modprobe.d/bonding.conf

    #/etc/modprobe.d/bonding.conf
    alias bond0 bonding
            options bonding mode=4 miimon=100 lacp_rate=1

    File: /etc/modules

    echo "bonding" >> /etc/modules
    echo "mii" >> /etc/modules

    Debian Network Configuration

    /etc/network/interfaces
    #/etc/network/interfaces 
    auto eth0
        iface eth0 inet manual
        bond-master bond0
    
    auto eth1
         iface eth1 inet manual
         bond-master bond0
    
    auto bond0
         iface bond0 inet static
         address 192.168.0.10
         gateway 192.168.0.1
         netmask 255.255.255.0
         bond-mode 802.3ad
         bond-miimon 100
         bond-downdelay 200
         bond-updelay 200
         bond-lacp-rate 4
         bond-slaves none
         dns-nameservers 192.168.0.1
         dns-search domain.int

    Start up the network.

    # /etc/init.d/networking start

    // CrashMAG

    Linux KVM host to guest connectivity

    If you’re experience a lack of connectivity between your KVM host and your guests please see below. The instructions below will only directly work on Debian and/or Ubuntu. They will also require your guests to use macvlan or macvtap. This will also work if you’re using LXC.

    Add the following to your

    /etc/network/interfaces

    configuration file. You need to adjust the network portion of the example below according to your own setup.

    auto macvlan0
    iface macvlan0 inet dhcp
        # as eth0 and macvlan0 are on the same LAN, we must drop default route and LAN route
        pre-up route del default
        pre-up route del -net 192.168.0.0 netmask 255.255.255.0
        pre-up ip link add link eth0 name macvlan0 type macvlan mode bridge
    

    Now, either reboot or run

    ifup macvlan0

    as root.

    // CrashMAG

    Disable the filesystem check (fsck) at boot time

    There’s several ways of accomplishing this. I will list all the methods beneath, just pick the one that fits the situation/you.

    • Filesystem tunable
    • Grub boot parameter
    • Placing command files on your root device
    • Active reboot without FSCK

    Filesystem tunable

    Use the tune2fs command to tell your filesystem to have a max count of mounts before a check to 0 to disable it.

    # tune2fs -c 0 /dev/sda1

    Parameter reference:

    -c max-mount-counts
     Adjust the number of mounts after which the filesystem will be  checked  by  e2fsck(8).   If max-mount-counts  is  0  or -1, the number of times the filesystem is mounted will be disregarded by e2fsck(8) and the kernel.
    

    Grub boot parameter

    Add the following at the end of your grub boot linux line.

    fastboot

    This can be done by editing “grub.conf” or by editing the boot command via the grub menu at boot.

    Placing command files on your root device

    To disable the filesystem check on boot.

    # touch /fastboot

    To enable a filesystem check on boot.

    # touch /forcefsck

    Active reboot without FSCK

    # shutdown -rf

    Parameter reference:

    -r     Reboot after shutdown.
    -f     Skip fsck on reboot.
    

    // CrashMAG

    Setting up and configuring the Deluge 1.3 web interface on a headless server

    This is a continuation of my previous article which goes through setting up and configuring the Deluge daemon. In my example I use Arch Linux. You may have another distribution and the commands to install the software will differ. Arch Linux separates the web interface out in a package. Your distribution may or may not. Most do however leave the Deluge web component out. See beneath for details for Debian, Ubuntu & Fedora.

    We want to set up the very slick web interface. See beneath for the screenshot.

    In addition to the software we already installed there’s more to go to get the web interface working. These are not installed by default so to do so, simply run the following.

    Arch Linux

    # pacman -S deluge

    Debian/Ubuntu

    # apt-get install deluge-webui

    Fedora

    # yum install deluge-web

    Install dependencies for deluge-web.

    # pacman -S python-mako

    This will also install the following dependencies

    Targets (3): python-markupsafe-0.9.2-1 python-beaker-1.5.4-1 python-mako-0.3.4-3

    Start the Deluge web client.

    # /etc/rc.d/deluge-web start

    Connect to the web client using your browser.

    http://server name or IP:8112

    NB: You will not be able to do the initial configuration using Google Chrome. But you can use the interface in general with Google Chrome.

    Configure the password.

    You can now monitor Deluge as you prefer using a web interface. If it’s set up properly you can access this from anywhere.

    // CrashMAG

    Nano syntax highlighting

    I wanted to share an easy way of adding syntax highlighting to your favorite editor. I’ll give you examples to use for Arch Linux, RHEL, CentOS, Fedora and Debian. This all requires you to add code to your ~/.nanorc file. Luckily, the nano packages contain what you want. You just have to add it.

    The typical format of these nanorc files that comes with the nano package is programming_language.nanorc.

    To list the available packages for each distributions please do the following

    RHEL/CentOS/Scientific Linux/Fedora

    # rpm -ql nano | grep nanorc

    Debian

    # dpkg -S nano | grep nanorc

    Arch Linux

    # pacman -Ql nano

    They all reside in the /usr/share/nano/ folder on each system.

    You add languages to your ~/.nanorc the following way.

    $ cat /usr/share/nano/programming_language.nanorc >> ~/.nanorc

    The >> option will append information so you can keep using this command for each language you want to add syntax highlighting for.

    // CrashMAG