Usagi Lepus database monitoring installation

Chapter 1 Introduction lepus

Lepus is a set of open-source database monitoring platform, now supports basic monitoring and alerting MySQL, Oracle, SQLServer, MongoDB, Redis and other databases (MySQL already supports replication monitoring, slow query analysis and advanced features such as directional push). After Lepus need to deploy scripts or Agent on each database server, only you need to create an account in the authorization database, you can remotely monitor, monitor database servers for more companies and monitoring the cloud database, which will monitor the company greatly simplified deployment processes while Lepus system built a wealth of performance monitoring indicators, enables companies to identify potential performance problems before database processing downtime, reduce the direct loss of business because of problems caused by database.

Essential requirements of Chapter 2 Software Installation

Software needs LAMP environment, you need a core package as follows:

The following packages need only be deployed to monitor the machine. Monitored machine without having to deploy.

1.MySQL5.1 and above (to be used to store data collected by the monitoring system)

2.Apache 2.2 and above (must, WEB server running server)

3.PHP 5.3 above (must provide support WEB interface does not support PHP7)

4.Python2 (must recommend version 2.6 and above, perform data acquisition and alarm tasks, does not support Python3)

5.Python monitoring database connections and associated drive module package:

MySQLdb for python (Python MySQl connection interface for monitoring MySQL, this module must be installed)

cx_oracle for python (Python Oracle connection interface, not necessarily, you need to be monitored if this oracle modules must be installed)

Pymongo for python (Python interface MongoDB, the non-essential, if desired MongoDB monitoring module must be installed)

redis-py for python (Python Redis connection interface, not necessarily, if necessary Redis monitoring module must be installed)

The installation demonstrates the use of the following packages to build:

software

Explanation

httpd-2.2.31.tar.gz

LAMP must build

mysql-5.5.49-linux2.6-x86_64.tar.gz

MySQL database

php-5.5.32.tar.gz

php

libiconv-1.14.tar.gz

Php support necessary components

Python-2.7.6.tgz

Necessary to install

Redis-py-2.10.3.tar.gz

Redis monitoring module (optional)

3.3.4 cx_oracle for python

Oracle monitoring module (optional)

oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm

oracle database module necessary

oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm

oracle database module necessary

oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm

oracle database module necessary

pymongo-2.7.tar.gz

Mongodb monitoring module

freetds-0.82

SQLServer monitoring module

Lepus3.7.zip

Usagi body monitoring software

Compile and install the software directory

/ Tools package unified storage directory

/ Server / scripts directory script store

/ Application after installing the software compiled directory location

Chapter 3 Software Installation

3.1 build LAMP environment

This is used to build a manual way to accomplish LAMP environment

3.1.1 compile and install httpd service

Unzip directory and create an account for http www service

[root@m02 ~]# cd /tools
[root@m02 tools]# tar xf httpd-2.2.31
[root@m02 tools]# cd httpd-2.2.31
[root@m02 tools]# useradd www -s /sbin/nologin -M

Install the necessary software package zlib

[root@m02 httpd-2.2.31]# yum install zlib zlib-devel -y

Installation and execution profile

[root@m02 httpd-2.2.31]# ./configure --prefix=/application/apache2.2.31 --enable-deflate --enable-expires --enable-headers --enable-modules=most --enable-so --with-mpm=worker --enable-rewrite
[root@m02 httpd-2.2.31]# make && make install

Create a soft link and start the service

[root@m02 httpd-2.2.31]# ln -s /application/apache2.2.31/ /application/apache
[root@m02 httpd-2.2.31]# /application/apache/bin/apachectl start
[root@m02 httpd-2.2.31]# netstat -lntup|grep http
tcp        0      0 :::80                       :::*                        LISTEN      57310/httpd  

3.1.2 based on the configuration of the virtual hosts apache

Virtual host configuration aim is to detect whether the service can display the home page http normal.

To www.test.com example to configure a home page

[root@m02 apache]# cd /application/apache/htdocs/
[root@m02 apache]# mkdir www

