Showing posts with label CentOS. Show all posts
Showing posts with label CentOS. Show all posts

Saturday, April 16, 2016

HowTo deploy Icinga2 Monitoring Server with Icinga Web 2 and Icingacli on CentOS 7.x 64 bit

To start with we require server ready with CentOS 7.x 64 bit

1) For Icinga2 installation we require server root access

$ sudo su -

now enter password to get the root prompt

#


2) Ensure SELINUX is disabled and to check the status run following command

# sestatus

and to disable read

Howto Disable SELINUX on CentOS 5.x / RHEL 5.x



3) Add EPEL repository as it is required for deploying Icinga2

# yum install epel-release


4) Add Icinga2 repository

# rpm --import http://packages.icinga.org/icinga.key
# curl -o /etc/yum.repos.d/ICINGA-release.repo http://packages.icinga.org/epel/ICINGA-release.repo
# yum makecache


5) Deploy Apache2 web server

# yum install httpd

to start and enable Apache2 server run following command

# systemctl start httpd && systemctl enable httpd

and to check the status of the server

# systemctl status httpd

open http://SERVERIPADDRESS/ url in the browser and you should get default apache2 page

create index.html file as this will take care of http warning initially displayed by Icinga2

# touch /var/www/html/index.html


6) Deploy MariaDB database server

# yum install mariadb-server mariadb

to start and enable MariaDB server run following command

# systemctl start mariadb && systemctl enable mariadb

and check the status of the server

# systemctl status mariadb

now lets secure Mariadb server

# mysql_secure_installation

Enter current password for root (enter for none):  (click on enter as no password is set by default)

Set root password? [Y/n] (click on enter to set root password)

New password: (type new root password)
Re-enter new password: (reenter new root password)

Remove anonymous users? [Y/n] (click on enter to remove all anonymous users)

Disallow root login remotely? [Y/n] (click on enter to disallow root login remotely)

Remove test database and access to it? [Y/n] (click on enter to delete test database)

Reload privilege tables now? [Y/n] (click on enter to reload user privileges)


7) Deploy PHP

# yum install php php-mysql php-ldap

update timezone in php.ini

# vi /etc/php.ini

search for [date] section and set timezone as per your location and save the file

date.timezone = "Asia/Kolkata"

restart apache2 server

# systemctl restart httpd

and check the status of the server

# systemctl status httpd


8) Deploy Icinga2

# yum install icinga2

to start and enable Icinga2 server run following command

# systemctl start icinga2 && systemctl enable icinga2


and check the status of the server

# systemctl status icinga2

by default all config files are stored in /etc/icinga2 directory

and by default Icinga2 enables three features and it can be checked by running following command

# icinga2 feature list


9)  Install Nagios plugins

# yum install nagios-plugins-all

by default plugins are installed in /usr/lib64/nagios/plugins/ directory and if plugin path is to be changed then it has to be updated for "const PluginDir" parameter in /etc/icinga2/constants.conf file

restart Icinga2 server

# systemctl restart icinga2


10) Configure IDO Mysql module

# yum install icinga2-ido-mysql

login into mariadb

# mysql -u root -p (at the password prompt provide root password)

at the prompt run following commands

> CREATE DATABASE icinga;

> GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icinga.* TO 'icinga'@'localhost' IDENTIFIED BY 'icinga';

> use icinga;

to import database schema run following command

> \. /usr/share/icinga2-ido-mysql/schema/mysql.sql

> exit

now lets update ido-mysql.conf file as follows

# vi /etc/icinga2/features-available/ido-mysql.conf

Edit IdoMysqlConnection section as follows

object IdoMysqlConnection "ido-mysql" {
  user = "icinga"
  password = "icinga"
  host = "localhost"
  port = 3306
  database = "icinga"
  table_prefix = "icinga_"
  instance_name = "icinga2"
  instance_description = "icinga2 instance"
}


11) Enable web interface feature to send commands to Icinga2

# icinga2 feature enable command

check if command is added in Enabled feature list

# icinga2 feature list

restart icinga2 to take effect

# systemctl restart icinga2


