Manage KVM (QEMU) with Kimchi (web interface)

 Solution  Comments Off on Manage KVM (QEMU) with Kimchi (web interface)
Sep 072015
 

Kimchi Logo

Kimchi is a HTML5 based web interface for KVM. It is provides easy and flexible interface to create and manage a guest virtual machines. Kimchi is installed and runs as a daemon on the KVM host. It manages KVM guests with the help of libvirt. Kimchi interface supports all latest version of the browsers with -1 version, it also supports mobile browsers.

Kimchi can be installed on latest version of RHEL, Fedora, openSUSE and Ubuntu. In this guide, i used Ubuntu 14.10 as a KVM host.

Before configuring kimchi, you must install the following dependent packages.

$ sudo apt-get install gcc make autoconf automake gettext git python-cherrypy3 python-cheetah python-libvirt  libvirt-bin python-imaging python-pam python-m2crypto python-jsonschema qemu-kvm libtool python-psutil python-ethtool  sosreport python-ipaddr python-ldap python-lxml nfs-common open-iscsi lvm2 xsltproc  python-parted nginx firewalld python-guestfs libguestfs-tools python-requests websockify novnc spice-html5 wget

System would ask you the following details during the installation of packages.

1. OK on Postfix configuration.

2. Select Internet Site on general type of mail configuration.

3. Type your FQDN and then select OK.

Once installed, download the latest version of kimchi from github.

 $ wget https://github.com/kimchi-project/kimchi/archive/master.zip

Unzip the downloaded file.

$ unzip master.zip
$ cd kimchi-master/

Build kimchi using the following command.

$ ./autogen.sh --system

Install.

$ make
$ sudo make install   # Optional if running from the source tree

Run kimchi.

 $ sudo kimchid --host=0.0.0.0

Access kimchi using web browser, https://localhost:8001. You would be asked to login, use your system credential which you normally use for login to system.

Kimchi Login Page
Kimchi Login Page

Once you logged in, you will get a page like below. This show the list of running guest virtual machines on current host, you have buttons to perform shutdown, restart and connect to console by clicking on action.

Kimchi guest virtual machines
Kimchi guest virtual machines

To create a new guest machine, click on the + sign in the right corner. If you use this option to create a machine, it will be done through templates.

Kimchi Creating Virtual Machine
Kimchi Creating Virtual Machine

You can manage templates by visiting templates menu. To create a new template, click on the + sign in the right corner. You can create a template using ISO images, you can place iso images on /var/lib/kimchi/isos or use remote one.

Kimchi Creating Template
Kimchi Creating Template

You can manage storage pool by going to storage menu, there you can add a new storage by clicking on + sign. It supports adding NFS, iSCSI and SCSI fibre channel storage.

Kimchi Storage Management
Kimchi Storage Management

Network can be managed by going to network menu, you can create a new network with isolated, NAT and bridged networking.

Kimchi Networking
Kimchi Networking

That’s All.

 

How to install Elasticsearch, Logstash and Kibana 4 on Ubuntu 14.04 / 15.04

 Solution  Comments Off on How to install Elasticsearch, Logstash and Kibana 4 on Ubuntu 14.04 / 15.04
Sep 072015
 
ELK Stack
ELK Stack

In this post, will look how to install Elasticsearch, Logstash and Kibana 4 on Ubuntu 14.04 / 15.04. This ELK stack help us to store and manage the logs in a centralized location. ELK stack consists of four vital components that makes a wonderful stack to analyze the problems by correlating the events on a particular time.

Centralizing logs will make a system admin life easier to analyze the problems and issues without going to each machine for logs, and visualize those logs to management for business requirements.

Components:

Logstash – It does the processing (Collect, parse and send it to Elasticsearch) of incoming logs.

Elasticsearch – Stores the logs coming from Logstash.

Kibana 4 – Web interface for visualizing the logs (has an own interface). The above three are installed on server.

Logstash-forwarder – Installed on client machines, sends log to Logstash through lumberjack protocol.

Application versions:

This article uses below version of softwares for ELK stack.

Elastisearch 1.7.0

logstash-1.5.3

Kibana 4.1.1

logstash-forwarder-0.4.0

Prerequisites:

1. We would require to install either openJDK or Oracle JDK, It is recommended to install Oracle JDK.Verify the java version by using the following command.

$ java -version

java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)

2. Install wget.

$ sudo su -
# apt-get update
# apt-get install wget

Install Elasticsearch:

Elasticsearch is an open source search server, it offers a realtime distributed search and analytics with RESTful web interface. Elasticsearch stores all the logs sent by the logstash server and displays the messages when the kibana4 requests for full filling user request over the web interface.

This topic covers configuration settings that is required for ELK, you can also take a look on Install Elasticsearch on CentOS 7 / Ubuntu 14.10 / Linux Mint 17.1 for detailed instruction.

Let’s install the Elasticsearch, it can be downloaded from official website. Setup repository and install the latest version of Elasticsearch.

# wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -

# echo "deb http://packages.elastic.co/elasticsearch/1.7/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-1.7.list

# apt-get update && apt-get install elasticsearch

Configure Elasticsearch to start during system startup.

# systemctl daemon-reload
# systemctl enable elasticsearch.service
# systemctl start elasticsearch.service

Wait, at least a minute to let the Elasticsearch get fully restarted, otherwise testing will fail. Elastisearch should be now listen on 9200 for processing HTTP request, we can use CURL to get the response.

# curl -X GET http://localhost:9200
{
  "status" : 200,
  "name" : "Thermo",
  "cluster_name" : "elasticsearch",
  "version" : {
    "number" : "1.7.0",
    "build_hash" : "929b9739cae115e73c346cb5f9a6f24ba735a743",
    "build_timestamp" : "2015-07-16T14:31:07Z",
    "build_snapshot" : false,
    "lucene_version" : "4.10.4"
  },
  "tagline" : "You Know, for Search"
}

Install Logstash:

Logstash is an open source tool, used for collecting logs, parsing and storing them searching. Yes, logstash comes with a web interface (kibana3 is built-in) for visualizing logs which we are not going to discuss here instead we use kibana4. Processing of various types of events can be extended by adding plugins to it, over 160 plugins are available as of now. Lets will go directly to the installation.

