Skip to content

sysadmin

InfluxDB Installation on CentOS 6

InfluxDB is an open-source, distributed, time series database with no external dependencies. In this documentation, I will show how to install InfluxDB on CentOS 6.


Download InfluxDB

wget https://s3.amazonaws.com/influxdb/influxdb-latest-1.x86_64.rpm

Install InfluxDB

sudo rpm -ivh influxdb-latest-1.x86_64.rpm

Enable and start InfluxDB service

sudo chkconfig influxdb on
sudo service influxdb start

Reference: http://influxdb.com/download/

Sensu Installation on CentOS 6

Sensu is often described as the “monitoring router”. Essentially, Sensu takes the results of “check” scripts run across many systems, and if certain conditions are met; passes their information to one or more “handlers”. Checks are used, for example, to determine if a service like Apache is up or down. Checks can also be used to collect data, such as MySQL query statistics or Rails application metrics. Handlers take actions, using result information, such as sending an email, messaging a chat room, or adding a data point to a graph. There are several types of handlers, but the most common and most powerful is “pipe”, a script that receives data via standard input. Check and handler scripts can be written in any language, and the community repository continues to grow! In this documentation, I will show how to install Sensu on CentOS 6.


Generate SSL certificates for communication of Sensu components (be sure that OpenSSL is installed)

which openssl
openssl version
cd /tmp
wget http://sensuapp.org/docs/0.16/tools/ssl_certs.tar
tar -xvf ssl_certs.tar
cd ssl_certs
./ssl_certs.sh generate

Install RabbitMQ (requires Erlang from EPEL repository)

sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
sudo yum install erlang
sudo rpm --import http://www.rabbitmq.com/rabbitmq-signing-key-public.asc
sudo rpm -Uvh http://www.rabbitmq.com/releases/rabbitmq-server/v3.4.4/rabbitmq-server-3.4.4-1.noarch.rpm
sudo chkconfig rabbitmq-server on
sudo service rabbitmq-server start

Configure RabbitMQ SSL listenet

sudo mkdir -p /etc/rabbitmq/ssl
sudo cp /tmp/sensu_ca/cacert.pem /etc/rabbitmq/ssl/
sudo cp /tmp/server/cert.pem /etc/rabbitmq/ssl/
sudo cp /tmp/server/key.pem /etc/rabbitmq/ssl/
sudo vi /etc/rabbitmq/rabbitmq.config

[
{rabbit, [
{ssl_listeners, [5671]},
{ssl_allow_poodle_attack, true},
{ssl_options, [{cacertfile,"/etc/rabbitmq/ssl/cacert.pem"},
    {certfile,"/etc/rabbitmq/ssl/cert.pem"},
    {keyfile,"/etc/rabbitmq/ssl/key.pem"},
    {verify,verify_peer},
    {fail_if_no_peer_cert,true}]}

]} ].

sudo service rabbitmq-server restart

Create a RabbitMQ vhost for Sensu

sudo rabbitmqctl add_vhost /sensu

Create a RabbitMQ user with permissions for the Sensu vhost

sudo rabbitmqctl add_user <rabbitmq-user> <rabbitmq-password>

Create a RabbitMQ user with permissions for the Sensu vhost

sudo rabbitmqctl set_permissions -p /sensu sensu ".*" ".*" ".*"

(Optional) Enable the RabbitMQ web management console

sudo rabbitmq-plugins enable rabbitmq_management

Install Redis (you can use tutorial in this page) Add Sensu repository

sudo vi /etc/yum.repos.d/sensu.repo

[sensu]
name=sensu-main
baseurl=http://repos.sensuapp.org/yum/el/$releasever/$basearch/
gpgcheck=0
enabled=1

Install Sensu using yum

sudo yum install sensu

Add Sensu SSL certificates

 sudo mkdir -p /etc/sensu/ssl
 sudo cp /tmp/ssl_certs/client/cert.pem /etc/sensu/ssl/
 sudo cp /tmp/ssl_certs/client/key.pem /etc/sensu/ssl/

Configure Sensu to communicate with RabbitMQ

sudo vi /etc/sensu/conf.d/rabbitmq.json

{

"rabbitmq": { "ssl": { "cert_chain_file": "/etc/sensu/ssl/cert.pem", "private_key_file": "/etc/sensu/ssl/key.pem" }, "host": "", "port": 5671, "vhost": "/sensu", "user": "", "password": "" } } Configure Sensu to communicate with Redis

sudo vi /etc/sensu/conf.d/redis.json

{
  "redis": {
 "host": "localhost",
    "port": 6379
  }
}

Configure Sensu API

sudo vi /etc/sensu/conf.d/api.json

{

"api": { "host": "localhost", "port": 4567, "user": "", "password": "" } } Configure Sensu client

sudo vi /etc/sensu/conf.d/client.json

