This operation step is based on the installation of Apache and PHP. For details on how to install Apache and Php, please refer to the installation chapter of [nagios host monitoring system] Installation of Apache and PHP
1. Download the software,
[root@node1 ~]# wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/2.0.6/zabbix-2.0.6.tar.gz/download
2. Install the components required by zabbix (server, agent)
[root@node1 ~]# yum -y install curl curl-devel net-snmp net-snmp-devel perl-DBI
3. Create a user account (server, agent)
[ root@node1 ~]# groupadd zabbix
[root@node1 ~]# useradd -g zabbix zabbix
[root@node1 ~]# usermod -s /sbin/nologin zabbix
4. Create zabbix database and import zabbix database data (server)
[root @node1 ~]# mysql -u root -p123456
mysql> grant all on zabbix.* to zabbix@localhost identified by '123456';
Query OK, 0 rows affected (2.50 sec)
mysql> create database zabbix;
Query OK, 1 row affected (0.09 sec)
[root@node1 opt]# tar zxvf zabbix-2.0.6.tar.gz
[root@node1 opt]# cd zabbix-2.0.6
[root@node1 zabbix-2.0.6]# mysql -uzabbix -p123456 zabbix < database/mysql/schema.sql
Warning: Using a password on the command line interface can be insecure.
[root@node1 zabbix-2.0.6]# mysql -uzabbix -p123456 zabbix < database/mysql/images.sql
Warning: Using a password on the command line interface can be insecure.
[root@node1 zabbix-2.0.6]# mysql -uzabbix -p123456 zabbix < database/mysql/data.sql
Warning: Using a password on the command line interface can be insecure.
5.编译安装(server,agent)
server: (192.168.7.201)
[root@node1 ~]# ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl
ti/CORE -I. -I/usr/include/net-snmp
Enable server: yes
Server details:
With database: MySQL
WEB Monitoring via: cURL
Native Jabber: no
SNMP: net-snmp
IPMI: no
SSH: no
ODBC: no
Linker flags: -rdynamic -L/usr/local/mysql/lib -L/usr/kerberos/lib64 -L/usr/lib64 -L/usr/lib64 -L/usr/lib64/lib -L/usr/lib64 -L/usr/lib64 -L/usr/lib64/lib
Libraries: -lm -lrt -lresolv -lmysqlclient -lcurl -ldl -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lidn -lssl -lcrypto -lz -lnetsnmp -lcrypto -lm -lwrap -lcrypto -lnetsnmp -lcrypto -lm -lwrap -lcrypto
Enable proxy: no
Enable agent: yes
Agent details:
Linker flags: -rdynamic -L/usr/kerberos/lib64
Libraries: -lm -lrt -lresolv -lcurl -ldl -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lidn -lssl -lcrypto -lz
Enable Java gateway: no
LDAP support: no
IPv6 support: yes
***********************************************************
* Now run 'make install' *
* *
* Thank you for using Zabbix! *
* <http://www.zabbix.com> *
***********************************************************
# make install
agent: (192.168.7.249)
# ./configure --enable-agent
Configuration:
Detected OS: linux-gnu
Install path: /usr/local
Compilation arch: linux
Compiler: gcc
Compiler flags: -g -O2
Enable server: no
Enable proxy: no
Enable agent: yes
Agent details:
Linker flags: -rdynamic
Libraries: -lm -lrt -lresolv
Enable Java gateway: no
LDAP support: no
IPv6 support: no
***********************************************************
* Now run 'make install' *
* *
* Thank you for using Zabbix! *
* <http://www.zabbix.com> *
***********************************************************
# make install
Here, the author forgot to customize the installation directory when compiling, so the zabbix configuration file uses the default path. Under /usr/local/etc/, if you recompile here, there will be many changes below, and the following content will be This path prevails.
For friends who refer to the configuration of this blog, it is recommended to add the --prefix=/usr/local/zabbix parameter when compiling, then the zabbix configuration file is in the /usr/local/zabbix/etc directory by default, and the bin in the zabbix directory needs to be loaded before starting the service later. Environment variables with the sbin directory
The bin and sbin directories under the default zabbix installation path /usr/local/ do not need to load environment variables because they are merged with the system
. Edit configuration files (server, agent)
[root@node1 ~]# cd /usr /local/etc/
Remove configuration file comments:
# cat zabbix_server.conf |grep -v "#" |grep -v "^$" > zabbix_server.conf.bak
# cp zabbix_server.conf.bak zabbix_server.conf
# cat zabbix_agentd. conf |grep -v "#" |grep -v "^$" > zabbix_agentd.conf.bak
# cp zabbix_agentd.conf.bak zabbix_agentd.conf
server: (192.168.7.201)
# vi /usr/local/etc/zabbix_server.
-------------
LogFile=/var/log/zabbix_server.log
DBHost=localhost
DBName=
zabbix DBUser=
zabbix DBPassword=123456
-------------
# vi /usr/local/etc/zabbix_agentd.conf
Modify the following and delete other unmodified parameter entries:
-------------
LogFile=/var/log/zabbix_agentd.log
Server=127.0.0.1, 192.168.7.201
UnsafeUserParameters=1
-------------
agent: (192.168.7.249)
# vi /usr/local/etc/zabbix_agentd.conf
Modify the following and delete other unmodified parameter entries:
- ------------
LogFile=/var/log/zabbix_agentd.log
Server=192.168.7.201
UnsafeUserParameters=1
-------------
# touch /var/log/ zabbix_server.log
# chmod 777 /var/log/zabbix_server.log
# touch /var/log/zabbix_agentd.log
# chmod 777 /var/log/zabbix_agentd.log
7. Start the daemon (server, agent)
on the server side to run and start zabbix_server
# zabbix_server
server start port is 10051
and run zabbix_agentd on all monitored machines.
[root@node1 etc]# zabbix_server
zabbix_server: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
1. First confirm whether the file libmysqlclient.so.18 exists under /usr/local/mysql/lib/.
ll /usr/local/mysql/lib/|grep libmysqlclient.so.18
2. Modify the ld.so.conf file
echo "/usr/local/mysql/lib" >>/etc/ld.so.conf
and then execute ldconfig to make it take effect.
[root@node1 etc]# zabbix_server
zabbix_server: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
[root@node1 etc]# locate libmysqlclient.so.18
[root@node1 etc]# locate libmysqlclient.*
[root@node1 etc]# whereis libmysqlclient.so.18
libmysqlclient.so:
[root@node1 etc]# ll /usr/local/mysql/lib/|grep libmysqlclient.so.18
lrwxrwxrwx 1 mysql mysql 20 Jan 7 20:39 libmysqlclient_r.so.18 -> libmysqlclient.so.18
lrwxrwxrwx 1 mysql mysql 24 Jan 7 20:39 libmysqlclient_r.so.18.1.0 -> libmysqlclient.so.18.1.0
lrwxrwxrwx 1 mysql mysql 20 Jan 7 20:39 libmysqlclient.so -> libmysqlclient.so.18
lrwxrwxrwx 1 mysql mysql 24 Jan 7 20:39 libmysqlclient.so.18 -> libmysqlclient.so.18.1.0
-rwxr-xr-x 1 mysql mysql 8132645 Jan 7 20:25 libmysqlclient.so.18.1.0
[root@node1 etc]# echo "/usr/local/mysql/lib" >>/etc/ld.so.conf
[root@node1 etc]# ldconfig
[root@node1 etc]# service zabbix_server restart
zabbix_server: unrecognized service
[root@node1 etc]# zabbix_server
[root@node1 etc]# zabbix_agentd
[root@node1 etc]# cd /opt/zabbix-2.0.6
[root@node1 zabbix-2.0.6]# cp misc/init.d/tru64/zabbix_server /etc/init.d/zabbix_server
[root@node1 zabbix-2.0.6]# cp misc/init.d/tru64/zabbix_agentd /etc/init.d/zabbix_agentd
[root@node1 zabbix-2.0.6]# cd /etc/init.d/
[root@node1 init.d]# chmod 755 zabbix_*
[root@node1 init.d]# chkconfig --add zabbix_server
service zabbix_server does not support chkconfig
[root@node1 init.d]# chkconfig --add zabbix_server
service zabbix_server does not support chkconfig
[root@node1 init.d]# mkdir /usr/local/apache2/htdocs/zabbix
[root@node1 init.d]# cd frontends/php
-bash: cd: frontends/php: No such file or directory
[root@node1 init.d]# cd /opt/zabbix-2.0.6
[root@node1 zabbix-2.0.6]# cd frontends/php
[root@node1 php]# cp -a . /usr/local/apache2/htdocs/zabbix
8. Install the zabbix web interface (server)
Copy the ZABBIX PHP source code file
The server program of zabbix is written in php, so a server platform that supports the LAMP architecture is required.
Now put the php source code file under frontends/php in the ZABBIX installation directory Copy it to the web server html file directory.
It is recommended to replace the APACHE HTML root directory with a subdirectory or use the APACHE virtual host
for the test environment here. I chose the former for convenience.
First create a subdirectory, copy the zabbix terminal php file into the subdirectory, and execute the following command:
# mkdir /usr/local/apache2/htdocs/zabbix
# cd frontends/php
# cp -a . /usr/local/ apache2/htdocs/zabbix
Install the front end
步骤一、重新编译PHP:
./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc --with-bz2 --with-curl \
--enable-ftp --enable-sockets --disable-ipv6 --with-gd \
--with-jpeg-dir=/usr/local --with-png-dir=/usr/local \
--with-freetype-dir=/usr/local --enable-gd-native-ttf \
--with-iconv-dir=/usr/local --enable-mbstring --enable-calendar \
--with-gettext --with-libxml-dir=/usr/local --with-zlib \
--with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd \
--enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath \
--with-apxs2=/usr/local/apache2/bin/apxs
configure: error: Please reinstall the BZip2 distribution
The reasons are as follows:
1. Make sure bzip2 and bzip2-devl are installed, if not installed:
yum install bzip2
yum install bzip2-devel
configure: error: png.h not found.
[root@node1 php-5.4.10]# yum install libpng*
Installed: libpng-devel.x86_64 2:1.2.10-17.el5_8 libpng-devel.i386 2:1.2.10-17.el5_8
Complete!
Configure: error: freetype.h not found.
Solution
CentOS
yum install freetype-devel
Step 2 Compile:
make
Step 3 Install:
make install
"a.php" [New] 5L, 27C written
Confirm the path of the PHP configuration file:
[root@node1 bin]# ./php a.php | grep php.ini
Configuration File (php.ini) Path => /usr/local/php/etc
Loaded Configuration File => /usr /local/php/etc/php.ini
/usr/local/apache2/bin/apachectl restart
zabbix_server restart
zabbix_agentd restart
max_execution_time = 300
max_input_time = 300
memory_limit = 128M
post_max_size = 32M
date.timezone = Asia/Shanghai
mbstring.func_overload=2