# echo "deb http://packages.elasticsearch.org/logstash/1.5/debian stable main" | sudo tee -a /etc/apt/sources.list

# apt-get update && apt-get install logstash

Once the logstash server is installed, lets move on to next section

Create SSL certificate:

Logstash-forwarder which will be installed on client-server to ship the logs requires SSL certificate to validate identity of logstash server. We have a two options to create a SSL certificate and it depends on logstash-forwarder configuration; if you use hostname ( “servers”: [ “server.itzgeek.local:5050″ ]), subject name of SSL should match “server.itzgeek.local”. If you use ( “servers”: [ “192.168.12.10:5050″ ]) an ip address, you must create a SSL certificate with IP SAN with value 192.168.12.10.

Follow any one of the method to create a SSL certificate.

Option 1: (Hostname FQDN)

Before creating a certificate, make sure you have A record for logstash server; ensure that client servers are able to resolve the hostname of the logstash server. If you do not have DNS, kindly add the host entry for logstash server; where 192.168.12.10 is the ip address of logstash server and itzgeek is the hostname of your logstash server.

# vi /etc/hosts

192.168.12.10 server.itzgeek.local

Lets create a SSl certificate. Go to OpenSSL directory.

# cd /etc/ssl/

Execute the following command to create a SSL certificate, replace “red” one in with your real logstash server.

# openssl req -x509 -nodes -newkey rsa:2048 -days 365 -keyout logstash-forwarder.key -out logstash-forwarder.crt -subj /CN=server.itzgeek.local

Option 2: (IP Address)

Before creating a SSL certificate, we would require to an add ip address of logstash server to SubjectAltName in the OpenSSL config file.

# vi /etc/pki/tls/openssl.cnf

Goto “[ v3_ca ]” section and replace “red” one with your logstash server ip.

subjectAltName = IP:192.168.12.10

Goto OpenSSL directory.

# cd /etc/ssl/

Execute the following command to create a SSL certificate.

# openssl req -x509 -days 365 -batch -nodes -newkey rsa:2048 -keyout logstash-forwarder.key -out logstash-forwarder.crt

This logstash-forwarder.crt should be copied to all client servers those who send logs to logstash server.

Configure Logstash:

Logstash configuration files can be found in /etc/logstash/conf.d/, just an empty folder. We would need to create a file, logstash configuration files consist of three section input, filter and output; all three section can be found either in single file or each section will have separate file ends with .conf.

Here we will use a single file to place an input, filter and output sections.

# vi /etc/logstash/conf.d/logstash.conf

In the first section, we will put an entry for input configuration. The following configuration sets lumberjack to listen on port 5050 for incoming logs from the logstash-forwarder that sits in client servers, also it will use the SSL certificate that we created earlier.

input {
lumberjack {
port => 5050
type => "logs"
ssl_certificate => "/etc/ssl/logstash-forwarder.crt"
ssl_key => "/etc/ssl/logstash-forwarder.key"
}
}

In the second section, we will put an entry for filter configuration. Grok is a filter in logstash, which does parsing of logs before sending it to Elasticsearch for storing. The following grok filter will look for the logs that are labeled as ‘syslog” and tries to parse them to make a structured index.

filter {
if [type] == "syslog" {
    grok {
      match => { "message" => "%{SYSLOGLINE}" }
    }

    date {
match => [ "timestamp", "MMM  d HH:mm:ss", "MMM dd HH:mm:ss" ]
}
  }

}

Consider visiting grokdebugger for filter patterns.

In the third section, we will put an entry of output configuration. This section defines location where the logs get stored; obviously it should be Elasticsearch.

output {
elasticsearch { host => localhost index => "logstash-%{+YYYY.MM.dd}" }
stdout { codec => rubydebug }
}

Now start the logstash service.

# systemctl start logstash.service

Logstash server logs are stored in the following file, will help us to troubleshoot the issues.

# cat /var/log/logstash/logstash.log

Next we will configure a logstash-forwarder to ship logs to logstash server.

Configure Logstash-forwarder.

Logstash-forwarder is a client software which ship logs to a logstash server, it should be installed on all client servers. Logstash-forwarder can be downloaded from official website or you can use the following command to download it in terminal and install it.

# wget https://download.elastic.co/logstash-forwarder/binaries/logstash-forwarder_0.4.0_amd64.deb

# dpkg -i logstash-forwarder_0.4.0_amd64.deb

Logstash-forwader uses SSL certificate for validating logstash server identity, so copy the logstash-forwarder.crt that we created earlier from the logstash server to the client.

# scp -pr [email protected]://etc/ssl/logstash-forwarder.crt /etc/ssl

Open up the configuration file.

# vi /etc/logstash-forwarder.conf

In the “network” section, mention the logstash server with port number and path to the logstash-forwarder certificate that you copied from logstash server.

This section defines the logstash-forwarder to send a logs to logstash server “server.itzgeek.local” on port 5050 and client validates the server identity with the help of SSL certificate. Note: Replace “server.itzgeek.local” with ip address incase if you are using IP SAN.

"servers": [ "server.itzgeek.local:5050" ],

"ssl ca": "/etc/ssl/logstash-forwarder.crt",

"timeout": 15

In the “files” section, configures what all are files to be shipped. In this article we will configure a logstash-forwarder to send a logs (/var/log/syslog) to logstash server with “syslog” as type.

{
"paths": [
"/var/log/syslog"
],

"fields": { "type": "syslog" }
}

Restart the service.

# systemctl start logstash-forwarder.service

You can look at a log file in case of any issue.

# cat /var/log/logstash-forwarder/logstash-forwarder.err

Configure Kibana 4:

Kidbana provides visualization of logs, download it from official website. Use following command to download it in terminal.

# wget https://download.elastic.co/kibana/kibana/kibana-4.1.1-linux-x64.tar.gz

Extract and move it to /opt/

# tar -zxvf kibana-4.1.1-linux-x64.tar.gz

# mv kibana-4.1.1-linux-x64 /opt/kibana4