{
  "client": {
    "name": "<client-name>",
    "address": "<clien-ip>",
    "subscriptions": [ "all" ]
  }
}

Enable Sensu services

sudo chkconfig sensu-server on
sudo chkconfig sensu-client on
sudo chkconfig sensu-api on

Start Sensu services

sudo service sensu-server start
sudo service sensu-client start
sudo service sensu-api start

Install Sensu dashboard: Uchiwa

sudo yum install uchiwa

Configure Sensu dashboard: Uchiwa

sudo cp /etc/sensu/{uchiwa.json,uchiwa.json.old}
sudo vi /etc/sensu/uchiwa.json

{
    "sensu": [
        {
            "name": "Sensu",
            "host": "127.0.0.1",
            "ssl": false,
            "port": 4567,
            "user": "<api-user>",
            "pass": "<api-password>",
            "path": "",
            "timeout": 5000
        }
    ],
    "uchiwa": {
        "user": "<uchiwa-user>",
        "pass": "<uchiwa-password>",
        "port": 3000,
        "stats": 10,
        "refresh": 10000
    }
}

Enable and start Uchiwa

sudo chkconfig uchiwa on
sudo service uchiwa start

You can access Uchiwa in http://sensu-server-ip:3000

References: http://sensuapp.org/docs/0.16/guide http://www.rabbitmq.com/install-rpm.html

Memcached on CentOS 6

Memcached is free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load. Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering. In this documentation I will show how to install memcached using yum package manager with Atomicorp repository.


Install the latest Atomicorp repository from http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/

sudo rpm -Uvh atomic-release*rpm

Then install memcached sudo yum install memcached

Reference: http://pkgs.org/centos-6/atomic-x86_64/memcached-1.4.22-4.el6.art.x86_64.rpm.html

MongoDB on CentOS 6

MongoDB is the only database that harnesses the innovations of NoSQL (flexibility, scalability, performance) and builds on the foundation of relational databases (expressive query language, secondary indexes, strong consistency). In this documentation, I will show how to install MongoDB on CentOS 6.


Add MongoDB repository to yum

sudo vi /etc/yum.repos.d/mongodb.repo

[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1

Install MongoDB

sudo yum install mongo-10gen mongo-10gen-server --exclude mongodb-org,mongodb-org-server

Add this to /etc/yum.conf to prevent MongoDB from being upgraded

sudo vi /etc/yum.conf

...
exclude=mongo-10gen,mongo-10gen-server

Start MongoDB service and configure it to start at boot

sudo service mongod start
sudo chkconfig mongod on

Reference: https://docs.mongodb.org/v2.4/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux/

Open Source Phusion Passenger Module for Nginx on CentOS 6

Phusion Passenger is a web server and application server for your web apps which built upon Ruby or NodeJS. In this documentation I will show how to install open source version of Phusion Passenger on CentOS 6.6 using Ruby gem installation.


Check your Ruby location

which ruby
/usr/local/rvm/rubies/ruby-2.1.5/bin/ruby

In this tutorial I assume your Ruby is installed using RVM Install passenger using gem command

gem install passenger -V

Install passenger module for nginx

rvmsudo passenger-install-nginx-module

Follow the installation steps and you can customize your nginx installation if you want Download init script for nginx and install

wget https://gist.githubusercontent.com/prasetiyohadi/90355ce4b02487261f58/raw/35319a9b63331a9503424c40489d7be27387584d/nginx
mv nginx /etc/init.d/nginx
sudo chmod +x /etc/init.d/nginx

Start nginx service

sudo chkconfig nginx on
sudo service nginx start
sudo service nginx status

Reference: https://www.phusionpassenger.com/documentation/Users%20guide%20Nginx.html#rubygems_generic_install https://www.digitalocean.com/community/tutorials/how-to-deploy-rails-apps-using-passenger-with-nginx-on-centos-6-5

Redis on CentOS 6

Redis is an open source, BSD licensed, advanced key-value cache and store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets, sorted sets, bitmaps and hyperloglogs. In this documentation, I will show how to install Redis on CentOS 6.


Install Development Tools

sudo yum groupinstall "Development Tools"

Download and extract latest Redis package from http://redis.io/ wget http://download.redis.io/releases/redis-2.8.19.tar.gz tar zxf redis-2.8.19.tar.gz Go to redis directory and run make

cd redis-2.8.19
make

it is a good idea to run make test

sudo yum install tcl
make test

Then run make install

sudo make install

Add /usr/local/bin and /usr/local/sbin to your secure_path in /etc/sudoers

Install as service

sudo ./utils/install-server.sh
Welcome to the redis service installer
This script will help you easily set up a running redis server

Please select the redis port for this instance: [6379]
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf]
Selected default - /etc/redis/6379.conf
Please select the redis log file name [/var/log/redis_6379.log]
Selected default - /var/log/redis_6379.log
Please select the data directory for this instance [/var/lib/redis/6379]
Selected default - /var/lib/redis/6379
Please select the redis executable path [/usr/local/bin/redis-server]
Selected config:
Port           : 6379
Config file    : /etc/redis/6379.conf
Log file       : /var/log/redis_6379.log
Data dir       : /var/lib/redis/6379
Executable     : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
Starting Redis server...
Installation successful!