Modify the page configuration file httpd.conf

[root@m02 htdocs]# vim /application/apache/conf/httpd.conf

Search / httpd-v, the foregoing comments removed.

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

Search the file Servername comment open, if there is a need to modify the network IP address.

ServerName 127.0.0.1:80

Edit the configuration file httpd-vhosts.conf page http

[root @ M02 htdocs] # vim /application/apache/conf/extra/httpd-vhosts.conf 
<VirtualHost *: 80> 
    ServerAdmin [email protected] # administrator mailbox 
    DocumentRoot "/application/apache2.2.31/htdocs/www " # page virtual directory 
    ServerName www.test.com # domain 
    ServerAlias test.com # alias 
    ErrorLog" logs / www_error_log " # error log 
    CustomLog" logs / www_access_log "the Common # access log 
</ VirtualHost>

Establish a home page file used to test whether normal

[root@m02 htdocs]# echo 'Apache www' >www/index.html

Restart the server to refresh the configuration

[root@m02 apache]# /application/apache/bin/apachectl -t
[root@m02 apache]# /application/apache/bin/apachectl graceful

Modify the client's hosts file to add the IP address of our page, if the content apache www www.test.com access through a browser appears, it shows the apache successfully completed structures.

3.1.3 install mysql

This is done directly by way of a single instance of the installation.

[root@m02 apache]# cd /tools
[root@m02 tools]# useradd -s /sbin/nologin -M mysql
[root@m02 tools]# tar xf mysql-5.5.49-linux2.6-x86_64.tar.gz
[root@m02 tools]# mv mysql-5.5.49-linux2.6-x86_64 /application/mysql-5.5.49
[root@m02 tools]# ln -s /application/mysql-5.5.49/ /application/mysql
[root@m02 tools]# chown -R mysql:mysql /application/mysql
[root@m02 tools]# cd /application/mysql
[root@m02 mysql]# ./scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql

3.1.4 mysql debugging and open database

[root@m02 mysql]# cd bin/
[root@m02 bin]# sed -i 's#/usr/local/#/application/#g' mysqld_safe
[root@m02 bin]# cd ../
[root@m02 mysql]# \cp support-files/my-small.cnf /etc/my.cnf
[root@m02 mysql]# echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile
[root@m02 mysql]# . /etc/profile
[root@m02 mysql]# sed -i 's#/usr/local/#/application/#g' support-files/mysql.server
[root@m02 mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@m02 mysql]# chmod +x /etc/init.d/mysqld
[root@m02 mysql]# chkconfig --add mysqld
[root@m02 mysql]# /etc/init.d/mysqld start

3.1.5 php5.5.32 installation

cd /tools/
[root@m02 tools]# tar xf libiconv-1.14.tar.gz
[root@m02 tools]# cd libiconv-1.14
[root@m02 libiconv-1.14]# ./configure --prefix=/usr/local/libiconv
[root@m02 libiconv-1.14]# make && make install
[root@m02 libiconv-1.14]# cd ../
[root@m02 tools]# yum install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libmcrypt-devel mhash mcrypt openssl-devel pcre-devel -y
[root@m02 tools]# tar xf php-5.5.32.tar.gz
[root@m02 tools]# cd php-5.5.32
[root@m02 php-5.5.32]# ./configure --prefix=/application/php5.5.32 --with-mysql=/application/mysql --with-pdo-mysql=/application/mysql --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --enable-short-tags --enable-static --with-xsl --with-fpm-user=www --with-fpm-group=www --enable-opcache=no --with-apxs2=/application/apache/bin/apxs --enable-ftp
[root@m02 php-5.5.32]# ln -s /application/mysql/lib/libmysqlclient.so.18  /usr/lib64/
[root@m02 php-5.5.32]# touch ext/phar/phar.phar
[root@m02 php-5.5.32]# make
[root@m02 php-5.5.32]# make install
[root@m02 php-5.5.32]# ln -s /application/php5.5.32 /application/php
[root@m02 php-5.5.32]# cp php.ini-production /application/php/lib/php.ini
[root@m02 php-5.5.32]# cd /application/php/etc
[root@m02 etc]# cp php-fpm.conf.default php-fpm.conf
[root@m02 etc]# grep libphp5.so /application/apache/conf/httpd.conf
[root@m02 etc]# ls /application/apache/modules/
[root@m02 etc]# /application/php/sbin/php-fpm