Enable PID file for Kibana, this is required to create a systemd init file.

# sed -i 's/#pid_file/pid_file/g' /opt/kibana4/config/kibana.yml

Kibana can be started by running /opt/kibana4/bin/kibana, to run kibana as a server we will create a systemd file.

# vi /etc/systemd/system/kibana4.service

[Unit]
Description=Kibana 4 Web Interface
After=elasticsearch.service
After=logstash.service
[Service]
ExecStartPre=/bin/rm -rf /var/run/kibana.pid
ExecStart=/opt/kibana4/bin/kibana
ExecReload=/bin/kill -9 $(cat /var/run/kibana.pid) && /bin/rm -rf /var/run/kibana.pid && /opt/kibana4/bin/kibana
ExecStop=/bin/kill -9 $(cat /var/run/kibana.pid)
[Install]
WantedBy=multi-user.target

Start and enable kibana to start automatically at system startup.

# systemctl start kibana4.service

# systemctl enable kibana4.service

Access your kibana portal by visiting the following link

http://your-ip-address:5601/

You will get a following page where you have to map logstash index to use kibana. Scroll down on Time-field name and select

@timestamp
Install Elasticsearch, Logstash and Kibana 4 on Ubuntu 14.04 - Index Pattern
Install Elasticsearch, Logstash and Kibana 4 on Ubuntu 14.04 – Index Pattern

Once you selected, it will redirect you to kibana main page.

 

Install Elasticsearch, Logstash and Kibana 4 on Ubuntu 14.04 - Kibana Discover the Logs
Install Elasticsearch, Logstash and Kibana 4 on Ubuntu 14.04 – Kibana Discover the Logs

Kibana does not comes with any kind of password protected access to portal. With Nginx, we can configure in such a way that the user should fulfill authentication mechanism before entering to portal.

That’s All, you have successfully configured ELK stack for centralized log management.

Install Tonido private cloud server on Ubuntu 14.04.3 / 15.04

 Solution  Comments Off on Install Tonido private cloud server on Ubuntu 14.04.3 / 15.04
Sep 072015
 
Tonido private cloud server
Tonido private cloud server

Tonido is a free application server that helps you to access all your files on your Linux server / machine from a web browser, smart phone, tablet, and even from DLNA enabled devices. Also, you can share them with your family, friends and colleagues. Configure public direct links so that anyone can access the content, additionally, you can create a secure private share to only allow authorized people to access them.

With Tonido, you can stream your Media such as Photos, Audios, and Videos to any devices on your network. It works on Windows, Linux, Mac and all major mobile phones and tablets including iPhone, iPad, Android, Windows Phone 8 and Blackberry. Tonido can also be used to take backup photos / videos from phone to your desktop.

Please note that, Tonido comes in two version, free for SOHO user, and paid for enterprise. In free version, you are allowed to have a custom logo, branding, and identity.

Prerequisites:

Install below dependent packages for Tonido.

$ sudo apt-get install libjpeg8 libfontconfig

Installing Tonido:

Here we will be using free version of Tonido. Please follow below instructions to install tonido on Ubuntu 64 bit, detailed instruction on installing Tonido on 32 bit can be found here.

Lets install curl, we will use this for downloading Tonido using terminal.

$ sudo apt-get update

$ sudo apt-get install curl

Create a directory for Tonido installation.

$ sudo mkdir /usr/local/tonido

Go to that directoryt and download the free version of Tonido from official website.

$ cd /usr/local/tonido
$ sudo curl -o tonido64.tar.gz  http://www.tonido.com/download.php?tonido64.tar.gz

Extract the tar file using below command.

$ sudo tar -zxvf tonido64.tar.gz

Now, run Tonido using command.

$ sudo ./tonido.sh start

Troubleshooting:

If Tonido service is not starting or not listening on port 10001, go through the Tonido logs for any errors.

$ cat /tmp/tonido_<accountname>.log

Configure Tonido:

After starting Tonido, open up your web browser and navigate to http://127.0.0.1:10001 or http://ip-add-ress:10001. You should get a below screen.

Now, create a local account. Enter the account name of your choice, password and email id.

Install Tonido - Create a Account
Install Tonido – Create an Account

Your remote access server will be created now, URL will look like.

http://<accountname>.tonidoid.com
Install Tonido - Remote Server URL
Install Tonido – Remote Server URL

Select the folders that can be accessed remotely via Tonido, you can change these settings later.

Install Tonido - Remote Access and Sharing
Install Tonido – Remote Access and Sharing

Select the folders to index Music, Photos and Video collection.

Install Tonido - Indexing Media Files
Install Tonido – Indexing Media Files

Install the mobile apps for iOS, Android, Windows phone and get access to all your collections. Click on Close to finish the installation.

Install Tonido - Mobile Apps
Install Tonido – Mobile Apps

Now, you will be redirected to your Tonido dashboard.

Install Tonido - DashBoard
Install Tonido – DashBoard

You can upload your files / Music / Videos by clicking on the upload button.

Once you have uploaded the media files, have to manually index those files by going to Settings –> Misc –> Index Now.

Install Tonido - Manual Indexing
Install Tonido – Manual Indexing

Wait for a minute to get indexing completed, you can play videos by going to Videos section.

Install Tonido - Playing Videos
Install Tonido – Playing Videos

You can share files/folders to your friends, family, and colleagues or to a particular person. To do that, go to Shared files section, click on New Share button and select the file / folder you want to share.

Install Tonido - Sharing File
Install Tonido – Sharing File

Also, you can share this file to a particular person.

Install Tonido - Sharing Files Permission
Install Tonido – Sharing Files Permission

If you want to sync files/folders to multiple systems, you can install the Tonido sync tool. Click the Account name drop-down box, and select Tonido Sync. Since I am using desktop, I selected the Desktop application.

Install Tonido - Sync Files
Install Tonido – Sync Files

You will be redirected to the Tonido sync download page. Select and download the Sync app depending upon your operating system.

You can configure app to sync files / folders from your desktop to Tonido.

Auto Start:

Copy the Tonido script to /etc/init.d directory.

$ sudo cp /usr/local/tonido/tonido.sh /etc/init.d/tonido

