RHEL/CentOS安装Observium

原文地址http://docs.observium.org/install_rhel7/


官方写的文档很清楚,纯粹为了抄过来做个记录。


Observiun整体就是php mysql libvirt fping这几个基础。


Introduction

This guide will show you how to perform an Observium installation on an CentOS/RHEL/Scientific Linux (referred to collectively as Enterprise Linux or EL) release 7 system.

In this example, we use and recommend a clean installation of EL.

Remote SSH

If you need to install SSH to install remotely, this can be installed via YUM:

yum install openssh

Then you can start the SSH server and add it to system startup

systemctl enable sshdsystemctl start sshd  
 systemctl enable sshd
 systemctl start sshd

Repositories

For more extended packagelist, we first install the Webtatic, OpenNMS and EPEL repositories:

yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install http://yum.opennms.org/repofiles/opennms-repo-stable-rhel7.noarch.rpm

Packages

Now let's install the needed packages for Observium:

PHP 7.0

If you'd like to use PHP 7.0 for better performance.

yum install wget.x86_64 httpd.x86_64 php70w.x86_64 php70w-opcache.x86_64 php70w-mysql.x86_64 php70w-gd.x86_64 \
php70w-posix php70w-mcrypt.x86_64 php70w-pear.noarch cronie.x86_64 net-snmp.x86_64 \
net-snmp-utils.x86_64 fping.x86_64 mariadb-server.x86_64 mariadb.x86_64 MySQL-python.x86_64 \
rrdtool.x86_64 subversion.x86_64 jwhois.x86_64 ipmitool.x86_64 graphviz.x86_64 ImageMagick.x86_64

PHP 5.6

If you'd like to use PHP 5.6 (recommended for Community Edition installs)

yum install wget.x86_64 httpd.x86_64 php56w.x86_64 php56w-opcache.x86_64 php56w-mysql.x86_64 php56w-gd.x86_64 \
php56w-posix php56w-mcrypt.x86_64 php56w-pear.noarch cronie.x86_64 net-snmp.x86_64 \
  net-snmp-utils.x86_64 fping.x86_64 mariadb-server.x86_64 mariadb.x86_64 MySQL-python.x86_64 \
  rrdtool.x86_64 subversion.x86_64 jwhois.x86_64 ipmitool.x86_64 graphviz.x86_64 ImageMagick.x86_64

If you want to be able to monitor libvirt virtual machines, install libvirt:

yum install libvirt.x86_64

Download Observium

First, create a directory for Observium to live in:

mkdir -p /opt/observium && cd /opt

Observium Editions

Observium comes in two editions, an Open Source Community Edition released on a biannual cycle, and a Subscription Edition with additional features,rapid bug fixes and feature improvements on a daily basis and an easy to use SVN-based update mechanism.

Observium Community Edition

If you would like to install the Community Edition, please install using the most recent .tar.gz release.

Download the latest .tar.gz of Observium and unpack:

wget http://www.observium.org/observium-community-latest.tar.gz<
tar zxvf observium-community-latest.tar.gz

Observium Subscription Edition

If you have a valid Observium subscription, please use one of the automated SVN release repositories.

We recommend the stable train for people who intend to use automated updates to keep their Observium installation up to date.

For the current train:

svn co http://svn.observium.org/svn/observium/trunk observium

For the stable train:

svn co http://svn.observium.org/svn/observium/branches/stable observium

MySQL Database

Start MySQL/MariaDB and configure it to be run at startup.

systemctl enable mariadb
systemctl start mariadb

Set the MySQL root password:

/usr/bin/mysqladmin -u root password '<mysql root password>'

Create the MySQL database:

mysql -u root -p
<    mysql root password>    mysql> CREATE DATABASE observium DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql> GRANT ALL PRIVILEGES ON observium.* TO 'observium'@'localhost' IDENTIFIED BY '<observium db password>';
mysql> exit;

Observium Configuration

Change into the new install directory:

cd observium

Copy the default configuration file and edit it for your system:

cp config.php.default config.php

Edit config.php. Change the options to reflect your installation.

MySQL Credentials