3.2 http combined with php and mysql module of

3.2.1 configuration file httpd.conf

Add the following line at 311 /application/apache/conf/httpd.conf file:

AddType application/x-httpd-php .html .htm .php .phtml
AddType application/x-httpd-php-source .html .htm .phps 

168 Line Review:

DirectoryIndex index.php index.html

In the first 67 rows Review:

User www
Group www

Edit the test file

[root@m02 etc]# cd /application/apache/htdocs/www
[root@m02 www]# echo "<?php phpinfo(); ?>" >test_info.php

If the input www.test.com/test_info.php php configuration page appears to explain php and has been associated with the http in the browser.

3.2.2 http combined with the mysql

Also, in the above directory, create a file in a mysql test document reads as follows

[root@m02 www]#  vim /application/apache/htdocs/www/test_mysql.php
<?php
        $link_id=mysql_connect('localhost','root','123456') or mysql_error();
        if($link_id){
                echo "MySQL successful by test !";
        }else {
                echo mysql_error();
        }
?>

Please note that the mysql login account password, if empty, please set their own account password mysql login.

The browser address input www.test.com/test_mysql.php view the database connection status.

Python 3.3 installation environment

Python database connection setup driver package. MySQLdb MySQL for Python connection and operation of the library, if you plan to use lepus system monitoring MySQL database, the module must be installed.

3.3.1 install python (must be installed)

XF-2.7.6.tgz the Python the tar 
CD the Python-2.7.6 
./configure --prefix = / file application / python2.7.6 # Note: Installing a new directory, to prevent overwriting the default Python 
the make the make the install && 
Music Videos / usr / bin / Python /usr/bin/python2.6.6.old 
LN /application/python2.7.6/bin/python -s / usr / bin / Python 
Python -V

If prompted Python 2.7.6 appears that success.

Since this time updated python version, you will get an error when using yum command.

modify

vim / usr / bin / yum 
#! / usr / bin / Python replace #! / usr / bin / python2.6.6.old (that is, the original version link)

3.3.2 python setuptools install

cd /tools
tar xf setuptools-12.0.3.tar.gz
cd setuptools-12.0.3
python setup.py install

3.3.3 mysqldb for python

CD / Tools 
the unzip MySQLdb-python.zip 
CD-Master MySQLdb1 / 
which mysql_config 
Vim site.cfg 
the mysql_config = / file application / MySQL / bin / the mysql_config # open comments, which mysql_config modify the path of the back. 
Build setup.py Python 
Python setup.py install

If it does not exist mysql_config install setuptools.

Redis 3.3.4 installation drive (if you need to monitor Redis must be installed)      

cd /tools
tar xf redis-py-2.10.3.tar.gz
cd redis-2.10.3/
python setup.py install

3.3.5 Installation cx_oracle for python (if you need to monitor the Oracle must be installed)

Install oracle instant client, this module is very pit father, the oracle official website Download will jump directly to the registration interface lets you log in, so I got to take a shortcut directly to the necessary installation package

oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm

oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm

oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm

cd /tools
rpm -ivh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
rpm -ivh oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm
rpm -ivh oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm
vim /root/.bash_profile #编辑全局配置文件
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs
ORACLE_HOME="/usr/lib/oracle/11.2/client64"
PATH=$PATH:$ORACLE_HOME/bin
#PATH=$PATH:$HOME/bin
export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH
source ~/.bash_profile #命令行加载生效
echo "/usr/lib/oracle/11.2/client64/lib" >> / etc / ld.so.conf 
/ sbin / ldconfig # command line take effect

Installation cx_Oracle-5.1.2 3.3.6