Make the service script to run as service at every boot.

$ sudo update-rc.d tonido defaults

To remove the tonido script.

$ sudo update-rc.d tonido remove

To start the script.

$ sudo service tonido start

For further, I suggest you to read comprehensive usage guide from Tonido site.

That’s All!!!, you have successfully configured Tonido private cloud server on Ubuntu 14.04 / 15.04.

Register clients with SpaceWalk Server

 Solution  Comments Off on Register clients with SpaceWalk Server
Sep 072015
 
Install Spacewalk
Spacewalk

This is the third part of Spacewalk installation and configuration series. In the first two parts, we gone through how to install and configure Spacewalk server and managing Spacewalk channels and repositories.

  1. Install And Configure Spacewalk In CentOS 7
  2. Managing Spacewalk Channels And Repositories

In this tutorial, we will configure clients to take installation packages from the Spacewalk server by registering it with Spacewalk server.

Environment:

OS : CentOS Linux release 7.0.1406 (Core)

Hostname : client.itzgeek.local

IP Address : 192.168.12.4

Install Spacewalk clients:

CentOS Base repository does not have packages that are required for registering clients with Spacewalk server, so we would require to configure Spacewalk repo on client machine.

# rpm -Uvh http://yum.spacewalkproject.org/2.3-client/RHEL/7/x86_64/spacewalk-client-repo-2.3-2.el7.noarch.rpm

Install below packhttp://www.itzgeek.com/wp-admin/post.php?post=9265&action=editage.

# yum install yum-rhn-plugin

Once the packages are installed, proceed to register the clients with spacewalk server.

Register clients with SpaceWalk Server:

It is recommended to use activation keys for registering and configuring client systems with Spacewalk server.

Now, login to Spacewalk server and get an activation that we created in previous tutorial.

Goto System –> Activation Keys.

Register clients with SpaceWalk Server - Activation Keys
Register clients with SpaceWalk Server

On client system’s Terminal, run the following command to register it to the Spacewalk server.

# rhnreg_ks --activationkey 1-3de95eb8d397e65b3831910fdc3e3f61 --serverUrl https://server.itzgeek.local/XMLRPC

Once the above command is executed, goto Spacewalk console, and click on Systems. You will see our client system that we just registered with Spacewalk.

Register Clients with Spacewalk server - System Overview
Register Clients with Spacewalk server – System Overview

Click on client name, you will be taken to client summary page where you can see detailed information about registered client (client.itzgeek.local). You can see that this system has subscribed automatically to base channel (itzgeek_centos7).

Register Clients with Spacewalk server - Client Overview
Register Clients with Spacewalk server – Client Overview

Modifying Subscription (Optional):

GUI Mode:

If you want to make a use of child channels (Ex. To install Nginx), To enable the child channels of the base channel to get Niginx packages.

Go to Systems –> <Your Client> –> Software –> Software Channels –> Software Channel Subscriptions.

OR

Click on Alter Subscription Channels on client over page.

Select the Child channels (Ex. nginx_centos7) and click Change Subscriptions.

Register Clients with Spacewalk server - Change Channel subscription
Register Clients with Spacewalk server – Change Channel subscription

Now, client system is successfully subscribed to Nginx child channel.

Register Clients with Spacewalk server - Subscripton List
Register Clients with Spacewalk server – subscription List

Command Line Mode:

You can also change channel subscription using command Line. To list subscribed channels, run.

# rhn-channel -l

sample output:

itzgeek_centos7

To list the available channels, run.

# rhn-channel -L

sample output:

Username: itzgeek
Password:
nginx_centos7

Now, to subscribe to child channel, run.

# rhn-channel -a -c nginx_centos7

You will have to enter username and password of Spacewalk server admin account.
Veryify the subscription using below command.

# rhn-channel -l

sample output:

itzgeek_centos7
nginx_centos7

If you want to remove child channel subscriptions, run the following command.

# rhn-channel -r -c nginx_centos7

That’s it.  You can start to install or update packages from the Spacewalk server. Also, make sure that you have disabled non-Spacewalk repositories.

To do that, run:

# sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/*

To test, install Nginx package on client machine.

# yum install nginx

Sample output:

Loaded plugins: fastestmirror, rhnplugin
This system is receiving updates from RHN Classic or Red Hat Satellite.
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package nginx.x86_64 1:1.8.0-1.el7.ngx will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package      Arch          Version                  Repository            Size
================================================================================
Installing:
nginx        x86_64        1:1.8.0-1.el7.ngx        nginx_centos7        369 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 369 k
Installed size: 889 k
Is this ok [y/d/N]:

[...]

If you see the above output, the packages are installed from Spacewalk child channel (nginx_centos7).

That’s All. You have successfully registered client systems with Spacewalk server for packages.I plan to cover more topics on Spacewalk server, stay tuned.

Managing Channels and Repositories – Spacewalk on CentOS 7 / RHEL 7

 Solution  Comments Off on Managing Channels and Repositories – Spacewalk on CentOS 7 / RHEL 7
Sep 072015
 
Install Spacewalk
Install Spacewalk

This is the continuation from installing and Configuring SpaceWalk on CentOS 7. This tutorial will show you how to configure Spacewalk to distribute updates for CentOS or RHEL clients.This is a simple step by step process, so i will only mention minimal settings to be done for distributing updates.

Spacewalk Channels:

Channel is nothing but a collection of software packages. A channel may contain packages from a specific distribution, also it may contain packages for an application or family of applications. Users may also define channels.

Any client can subscribe to a particular channel to download, update, install packages. The channels are linked to upstream server (a normal YUM repository). A channel may have linked to multiple repositories, can be cloned, sync or customized.

There are two types of channels:

1.Base channels

2. Child channels

A base channel consists of packages based on a specific architecture and Red Hat Enterprise Linux release. A child channel is a channel associated with a base channel that contains extra packages. A system must be subscribed to only one base channel. A system can be subscribed to multiple child channels of its base channel. A subscribed system can only install or update packages available through its Satellite channels.

Create a Base Channel:

Login to Spacewalk web console, https://spacewalk-server-ip. Enter user name and password that you defined in previous tutorial.