12) Add apache user to icingacmd group

# usermod -a -G icingacmd apache

to check if apache user is added to the group run following command

# id apache

and output would look similar to

uid=48(apache) gid=48(apache) groups=48(apache),992(icingacmd)


13) Deploy Icinga Web 2 and Icingacli

# yum install icingaweb2 icingacli


restart icinga2 to take effect


# systemctl restart icinga2

create database for Icinga web 2

# mysql -u root -p (at the password prompt provide mariadb root password)

at the prompt run following commands

> CREATE DATABASE icingaweb2;

> GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icingaweb2.* TO 'icingaweb2'@'localhost' IDENTIFIED BY 'icingaweb2';

> exit


restart apache2 server

# systemctl restart httpd

and check the status of the server

# systemctl status httpd


14) Now generate token to proceed with the installation using browser

icingacli setup token create

to recheck generated token run following command


# icingacli setup token show

open http://SERVERIPADDRESS/icingaweb2/setup URL in the browser to proceed with the installation

On 'Setup' page provide setup token and click on "Next"

On 'Modules' page click on "Next"

On 'Requirement' page ensure every option is green, scroll to bottom of the page and click on "Next"

On 'Authentication' page the default Authentication Type is set to Database, click on "Next"

On 'Database Resource' page provide details as follows

Resource Name : icingaweb2
Database Type : MySQL
Host          : localhost
Port          : 3306
Database Name : icingaweb2
Username      : icingaweb2
Password      : icingaweb2

Click on "Validate Configuration" and once successfully validated click on "Next"

On 'Database Setup' page for Username and Password provide MariaDB administrative username i.e root and its configured password and click on "Next"

On 'Authentication Backend' page keep default value and click on "Next"

On 'Administration' page create Icinga Web2 administrative user i.e admin, and set its password now click on "Next"

On 'Application Configuration' page keep default value and click on "Next"

On 'Configuration' page it will show all configuration provided earlier and would mention that Icinga Web 2 is successfully installed and click on "Next"

On 'Welcome' page click on "Next"

On 'Monitoring Backend' page keep default values and click on "Next"

On 'Monitoring IDO Resource'page provide details as follows

Resource Name : icingaido
Database Type : MySql
Host          : localhost
Port          : 3306
Database Name : icinga
Username      : icinga
Password      : icinga

Click on "Validate Configuration" and once successfully validated click on "Next"

On 'Command Transport' page keep default values and click on "Next"

On 'Monitoring Security' page keep default values and click on "Next"

On 'Finish' page click on "Finish"

On 'Congratulations' page on the the right hand side, click on 'Login to Icinga Web 2'. On login page provide Icinga Web2 admin user name and password to go to Icinga Dashboard page.

With this you have successfully deployed Icinga2 Server along with Icinga Web2 and Icingacli module. Now you can proceed with configuring servers to be monitored that will be covered in the next blog post.

Tuesday, November 22, 2011

Revisiting Nginx (engine x) – Installation Guide on CentOS 5.5

It has been a long time since I worked with Nginx and decide to check it again. And was amazed to find that the server has improved and also its installation process is much simpler. Below are the revised installation steps.

1] Download Nginx from its official site (http://nginx.org/)

Stable version is available at

(Note : On production server use only stable version)

or

Development version is available at



2] Lets store downloaded file under a directory, for example 'download' directory

$ mkdir ~/download

$ mv nginx-1.0.10.tar.gz ~/download


3] We need to install following required Nginx dependencies - pcre pcre-devel zlib zlib-devel openssl openssl-devel

$ sudo yum install pcre pcre-devel zlib zlib-devel openssl openssl-devel


4] Create Nginx user and group id

$ sudo /usr/sbin/groupadd nginx

$ sudo /usr/sbin/useradd –g nginx –s /bin/false nginx


5] Proceed with source installation of Nginx

$ cd ~/download

$ tar -zxvf nginx-1.0.10.tar.gz

$ cd nginx-1.0.10.tar.gz


6] Configure Nginx source

$ ./configure \
--user=nginx \
--group=nginx \
--with-http_realip_module \
--with-http_flv_module \
--with-http_gzip_static_module \
--with-http_ssl_module \
--with-http_stub_status_module


