开源监控解决方案:Icinga(Nagios)部署实录
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了开源监控解决方案:Icinga(Nagios)部署实录相关的知识,希望对你有一定的参考价值。
[[email protected] ~]# rpm -ivh http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm [[email protected] ~]# yum install -y mysql-community-server [[email protected] ~]# vi /etc/my.cnf [mysqld] port = 3306 user = mysql character-set-server=utf8 explicit_defaults_for_timestamp sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES open-files-limit = 65535 max_connections = 500 max_connect_errors = 10000 key_buffer_size = 256M max_allowed_packet = 16M read_buffer_size = 1M read_rnd_buffer_size = 1M sort_buffer_size = 1M join_buffer_size = 1M tmp_table_size = 256M max_heap_table_size = 256M table_open_cache = 512 thread_cache_size = 64 slow_query_log = 1 long_query_time = 5 log-queries-not-using-indexes log_bin = mysql-bin binlog_format = row sync_binlog = 1 binlog_cache_size = 16M max_binlog_cache_size = 32M max_binlog_size = 512M expire_logs_days = 7 relay_log = relay-bin relay_log_recovery = 1 master_info_repository = table relay_log_info_repository = table innodb_buffer_pool_size = 2G innodb_buffer_pool_instances = 2 innodb_log_file_size = 128M innodb_log_files_in_group = 3 innodb_log_buffer_size = 16M innodb_undo_logs= 128 innodb_undo_tablespaces = 3 innodb_file_format = Barracuda innodb_strict_mode = 1 innodb_data_file_path = ibdata1:1024M:autoextend [mysqldump] quick max_allowed_packet = 16M [mysql] no-auto-rehash default-character-set = utf8 [client] default-character-set = utf8 [[email protected] ~]# service mysqld start Initializing MySQL database: 2018-04-16 21:44:09 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap. 2018-04-16 21:44:09 0 [Note] /usr/sbin/mysqld (mysqld 5.6.39-log) starting as process 1838 ... 2018-04-16 21:44:09 1838 [Note] InnoDB: Using atomics to ref count buffer pool pages 2018-04-16 21:44:09 1838 [Note] InnoDB: The InnoDB memory heap is disabled 2018-04-16 21:44:09 1838 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2018-04-16 21:44:09 1838 [Note] InnoDB: Memory barrier is not used 2018-04-16 21:44:09 1838 [Note] InnoDB: Compressed tables use zlib 1.2.3 2018-04-16 21:44:09 1838 [Note] InnoDB: Using Linux native AIO 2018-04-16 21:44:09 1838 [Note] InnoDB: Using CPU crc32 instructions 2018-04-16 21:44:09 1838 [Note] InnoDB: Initializing buffer pool, size = 2.0G 2018-04-16 21:44:09 1838 [Note] InnoDB: Completed initialization of buffer pool 2018-04-16 21:44:09 1838 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created! 2018-04-16 21:44:09 1838 [Note] InnoDB: Setting file ./ibdata1 size to 1024 MB 2018-04-16 21:44:09 1838 [Note] InnoDB: Database physically writes the file full: wait... InnoDB: Progress in MB: 100 200 300 400 500 600 700 800 900 1000 2018-04-16 21:44:12 1838 [Note] InnoDB: Setting log file ./ib_logfile101 size to 128 MB InnoDB: Progress in MB: 100 2018-04-16 21:44:13 1838 [Note] InnoDB: Setting log file ./ib_logfile1 size to 128 MB InnoDB: Progress in MB: 100 2018-04-16 21:44:13 1838 [Note] InnoDB: Setting log file ./ib_logfile2 size to 128 MB InnoDB: Progress in MB: 100 2018-04-16 21:44:13 1838 [Note] InnoDB: Data file ./undo001 did not exist: new to be created 2018-04-16 21:44:13 1838 [Note] InnoDB: Setting file ./undo001 size to 10 MB 2018-04-16 21:44:13 1838 [Note] InnoDB: Database physically writes the file full: wait... 2018-04-16 21:44:14 1838 [Note] InnoDB: Data file ./undo002 did not exist: new to be created 2018-04-16 21:44:14 1838 [Note] InnoDB: Setting file ./undo002 size to 10 MB 2018-04-16 21:44:14 1838 [Note] InnoDB: Database physically writes the file full: wait... 2018-04-16 21:44:14 1838 [Note] InnoDB: Data file ./undo003 did not exist: new to be created 2018-04-16 21:44:14 1838 [Note] InnoDB: Setting file ./undo003 size to 10 MB 2018-04-16 21:44:14 1838 [Note] InnoDB: Database physically writes the file full: wait... 2018-04-16 21:44:14 1838 [Note] InnoDB: Opened 3 undo tablespaces 2018-04-16 21:44:14 1838 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0 2018-04-16 21:44:14 1838 [Warning] InnoDB: New log files created, LSN=48425 2018-04-16 21:44:14 1838 [Note] InnoDB: Doublewrite buffer not found: creating new 2018-04-16 21:44:14 1838 [Note] InnoDB: Doublewrite buffer created 2018-04-16 21:44:14 1838 [Note] InnoDB: 128 rollback segment(s) are active. 2018-04-16 21:44:14 1838 [Warning] InnoDB: Creating foreign key constraint system tables. 2018-04-16 21:44:15 1838 [Note] InnoDB: Foreign key constraint system tables created 2018-04-16 21:44:15 1838 [Note] InnoDB: Creating tablespace and datafile system tables. 2018-04-16 21:44:15 1838 [Note] InnoDB: Tablespace and datafile system tables created. 2018-04-16 21:44:15 1838 [Note] InnoDB: Waiting for purge to start 2018-04-16 21:44:15 1838 [Note] InnoDB: 5.6.39 started; log sequence number 0 2018-04-16 21:44:16 1838 [Note] Binlog end 2018-04-16 21:44:16 1838 [Note] InnoDB: FTS optimize thread exiting. 2018-04-16 21:44:16 1838 [Note] InnoDB: Starting shutdown... 2018-04-16 21:44:18 1838 [Note] InnoDB: Shutdown completed; log sequence number 1508992 2018-04-16 21:44:18 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap. 2018-04-16 21:44:18 0 [Note] /usr/sbin/mysqld (mysqld 5.6.39-log) starting as process 1860 ... 2018-04-16 21:44:18 1860 [Note] InnoDB: Using atomics to ref count buffer pool pages 2018-04-16 21:44:18 1860 [Note] InnoDB: The InnoDB memory heap is disabled 2018-04-16 21:44:18 1860 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2018-04-16 21:44:18 1860 [Note] InnoDB: Memory barrier is not used 2018-04-16 21:44:18 1860 [Note] InnoDB: Compressed tables use zlib 1.2.3 2018-04-16 21:44:18 1860 [Note] InnoDB: Using Linux native AIO 2018-04-16 21:44:18 1860 [Note] InnoDB: Using CPU crc32 instructions 2018-04-16 21:44:18 1860 [Note] InnoDB: Initializing buffer pool, size = 2.0G 2018-04-16 21:44:18 1860 [Note] InnoDB: Completed initialization of buffer pool 2018-04-16 21:44:18 1860 [Note] InnoDB: Opened 3 undo tablespaces 2018-04-16 21:44:18 1860 [Note] InnoDB: Highest supported file format is Barracuda. 2018-04-16 21:44:18 1860 [Note] InnoDB: 128 rollback segment(s) are active. 2018-04-16 21:44:18 1860 [Note] InnoDB: Waiting for purge to start 2018-04-16 21:44:18 1860 [Note] InnoDB: 5.6.39 started; log sequence number 1508992 2018-04-16 21:44:29 1860 [Note] Binlog end 2018-04-16 21:44:29 1860 [Note] InnoDB: FTS optimize thread exiting. 2018-04-16 21:44:29 1860 [Note] InnoDB: Starting shutdown... 2018-04-16 21:44:31 1860 [Note] InnoDB: Shutdown completed; log sequence number 1509002 PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -u root password 'new-password' /usr/bin/mysqladmin -u root -h king01 password 'new-password' Alternatively you can run: /usr/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. Please report any problems at http://bugs.mysql.com/ The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at http://shop.mysql.com Note: new default config file not created. Please make sure your config file is current WARNING: Default config file /etc/my.cnf exists on the system This file will be read by default by the MySQL server If you do not want to use this, either remove it, or use the --defaults-file argument to mysqld_safe when starting the server [ OK ] Logging to '/var/lib/mysql/king01.err'. Starting mysqld: [ OK ] [[email protected] ~]# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation. Set root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist ... Failed! Not critical, keep moving... - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! All done! If you've completed all of the above steps, your MySQL installation should now be secure. Thanks for using MySQL! Cleaning up...
[[email protected] ~]# mysql -uroot -pabcd.1234 mysql> create database icinga default character set utf8; Query OK, 1 row affected (0.07 sec) mysql> grant all on icinga.* to 'icinga'@'localhost' identified by 'icinga'; Query OK, 0 rows affected (0.04 sec) mysql> flush privileges; Query OK, 0 rows affected (0.04 sec)
[[email protected] ~]# yum install -y httpd gcc glibc glibc-common gd gd-devel libjpeg libjpeg-devel openssl openssl-devel libpng libpng-devel libdbi libdbi-devel libdbi-drivers libdbi-dbd-mysql
[[email protected] ~]# useradd icinga [[email protected] ~]# usermod -a -G icinga apache
[[email protected] ~]# tar xvf icinga-cn-1.12.2.tar.xz [[email protected] ~]# cd icinga-cn-1.12.2 [[email protected] icinga-cn-1.12.2]# ./configure --prefix=/usr/local/icinga --with-icinga-user=icinga --with-icinga-group=icinga --with-command-user=icinga --with-command-group=icinga --with-perl_lib_path=/usr/lib64/perl5 --with-libdbi-driver-dir=/usr/lib64 --enable-perfdata --enable-nanosleep --enable-event-broker --enable-idoutils --with-httpd-conf=/etc/httpd/conf.d [[email protected] icinga-cn-1.12.2]# make all [[email protected] icinga-cn-1.12.2]# make install [[email protected] icinga-cn-1.12.2]# make install-init [[email protected] icinga-cn-1.12.2]# make install-commandmode [[email protected] icinga-cn-1.12.2]# make install-eventhandlers [[email protected] icinga-cn-1.12.2]# make install-idoutils [[email protected] icinga-cn-1.12.2]# make install-config [[email protected] icinga-cn-1.12.2]# [[email protected] icinga-cn-1.12.2]# make install-webconf [[email protected] icinga-cn-1.12.2]# make install-webconf-auth [[email protected] icinga-cn-1.12.2]# make cgis [[email protected] icinga-cn-1.12.2]# make install-cgis [[email protected] icinga-cn-1.12.2]# make install-html
[[email protected] icinga-cn-1.12.2]# cd module/idoutils/db/mysql/ [[email protected] mysql]# mysql -uroot -pabcd.1234 icinga < mysql.sql
[[email protected] ~]# htpasswd -c /usr/local/icinga/etc/htpasswd.users icingaadmin New password: Re-type new password: Adding password for user icingaadmin [[email protected] mysql]# service httpd restart
[[email protected] ~]# tar xvf nagios-cn-plugins-2.0.3.tar.xz [[email protected] ~]# cd nagios-cn-plugins-2.0.3 [[email protected] nagios-cn-plugins-2.0.3]# ./configure --prefix=/usr/local/icinga --with-package-name=icinga-plugins --with-cgiurl=/icinga/cgi-bin --with-nagios-user=icinga --with-nagios-group=icinga [[email protected] nagios-cn-plugins-2.0.3]# make [[email protected] nagios-cn-plugins-2.0.3]# make install
[[email protected] ~]# service ido2db start Starting Ido2db: done. [[email protected] ~]# service ido2db status Ido2db (pid 14450) is running... [[email protected] ~]# service icinga start Running configuration check...OK Starting icinga: Starting icinga done. [[email protected] ~]# service icinga status Icinga (pid 14479) is running...
以上是关于开源监控解决方案:Icinga(Nagios)部署实录的主要内容,如果未能解决你的问题,请参考以下文章
开源监控解决方案:ICINGA(Nagios)Email Notification