Test your redis installation

redis-cli
127.0.0.1:6379>INFO

Reference: http://redis.io/download

RVM for Managing Ruby Version on CentOS 6

RVM is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems. In this documentation I will show how to install RVM on CentOS 6.6.


Install Development Tools

sudo yum groupinstall "Development Tools"

Install mpapis public key

sudo gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

or if failed

curl -sSL https://rvm.io/mpapis.asc | sudo gpg2 --import -

Install RVM for multiuser installation

\curl -sSL https://get.rvm.io | sudo bash -s stable

Add your user to rvm group

sudo usermod -aG rvm <user>

Logout and login again then install Ruby

rvm install 2.1
rvm use --default 2.1

You have installed Ruby version 2.1 and set it as your default version of Ruby.

ruby -v
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux]

Reference: https://rvm.io/rvm/install

Varnish 4 on CentOS 6

Varnish Cache is a web application accelerator also known as a caching HTTP reverse proxy. You install it in front of any server that speaks HTTP and configure it to cache the contents. Varnish Cache is really, really fast. It typically speeds up delivery with a factor of 300 - 1000x, depending on your architecture. In this documentation, I will show how to install Varnish 4 on CentOS 6.


For first installation install Varnish repository

sudo rpm --nosignature -i https://repo.varnish-cache.org/redhat/varnish-4.0.el6.rpm

Then install Varnish

sudo yum install varnish

Start Varnish service and configure it to start at boot

sudo service varnish start
sudo chkconfig varnish on

Reference: https://www.varnish-cache.org/installation/redhat

Start Your Own Documentation Blog

I am trying to write again after some month was absent from touching any electronic notes (blogs). Actually I wanted to do it from a long time ago but I was afraid don't have any material with qualities to be written. In reality, I realized that I have been encountering events that I must write about. After so long trying to make up my mind and gather my courage, I finally be able to put some ideas into my writing, starting with this re-introduction.

This blog actually planned to be a place where I keep my documentation about thing that I have been thinkering with. But I think I was too strict. Why don't I write anything I want to write here? This is my personal blog after all. So, I think it is wiser to share any good things with folks from internet here. As a system administrator which also want to be a developer, I think having a blog to write about your project or anything you get in touch is essential. It keeps a record about your projects and also can be a source of help for someone working the same projects out there.

Okay, I think this is all from me now. We will catch up again real soon, I hope.

Puppet Master-Agent Installation on FreeBSD

Puppet is a software which can automate configuration and management of machines and software running on them. This tool has great benefits for system administrator because it helps sysadmin to be the dream of every sysadmin, a lazy sysadmin. Puppet has great support for many operating system. Unfortunately its installation on my favourite OS, FreeBSD, is not so smooth. An introduction of Puppet installation which I found in BSD Magazine January 2012 edition is a starting point but I have to make some modification due to some of deprecated configurations. So, here I want to show you how to install and configure the basic of Puppet in FreeBSD in its master-agent scenario.

Let's start...

Puppet benefits:

  1. automated server installation
  2. mass deployment of changes to servers
  3. maintain server state consistency

Puppet scenario: 0. FreeBSD (master)

  1. FreeBSD (agent)

FreeBSD initial:

update ports

# portsnap fetch extract
# portsnap fetch update

install portmaster via ports

# cd /usr/ports/ports-mgmt/portmaster
# make install clean
# rehash

switch to pkgng

# portmaster -dB ports-mgmt/pkg

convert package database to new pkgng format

# pkg2ng

use pkgng by default

# echo 'WITH_PKGNG=yes' >> /etc/make.conf

define new repository for pkgng

# mkdir -p /usr/local/etc/pkg/repos
# cat << 'EOF' > /usr/local/etc/pkg/repos/FreeBSD.conf
 FreeBSD: {
     url: "http://pkg.FreeBSD.orf/${ABI}/latest",
        mirror_type: "srv",
     enabled: true
    }
 EOF
# pkg update

test pkgng

# pkg install sl
# sl

Puppet master initial:

IMPORTANT: Puppet requires FQDN hostname install from ports

# cd /usr/ports/sysutils/puppet
# make install clean

generate puppet configuration file

# puppet master --genconfig > /usr/local/etc/puppet/puppet.conf

copy auth.conf-dist to auth.conf