7] Make and install

$ make

$ sudo make install


8] Change ownerships before we proceed

$ sudo chown nginx:nginx –R /usr/local/nginx


9] To start Nginx

$ sudo /usr/local/nginx/sbin/nginx

If we get no error while starting Nginx then lets check running process status

[joel@localhost ~]$ ps aux | grep nginx
root 14802 0.0 0.0 4076 500 ? Ss 01:27 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx 14803 0.0 0.1 4264 1092 ? S 01:27 0:00 nginx: worker process
joel 15004 0.0 0.0 4016 708 pts/1 S+ 01:39 0:00 grep nginx

10] And now we are ready to use Nginx

Open http://localhost or http://127.0.0.1 on your system browser and Nginx shows up.

Bingo!!!

11] To shutdown Nginx

$ sudo kill `cat /usr/local/nginx/logs/nginx.pid`

Thursday, October 1, 2009

Nginx (engine x) – Installation Guide on CentOS

1] Download source code of Nginx from the official site (http://nginx.net/)

To get stable version as per this tutorial dated is

$ wget http://sysoev.ru/nginx/nginx-0.7.61.tar.gz

or

To get development version as per this tutorial dated is

$ wget http://sysoev.ru/nginx/nginx-0.8.7.tar.gz

(Note : For production server use stable version only)


2] We store downloaded file under a directory, for example we will use 'download' directory

$ mkdir ~/download

$ cp nginx-0.6.36.tar.gz ~/download

$ cd download


3] Install required Nginx dependencies

pcre pcre-devel zlib zlib-devel openssl openssl-devel

so using default package manager of CentOS

$ sudo yum install pcre pcre-devel zlib zlib-devel openssl openssl-devel


4] Create required Nginx user and group ids

$ sudo /usr/sbin/groupadd nginx

$ sudo /usr/sbin/useradd –g nginx –s /bin/false nginx


5] Proceed with source installation of Nginx

$ cd ~/download

unzip the source file

$ tar -zxvf nginx-0.7.61.tar.gz

$ cd nginx-0.7.61


6] Configure Nginx source

$ ./configure \

--prefix=/usr/local/nginx \

--sbin-path=/usr/local/sbin \

--conf-path=/usr/local/nginx/nginx.conf \

--http-log-path=/var/log/nginx/access.log \

--error-log-path=/var/log/nginx/error.log \

--pid-path=/var/run/nginx/nginx.pid \

--lock-path=/var/lock/nginx.lock \

--user=nginx \

--group=nginx \

--http-client-body-temp-path=/var/tmp/nginx/client/ \

--http-proxy-temp-path=/var/tmp/nginx/proxy/ \

--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \

--with-http_ssl_module \

--with-http_realip_module \

--with-http_perl_module \

--with-http_flv_module \

--with-http_gzip_static_module \

--with-http_stub_status_module \

--with-md5-asm \

--with-md5=auto/lib/md5 \

--with-sha1-asm \

--with-sha1=auto/lib/sha1


7] Make and Install

$ make

$ sudo make install


8] Change ownerships before we proceed

$ sudo chown nginx:nginx –R /usr/local/nginx


9] Create following directories with required ownership to proceed

$ sudo mkdir -p /var/tmp/nginx /{client,proxy,fcgi}

$ sudo chown nginx:nginx -R /var/tmp/nginx


10] Start Nginx

$ sudo /usr/local/sbin/nginx

If we get no error while starting Nginx then lets check running process status by executing following command and getting similar output as below

$ ps aux | grep nginx

root 10009 0.0 0.0 5524 592 ? Ss 07:21 0:00 nginx: master process /usr/local/sbin/nginx

nginx 10010 0.0 0.0 5716 928 ? S 07:21 0:00 nginx: worker process


11] And we are ready to use Nginx

Open your browser and type ip address of your server or just type localhost.

http://localhost

http://127.0.0.1


Bingo!!!

12] Shutdown Nginx

$ sudo kill `cat /var/run/nginx/nginx.pid`