You must change the MySQL username and password contained in db_user and db_pass. Most other settings can be left as default.

Insert MySQL Schema

Run the discovery.php script with the upgrade switch -u in order to insert the initial MySQL schema

./discovery.php -u

It is OK to have some errors in the SQL revisions

Fping

Since Fping is in a different location, add a line to config.php to tell Observium.

[root@observium-centos observium]# which fping
/sbin/fping

Add the following

$config['fping'] = "/sbin/fping";

SELinux

Explaining SELinux and how to make Observium work within it is beyond the scope of this guide, so we will disable it. If you are competent enough to maintain SELinux, then that is possible too, but is an even more unsupported configuration than RHEL/CentOS themselves.

Firstly, disable SELinux. You can do this temporarily with the following command:

setenforce 0

We need to disable SELinux permanently, so you also need to change /etc/selinux/config so that the SELINUX option is set to permissive

SELINUX=permissive

System

Create the rrd directory to store RRDs in:

mkdir rrd
chown apache:apache rrd

If the server will be running only Observium, change /etc/httpd/conf.d/observium.conf and add the following to the end :

<VirtualHost *>
 DocumentRoot /opt/observium/html/
 AerverName  observium.domain.com
 CustomLog /opt/observium/logs/access_log combined  
 ErrorLog /opt/observium/logs/error_log  
 <Directory "/opt/observium/html/">    
 AllowOverride All    
 Options FollowSymLinks MultiViews    
 Require all granted  
 </Directory>
 </VirtualHost>

Create logs directory for apache

mkdir /opt/observium/logs
chown apache:apache /opt/observium/logs

Add a first user, use level of 10 for admin:

cd /opt/observium
./adduser.php <username> <password> <level>

Add a first device to monitor:

./add_device.php <hostname> <community> v2c

Do an initial discovery and polling run to populate the data for the new device:

./discovery.php -h all
./poller.php -h all

Cron

Add cron jobs, create a new file /etc/cron.d/observium with the following contents:

Cron Usage

The below example includes a username, so will only work in /etc/crontab or /etc/cron.d/observium. It will NOT work in a user crontab edited with crontab -e without removing the username.

# Run a complete discovery of all devices once every 6 hours
33  */6   * * *   root    /opt/observium/discovery.php -h all >> /dev/null 2>&1

# Run automated discovery of newly added devices every 5 minutes
*/5 *     * * *   root    /opt/observium/discovery.php -h new >> /dev/null 2>&1

# Run multithreaded poller wrapper every 5 minutes
*/5 *     * * *   root    /opt/observium/poller-wrapper.py 8 >> /dev/null 2>&1

# Run housekeeping script daily for syslog, eventlog and alert log
13 5 * * * root /opt/observium/housekeeping.php -ysel

# Run housekeeping script daily for rrds, ports, orphaned entries in the database and performance data
47 4 * * * root /opt/observium/housekeeping.php -yrptb

And reload the cron process:

systemctl reload crond

Please note running four poller instances is good for initial testing, but do check the [[Performance tuning]] page for further performance enhancing options once  you get going.

Final Points

Let's set the httpd to startup when we reboot the server:

systemctl enable httpd
systemctl start httpd

Permit HTTP through the server's default firewall

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --reload

You should now be able to see http://<server ip>

Updating

Updating Observium has been designed to be as quick and painless as possible. Using our SVN delivery mechanism, it can even be automated. Because we have a rapid development and model, we recommend that you update frequently, at least once per month, though once or twice per week is better and many users update daily via an automated CRON job.

See Updating the Subscription Edition for a short explanation on how to update the Subscription Edition of Observium.

Problems

When running eg. poller.php or discovery.php a lot of notices regarding undefined indexes, variables and offsets.To hide these notices you can do the following:

nano /etc/php.ini

Find the line containing:

error_reporting = E_ALL & ~E_DEPRECATED

Change this to:

error_reporting = E_ALL & ~E_NOTICE

If there are problems with this installation tutorial, please make sure you've followed the install guide closely, check the FAQs, then join our IRC channel or Mailing Lists and ask for help.

添加新评论 »