# cp /usr/local/etc/puppet/auth.conf-dist /usr/local/etc/puppet/auth.conf

some "red" warnings when run puppet help

Warning: Setting manifestdir is deprecated. See http://links.puppetlabs.com/env-settings-deprecations
   (at /usr/local/lib/ruby/site_ruby/1.9/puppet/settings.rb:1095:in `block in issue_deprecations')
Warning: Setting manifest is deprecated in puppet.conf. See http://links.puppetlabs.com/env-settings-deprecations
   (at /usr/local/lib/ruby/site_ruby/1.9/puppet/settings.rb:1095:in `block in issue_deprecations')
Warning: Setting modulepath is deprecated in puppet.conf. See http://links.puppetlabs.com/env-settings-deprecations
   (at /usr/local/lib/ruby/site_ruby/1.9/puppet/settings.rb:1095:in `block in issue_deprecations')
Warning: Setting templatedir is deprecated. See http://links.puppetlabs.com/env-settings-deprecations
   (at /usr/local/lib/ruby/site_ruby/1.9/puppet/settings.rb:1095:in `block in issue_deprecations')

skeleton files creation

# mkdir -p /usr/local/etc/puppet/files
# mkdir -p /usr/local/etc/puppet/manifests
# touch /usr/local/etc/puppet/fileserver.conf
# touch /usr/local/etc/puppet/files/sudoers
# touch /usr/local/etc/puppet/manifests/site.pp
# touch /usr/local/etc/puppet/environments/production/environment.conf
# touch /usr/local/etc/puppet/environments/production/manifests/site.pp

edit puppet.conf

[main]
    environmentpath = /usr/local/etc/puppet/environments
[master]
    #manifestdir = /usr/local/etc/puppet/manifests
    #manifest = /usr/local/etc/puppet/manifests/site.pp
    #modulepath = /usr/local/etc/puppet/modules:/usr/share/puppet/modules
    #templatedir = /var/puppet/templates
    pluginsource = puppet://puppetmaster.domain/plugins
    pluginfactsource = puppet://puppetmaster.domain/pluginfacts

edit fileserver.conf

[files]
    path /usr/local/etc/puppet/files
    allow *.domain

edit environments/production/environment.conf

modulepath = /usr/local/etc/puppet/modules:/usr/share/puppet/modules
manifest = /usr/local/etc/puppet/environments/production/manifests/site.pp
### EXPERIMENTAL ###
#config_version = get_environment_commit.sh
#environment_timeout = 5s

edit environments/production/manifests/site.pp

class sudoers {
        file { "/usr/local/etc/sudoers":
                ensure  => file,
                owner   => root,
                group   => wheel,
                mode    => 440,
                source  => "puppet://puppetmaster.domain/files/sudoers",
        }
}

node 'puppetclient.domain' {
        include sudoers
}

start puppet master

# echo 'puppetmaster_enable="YES"' >> /etc/rc.conf
# /usr/local/etc/rc.d/puppetmaster start

sign the certificate when agent initiate a certificate signing session # puppet cert --list --all # puppet cert --sign puppetagent.domain

edit files/sudoers

root ALL=(ALL) ALL

update puppet agents using kick

# puppet kick puppetagent.domain

Puppet agent initial:

IMPORTANT: Puppet requires FQDN hostname install from ports # cd /usr/ports/sysutils/puppet # make install clean

configure hostname

# hostname puppetagent.domain

create and edit new auth.conf

path /run
method save
allow puppetmaster.domain

initiate a certificate signing session from agent to master and wait to be signed and automatically closed

# puppet agent -v --server puppetmaster.domain --waitforcert 60 --test

enable puppet agent on rc.conf

# echo 'puppet_enable="YES"' >> /etc/rc.conf
# echo 'puppet_flags="-v --listen --server puppetmaster.domain"' >> /etc/rc.conf

start puppet agent

# /usr/local/etc/rc.d/puppet start

inspect /usr/local/etc/sudoers after puppet master kicked some changes

# less /usr/local/etc/sudoers

Puppet problems:

cannot connect to https://forge.puppetlabs.com

security/ca_root_nss port needed to be installed with ETCSYMLINK turned on

puppet kick and --listen flag is deprecated still can't find good configuration for using sysutils/mcollective-puppet-agent as alternative


References: http://www.iceflatline.com/2013/02/how-to-use-portmaster-to-update-ports/ http://www.fitzdsl.net/2013/11/utiliser-pkgng-sous-freebsd-avec-puppet/ https://mebsd.com/make-build-your-freebsd-word/pkgng-first-look-at-freebsds-new-package-manager.html https://forums.freebsd.org/viewtopic.php?&t=36732 http://www.6tech.org/2013/01/how-to-install-puppet-open-source-on-centos-6-3/ https://github.com/puppetlabs-operations/puppet-freebsd