Goto Channels –> Manage Software Channels –> Create New Channel.

Managing Channels and Repositories - Create Base Channel
Managing Channels and Repositories – Create Base Channel

This is where you can label your different type of architecture. Here i created label “itzgeek_centos7” for CentOS 7 packages, same like you can create label for other architectures and other Linux flavors, label name does not matter; only architecture is important while configuring.

Managing Channels and Repositories - Base Channel Details
Managing Channels and Repositories – Base Channel Details

Create a repository:

Goto Channels –> Manage Software Channels –> Manage Repositories –> Create repository.

Managing Channels and Repositories - Create a Repository
Managing Channels and Repositories – Create a Repository

Here you can mention upstream server from where Spacewalk server will download the updated packages for clients. To show you a demo, i used http://mirror.supremebytes.com/centos/7/os/x86_64/as Repository URL. This repository URL is one of CentOS mirror, you can find more mirrors here.

Managing Channels and Repositories - Repository Detail
Managing Channels and Repositories – Repository Detail

Assigning a repository to Base channel:

Goto Channels –> Manage Software Channels –> Select the created channel (itzgeek_centos7) –> Repository –> Select the previously created repository –> Update repository.

Managing Channels and Repositories - Adding Repository to Base Channel
Managing Channels and Repositories – Adding Repository to Base Channel

Now its time to sync packages from upstream server, Go to Channels –> Manage Software Channels –> Select the created channel –> Repository –> Sync –> Sync Now.

Managing Channels and Repositories - Sync Base Channel
Managing Channels and Repositories – Sync Base Channel

or

Run below command to sync with upstream server.

# /usr/bin/spacewalk-repo-sync --channel  itzgeek_centos7 --type yum

You can go through sync logs to troublehoot any issues arise during the synchronization.

# cat /var/log/rhn/reposync/reponame.log

Note: The packages will be downloaded from the upstream server will be kept in /var/satellite/ folder of your Spacewalk server. Make sure you have enough space in /var/satellite/ folder.

Once the package synchronization is completed, you can list the packages by going to Channels –> Manage Software Channels –> Select your channel –> Packages –> List / Remove.

Managing Channels and Repositories - Channel Packages
Managing Channels and Repositories – Channel Packages

Create Activation Key:

Goto Systems –> Activation Keys –> Create New Key.

Managing Channels and Repositories -Activation Keys
Managing Channels and Repositories -Activation Keys

Here you can create a activation keys for client subscription, in this page you need to select the base channel ( itzgeek_centos7).

Whenever any client uses this key, the client machine will be automatically subscribed to the created channel. You can create multiple keys; in case you would like to use multiple channels.

Note: Better to leave the key blank for automatic generation.

Managing Channels and Repositories -Create Activation Key
Managing Channels and Repositories -Create Activation Key

You can get a list of activation key by going to Systems –> Activation Keys.

Managing Channels and Repositories - All Activation Keys
Managing Channels and Repositories – All Activation Keys

Creat a Child Channel:

Goto Channels –> Manage Software Channels –> Create New Channel. Enter the Child channel name, label, Parent channel, Architecture, and Channel description etc. Here you must select the Parent channel from the drop down list. Finally, click Create Channel button.

Managing Channels and Repositories - Create a child channel
Managing Channels and Repositories – Create a child channel

Creat a Repository for Child Channel:

Goto Channels –> Manage Software Channels –> Manage Repositories –> Create repository.

Let us create a Nginx repository, Enter the repository name and actual URL.

You can create your own repository.

Managing Channels and Repositories - Create a Nginx repository
Managing Channels and Repositories – Create a Nginx repository

Assigning a repository to Child channel:

Goto Channels –> Manage Software Channels –> Select the child channel.

Managing Channels and Repositories - Adding repository to Child Channel
Managing Channels and Repositories – Adding repository to Child Channel

Goto Repository (TAB) –> Select the created repository (Nginx) –> Update repository.

Managing Channels and Repositories - Adding repository to Child Channel - Updating respoitory
Managing Channels and Repositories – Adding repository to Child Channel – Updating respoitory

In same page, goto Sync (TAB) –> Sync Now or Select a schedule.

Managing Channels and Repositories - Adding repository to Child Channel - Sync
Managing Channels and Repositories – Adding repository to Child Channel – Sync

or

Run below command.

/usr/bin/spacewalk-repo-sync --channel nginx_centos7 --type yum

You can go through sync logs to troubleshoot any issues arise during the synchronization.

# cat /var/log/rhn/reposync/reponame.log

At this stage your Spacewalk server is almost ready to serve packages to the clients.

That’s all. The next tutorial will be on configuring client to use Spacewalk server for updates.

How to install SpaceWalk on CentOS 7 / RHEL 7

 Solution  Comments Off on How to install SpaceWalk on CentOS 7 / RHEL 7
Sep 072015
 
Install Spacewalk
Install Spacewalk

Spacewalk is an open source package and system management solution for RedHat derivative distributions like CentOS, Scientific Linux and Fedora, developed by the spacewalk community. Spacewalk is the upstream project for the source of ​Red Hat Satellite, It is released under GPLv2 license.

Spacewalk provides the web interface to manage and view the updates for the system that are registered with Spacewalk, we can initiate the task such as install, update, inventory, and so on. Here is the small tutorial about installing Spacewalk on CentOS 7 / RHEL 7.

Features:

  • Inventory of the systems
  • Install and Update system packages.
  • Configuring Kick-start installation.
  • Deploy and Manage the configuration files from singe location
  • Start / Stop / Configure the guests.
  • Distribute the content across the multiple Geo graphical location using spacewalk proxy.

Prerequsites

  • Outbound open ports 80, 443
  • Inbound open ports 80, 443, 5222 (only if you want to push actions to client machines) and 5269 (only for push actions to a Spacewalk Proxy), 69 udp if you want to use tftp
  • Storage for database: 250 KiB per client system + 500 KiB per channel + 230 KiB per package in channel (i.e. 1.1GiB for channel with 5000 packages)
  • Storage for packages (default /var/satellite): Depends on what you’re storing; Red Hat recommend 6GB per channel for their channels
  • 2GB RAM minimum, 4GB recommended
  • Underlying (SpaceWalk Server) OS is fully up-to-date.