tar xf cx_Oracle-5.1.2.tar.gz
cd cx_Oracle-5.1.2
python setup.py build 
python setup.py install

3.3.7 Installation Pymongo for python (if you need to monitor Mongodb must be installed)

cd /tools
tar xf pymongo-2.7.tar.gz
cd pymongo-2.7
python setup.py install

3.3.8 install SQLServer driver (if you need to monitor the SQLServer must be installed)

3.3.8.1 Installation freetds

cd /tools
tar xf freetds-0.82.tar.gz
cd freetds-0.82
./configure --prefix=/usr/local/freetds --with-tdsver=8.0 --enable-msdblib --enable-dbmfix --with-gnu-ld --enable-shared --enable-static
make
make install
echo "/usr/local/freetds/lib" >>/etc/ld.so.conf.d/freetds.conf
ldconfig -v

3.3.8.2 Installation pymssql

cd /tools
tar xf pymssql-2.1.1.tar.gz
cd pymssql-2.1.1
python setup.py install

3.3.9 Lepus3.7 decompression software checks the connection portions are normal driving

cd /tools
unzip Lepus3.7.zip
cd /tools/lepus_v3.7/python
python test_driver_mysql.py
python test_driver_oracle.py
python test_driver_mongodb.py
python test_driver_redis.py

3.4 Collector installation lepus

cd /tools/lepus_v3.7/python
chmod +x lepus*
chmod +x install.sh
./install.sh
cd /usr/local/lepus/

3.4.1 Create a database to monitor the monitoring machine and authorization

Log database

create database lepus default character set utf8;
grant all on lepus.* to 'lepus_user'@'localhost' identified by '123456';
flush privileges;

Import SQL folder in the SQL initialization file (table structure and data files)

cd /tools/lepus_v3.7/sql/
mysql -uroot -p123456 lepus <lepus_table.sql
mysql -uroot -p123456 lepus <lepus_data.sql

3.5 WEB management station installation

Copy lepus_v3.7 / php file to a folder in the apache web site corresponding virtual directory, modify the configuration.

cd /tools/lepus_v3.7
cp -rf php/* /application/apache/htdocs/www/

Lepus modify the database connection file

vim /application/apache/htdocs/www/application/config/database.php

$db['default']['hostname'] = '127.0.0.1';
$db['default']['port']     = '3306';
$db['default']['username'] = 'lepus_user';
$db['default']['password'] = '123456';
$db['default']['database'] = 'lepus';
$db['default']['dbdriver'] = 'mysql';

To modify the ServerName native 127.0.0.1:80

Modify the virtual configuration file

/application/apache/conf/extra/httpd-vhosts.conf

Restart apache service and modify the configuration file

/usr/local/lepus/etc/config.ini Vim 
### monitoring machine MySQL database connection address ### 
[monitor_server] 
Host = "127.0.0.1" 
Port = 3306 
User = "lepus_user" 
the passwd = "123456" 
dbname = "lepus"

Start lepus Service

cd /usr/local/lepus/
lepus start
ps -ef|grep lepus

But because it has not added a host, so view the log will see the following prompt is a normal prompt. Of course, this step can also be started after the completion of the deployment Lepus WEB console.

Admin login page User name Password Lepusadmin.

Chapter 4 Adding MySQL monitoring instance

Lepus is the use of remote monitoring database connections into data acquisition, so no need to deploy the relevant agent or scheduled tasks on the database server. But it needs to be granted access to the database side, and then configure instances WEB end it. As shown in the following steps.

First, we performed the authorization being monitored database, allowing the use Lepus collector can connect to the database server, perform the following command to authorize the monitored database.

On the database server to be monitored authorization, we are now multi-instance database on borrowed 10.0.0.52 3306 to operate the test

grant select,process,super on *.* to 'lepus_user'@'10.0.0.%' identified by '123456';
flush privileges;

Once created, you can configure the host entry in the page.

  

 

 

Guess you like

Origin www.cnblogs.com/ninjawei/p/11375270.html