Environment:

HostName :  server.itzgeek.local

IP Address : 192.168.12.3

OS : CentOS Linux release 7.1.1503 (Core)

Setup Repositories:

Before installing Spacewalk on CentOS, we must configure required repositories for Spacewalk setup.

Lets first setup Spacewalk repository, at the time of writing, latest available Spacewalk version was 2.3.

rpm -Uvh http://yum.spacewalkproject.org/2.3/RHEL/7/x86_64/spacewalk-repo-2.3-4.el7.noarch.rpm

Setup Jpackage Repo:

vi /etc/yum.repos.d/jpackage-generic.repo

Add the following.

[jpackage-generic]
name=JPackage generic
#baseurl=http://mirrors.dotsrc.org/pub/jpackage/5.0/generic/free/
mirrorlist=http://www.jpackage.org/mirrorlist.php?dist=generic&type=free&release=5.0
enabled=1
gpgcheck=1
gpgkey=http://www.jpackage.org/jpackage.asc

Setup EPEL repo on CentOS 7.

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

Your Spacewalk server should have a resolvable fully-qualified domain name (FQDN) such as “hostname.domain.com”, to do that; edit /etc/hosts file.

vi /etc/hosts

Modify it according to your environment.

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
# Your Spacewalk Server
192.168.12.3 server.itzgeek.local server

Configure Firewall:

As said in the prerequisites, we need to have outbound port opened. Run the following on terminal to allow the required ports.

firewall-cmd --add-service=http ; firewall-cmd --add-service=https

Add port 5222 if you want to push actions to client machines and 5269 for push actions to a Spacewalk Proxy, 69 udp if you want to use tftp.

Restart firewall service using command:

firewall-cmd --reload

SpaceWalk Database:

SpaceWalk supports PostgreSQL (version 8.4 or higher) or Oracle ( version 10g or higher) as a database for storing its data.

Embedded Database:

Spacewalk has the embedded setup for PostgrSQL database which will do the automatic Spacewalk installation without having user intervention to enter the database information. Embedded database method is very easy to setup and run the Spacewalk in no time; this is very useful for those who do not have any database knowledge.

yum install spacewalk-setup-postgresql

External Database:

You can use the external PostgreSQL or Oracle database to install Spacewalk, you can find the tons of documents online to setup database.

Installing SpaceWalk:

If you are planning use PostgreSQL database (Either Embedded or External PostgreSQL database).

yum install spacewalk-postgresql

If you are planning to use Oracle database.

yum install spacewalk-oracle

Configuring SpaceWalk:

If you have installed embedded database, then use below command. It will ask you to enter the admin mail and organization details to generate the self signed certificate for secured access.

spacewalk-setup --disconnected

if you have setup database manually, then use below commands depend on database type. It will ask you to enter external database details.

Oracle:

spacewalk-setup --disconnected --external-oracle

PostgreSQL:

spacewalk-setup --disconnected --external-postgresql

Since i am using embedded postgresql database, an example session is as follows;

# spacewalk-setup --disconnected

* Setting up SELinux..
** Database: Setting up database connection for PostgreSQL backend.
** Database: Installing the database:
** Database: This is a long process that is logged in:
** Database:   /var/log/rhn/install_db.log
*** Progress: ###
** Database: Installation complete.
** Database: Populating database.
*** Progress: ############################
* Configuring tomcat.
* Setting up users and groups.
** GPG: Initializing GPG and importing key.
** GPG: Creating /root/.gnupg directory
You must enter an email address.
Admin Email Address? [email protected] ## Email Address ##
* Performing initial configuration.
* Activating Spacewalk.
** Loading Spacewalk Certificate.
** Verifying certificate locally.
** Activating Spacewalk.
* Configuring apache SSL virtual host.
Should setup configure apache's default ssl server for you (saves original ssl.conf) [Y]? ## Press Y ##
** /etc/httpd/conf.d/ssl.conf has been backed up to ssl.conf-swsave
* Configuring jabberd.
* Creating SSL certificates.
CA certificate password? ## Enter Certificate Password ##
Re-enter CA certificate password? ## Re Enter Certificate Password ##
Organization? ITzGeek ## Your Organization Name ##
Organization Unit [server.itzgeek.local]? Linux ## Your Organization Unit ##
Email Address [[email protected]]? ## Email Address ##
City? Albany ## Your City ##
State? NY ## Your State ##
Country code (Examples: "US", "JP", "IN", or type "?" to see a list)? US ## Your Country ##
** SSL: Generating CA certificate.
** SSL: Deploying CA certificate.
** SSL: Generating server certificate.
** SSL: Storing SSL certificates.
* Deploying configuration files.
* Update configuration in database.
* Setting up Cobbler..
Cobbler requires tftp and xinetd services be turned on for PXE provisioning functionality. Enable these services [Y]? ## Press Y ##
* Restarting services.
Installation complete.
Visit https://server.itzgeek.local to create the Spacewalk administrator account                                                                                        .

On complete, start the Spacewalk service if not started automatically.

/usr/sbin/spacewalk-service start

Open up your browser and navigate it to https://ip-add-ress or https://your-domain-name.

You will be asked to create administrator account for spacewalk, fill up details and click on Create Login.

Install Spacewalk on CentOS 7 - Create Spacewalk Administrator
Install Spacewalk on CentOS 7 – Create Spacewalk Administrator

Once administrator account is created, it will take you to home page of spacewalk where you can do all administration activities.

Install Spacewalk on CentOS 7 - Overview of Spacewalk
Install Spacewalk on CentOS 7 – Overview of Spacewalk

That’s All!!!, you have sucessfully installed Spacewalk on CentOS 7 / RHEL 7. Next tutorial is about Configuring the SpaceWalk to distribute the updates for CentOS clients.

Setup SysLog Server on CentOS 6 / RHEL 6

 Linux  Comments Off on Setup SysLog Server on CentOS 6 / RHEL 6
Sep 072015
 

Today we will be looking into how to setup a centralized log management for Linux servers, this will help the Linux admin to have a multiple server logs into one single place. The Linux admin not required to login in to each servers for checking the logs, he can just login into the centralized server and start do the logs monitoring.

Linux labels (auth, cron, ftp, lpr, authpriv, news, mail, syslog, etc ,..) the log messages to indicate the type of software that generated the messages with severity (Alert, critical, Warning, Notice, info, etc ,..).

You can find more information on Message Labels and Severity Levels

Make sure you have the following to setup log server.

Two Linux servers ( server and client).

server.itzgeek.local 192.168.0.105

client.itzgeek.local  192.168.0.104

Server setup:

Install syslog package, if you do not have it installed.

[root@server ~]# yum -y install rsyslog

Edit /etc/rsyslog.conf

[root@server ~]# vi /etc/rsyslog.conf

Un comment the following to enable the syslog server to listen on the tcp and udp port.

From

# Provides UDP syslog reception
#$ModLoad imudp
#$UDPServerRun 514
 
# Provides TCP syslog reception
#$ModLoad imtcp
#$InputTCPServerRun 514

To

# Provides UDP syslog reception
$ModLoad imudp
$UDPServerRun 514
 
# Provides TCP syslog reception
$ModLoad imtcp
$InputTCPServerRun 514

Restart the syslog service

[root@server ~]# service rsyslog restart

Verify the syslog server listening.

[root@server ~]# netstat -antup | grep 514
 
tcp        0      0 0.0.0.0:514                 0.0.0.0:*                   LISTEN      8081/rsyslogd
tcp        0      0 :::514                      :::*                        LISTEN      8081/rsyslogd
udp        0      0 0.0.0.0:514                 0.0.0.0:*                               8081/rsyslogd
udp        0      0 :::514                      :::*                                    8081/rsyslogd

Client setup:

Edit /etc/rsyslog.conf

[root@client ~]# vi /etc/rsyslog.conf

At the end of file place the following line to point the client message log to the server

*.info;mail.none;authpriv.none;cron.none   @192.168.0.105

You can either mention hostname or ip address.

Restart the syslog service

[root@client ~]# service rsyslog restart

Now all the message logs are sent to the central server and also it keeps the copy locally.

Firewall Port opening (Optional):

Mostly all the production environment are protected by hardware firewall, ask them to open the TCP & UDP 514. You can verify the port opening by issuing the following command from the client.

[root@client ~]# telnet 192.168.0.105 514
 
Trying 192.168.0.105...
Connected to 192.168.0.105.
Escape character is '^]'.

If it didn’t give any reply, disable firewall on both client and server.

Test:

Monitor the activity from the log server, open the message log.

[root@server ~]# tailf /var/log/messages

Now restart xinetd service on client, Now you can get the service restart message on the syslog server.

Oct 17 15:06:41 client xinetd[4280]: xinetd Version 2.3.14 started with libwrap loadavg labeled-networking options compiled in.
Oct 17 15:06:41 client xinetd[4280]: Started working: 0 available services

By this way you can monitor the other logs such as secure, mail, cron logs etc.

Install Nginx on CentOS 7 / RHEL 7

 Monitoring  Comments Off on Install Nginx on CentOS 7 / RHEL 7
Sep 072015
 

NGINX

Nginx is a popular lightweight server for those who do not need the bulk and extra services that Apache may offer. This article will look at installing Nginx on a CentOS using the ‘yum’ package manager.

Install Nginx:

To install Nginx using yum we need to include the Nginx repository, install the Nginx repository.

rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

Install the Nginx by issuing the following command.

yum install nginx

Starting Nginx:

Once installed, start the Nginix by using the following command.

systemctl start nginx.service

Once started. Navigate the web browser to Nginx server(IP Address or Host Name). The following image shows the default Welcome Screen of Nginx.

CentOS 7 - Nginx Default Page
CentOS 7 – Nginx Default Page

Extras:

Init scripts will help you to start and stop the service. The init scripts for the Nginx is installed while installing Nginx. However, we need to set up Nginx to start automatically if the server is rebooted:

systemctl enable nginx.

Configuration File:

The name of the default configuration file is nginx.conf, located in /etc/nginx directory. Configuration file is based on directives and parameters, each directive ends with a semi colon. The following shows the directives for worker connection and in which user name Nginx process should run.

user  nginx;
worker_processes  1;
events {
worker_connections  1024;
}

Creating a Virtual Server:

We must setup at least one virtual server for Nginx, in order to process the HTTP request by Nginx. When Nginx process the request,  it looks for the server directive which is placed in http context. You can add multiple server directives, to define multiple virtual servers.

Default virtual server config can be found under /etc/nginx/conf.d directory, if you open and see that; first line itself a virtual server for localhost and listening on port 80.

server {
listen       80;
server_name  localhost;
}

You will find the location directive, which will tell the server to look for the static file when the requests comes for the localhost.

location / {
root   /usr/share/nginx/html;
index  index.html index.htm;
}

Additionally you can mention the error pages.

error_page   500 502 503 504  /50x.html;
location = /50x.html {
root   /usr/share/nginx/html;
}

The above is the minimum configuration for a virtual server, you can find the full configuration here.

Example:

The following virtual server will accept the request for server.itzgeek.com, create a configuration file  in/etc/nginx/conf.d or copy the default configuration file.

cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/itzgeek.conf

Edit in such a way that, it receives the request. Minimal configuration will look like below.

vi /etc/nginx/conf.d/itzgeek.conf
server {
listen       80;
server_name  server.itzgeek.com;
location / {
root   /usr/share/nginx/html/itzgeek;
index  index.html index.htm;
}
}

Create root directory.

mkdir /usr/share/nginx/html/itzgeek

Create Index.html page.

echo “This is ITzGeek Home” > /usr/share/nginx/html/itzgeek/index.html

Restart the Nginx service.

 systemctl restart nginx.service

Test with browser, url will be http://server.itzgeek.com

CentOS 7 - Nginx Virtual Server
CentOS 7 – Nginx Virtual Server

That’s all.

How to install Java SDK 1.8 on RHEL 7/ CentOS 7

 Linux  Comments Off on How to install Java SDK 1.8 on RHEL 7/ CentOS 7
Sep 072015
 

Java

Today we will be looking into the installation of Oracle Java SDK 1.8_u5 on RHEL / CentOS, Java SDK is the most important base to the developers; this guide will be more useful for them to setup development environment when they especially uses Redhat or CentOS.

Download Java SDK:

You can either use command line or browser to download the JDK, better to use the browser, the easiest one. Visit the Oracle SDK page to download. If you still want to use the command line, use the below command.

# wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u11-b12/jdk-8u11-linux-x64.tar.gz
# tar -zxvf jdk-8u11-linux-x64.tar.gz
 
#  mv jdk1.8.0_11/ /usr/

Install Java:

Once moved the java to the desired location, java must setup with the alternatives commands; this will install the java on your system.

# /usr/sbin/alternatives --install /usr/bin/java java /usr/jdk1.8.0_11/bin/java 2
 
# /usr/sbin/alternatives --config java

Select the latest java.

There are 2 programs which provide 'java'.
 
  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.51-2.4.5.5.el7.x86_64/jre/bin/java
   2           /usr/jdk1.8.0_11/bin/java
 
Enter to keep the current selection[+], or type selection number: 2

Verify the Java:

Once setup the alternatives, verify the java version installed using the following command.

# java –version
 
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)

Setup Environmental Variable:

The most important part has come now, it should be set before the installation of any java based applications.

# export JAVA_HOME=/usr/jdk1.8.0_11/
 
# export JRE_HOME=/usr/jdk1.8.0_11/jre/

Set PATH variable too.

# export PATH=$JAVA_HOME/bin:$PATH

To set it as a permanent, place the above three commands in the /etc/profile (All Users) or .bash_profile (Single User)

That’s All!. Hope this helped, place your valuable comments below.

Install Apache Tomcat 8 on CentOS 7 / RHEL 7

 Linux  Comments Off on Install Apache Tomcat 8 on CentOS 7 / RHEL 7
Sep 072015
 

Tomcat Logo

Apache Tomcat is an open source web server and servlet container developed by the Apache Software Foundation (ASF). Tomcat implements the Java Servlet and the JavaServer Pages (JSP) specifications from Oracle and provides a “pure Java” HTTP web server environment for running the Java codes. Apache Tomcat includes tools for configuration and management, but can also be configured by editing XML configuration files.

Here is the step by step guide to install Apache Tomcat 8.0 on RHEL 7 / CentOS 7.

Open Terminal.

Switch to root user.

Install OpenJDK:

Tomcat requires to have java installed on your machine, you can either have Oracle JDK or OpenJDK installed on your machine. Here i used the openjdk, lets install openjdk by issuing the following command.

[root@server ~]# yum install java-1.7.0

You can also verify it, by issuing the following command.

[root@server ~]# java -version
java version “1.7.0_65″
OpenJDK Runtime Environment (rhel-2.5.1.2.el7_0-x86_64 u65-b17)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)

Download & Setup Apache Tomcat:

Download the latest version of the Apache Tomcat from the website and save it on your home directory.

[root@server ~]# wget http://mirror.nexcess.net/apache/tomcat/tomcat-8/v8.0.9/bin/apache-tomcat-8.0.9.tar.gz

Download the MD5 file.

[root@server ~]# wget --no-check-certificate https://www.apache.org/dist/tomcat/tomcat-8/v8.0.9/bin/apache-tomcat-8.0.9.tar.gz.md5

Verify the md5 check sum of the downloaded Tomcat archive with check sum provided by Apache Tomcat.

[root@server ~]# cat apache-tomcat-8.0.9.tar.gz.md5
82140943a894d582e5b34eff79b8c776 *apache-tomcat-8.0.9.tar.gz
 
[root@server ~]# md5sum apache-tomcat-8.0.9.tar.gz
82140943a894d582e5b34eff79b8c776  apache-tomcat-8.0.9.tar.gz

If both matches, extract the the tomcat on to your desired (/var/local) directory.

[root@server ~]# tar -zxvf apache-tomcat-8.0.9.tar.gz -C /var/local/

Controlling Apache Tomcat:

Apache Tomcat can be started and stopped by the script which comes with package, start the Apache Tomcat.

[root@server ~]# /var/local/apache-tomcat-8.0.9/bin/startup.sh

you will get the following output.

Using CATALINA_BASE:   /var/local/apache-tomcat-8.0.9
Using CATALINA_HOME:   /var/local/apache-tomcat-8.0.9
Using CATALINA_TMPDIR: /var/local/apache-tomcat-8.0.9/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /var/local/apache-tomcat-8.0.9/bin/bootstrap.jar:/var/local/apache-tomcat-8.0.9/bin/tomcat-juli.jar
Tomcat started.

You can verify the service running, by default tomcat runs on port no 8080

[root@server ~]# netstat -antup | grep 8080
tcp        0      0 0.0.0.0:8080                0.0.0.0:*                   LISTEN      2476/java

Open the web browser and point to http://ipaddress:8080

CentOS 7 - Apache Tomcat 8 Default Page
CentOS 7 – Apache Tomcat 8 Default Page

Stop the Apache Tomcat.

[root@server ~]# /var/local/apache-tomcat-8.0.9/bin/shutdown.sh

Managing the Apache Tomcat:

Tomcat can be managed through the web-manager, the following can be done through that.
Deploy new application, deploy new application on specified context, list the active or in active applications, start and stop the web applications.

Web manager is password protected, requires user name and password to access. Only the user with the “manager-gui” role is allowed to access, these users and roles are defined in tomcat-users.xml. By default “manager-gui” role not defined that file, we need to add it manually.

[root@server ~]# vi /var/local/apache-tomcat-8.0.9/conf/tomcat-users.xml

Place the following two lines just above the last line.

<role rolename="manager-gui"/>
<user username="tomcat" password="tomcat" roles="manager-gui"/>

Start the tomcat, now tomcat user have access to the web manager.

CentOS 7 - Apache Tomcat 8 App Manager
CentOS 7 – Apache Tomcat 8 App Manager

Same like, you can define the other roles.