How to install and use Zabbix in CentOS6.5
Zabbix is an enterprise-level open-source solution that provides distributed system monitoring and network monitoring functions based on the WEB interface. Zabbix can monitor various network parameters to ensure secure operation of server systems. It also provides a flexible notification mechanism for system administrators to quickly locate and solve various problems. In a common enterprise environment, zabbix consists of two parts: zabbix server and the optional component zabbix agent. The running environment of this series is CentOS6.5, and zabbix is the latest stable version 2.4.7 on the official website. Before using zabbix, you must first learn to install zabbix. In the documentation on the official website, yum or apt is the first installation method. This method is relatively simple and suitable for Internet access environments. However, in some enterprise-level environments, strict Intranet and Internet isolation policies are implemented. Direct Internet connection is not allowed to the Intranet, and most servers must be monitored to run in the intranet. Therefore, in this case, you need to install zabbix in another way, that is, source code installation. This article describes how to install zabbix source code.
Some Zabbix Tutorials:
Compile and install Zabbix2.4.5 source code in Ubuntu 14.04
Install and deploy the distributed monitoring system Zabbix 2.06
Install and deploy the distributed monitoring system Zabbix 2.06
Install and deploy Zabbix in CentOS 6.3
Zabbix distributed monitoring system practice
Under CentOS 6.3, Zabbix monitors apache server-status
Monitoring MySQL database Parameters Using Zabbix in CentOS 6.3
Install Zabbix 2.0.6 in 64-bit CentOS 6.2
Local yum sources are configured due to network restrictions, but some dependent packages have to be installed. Therefore, they can only be configured from local yum sources. Assume that the rpm Packages have been copied from the CD to the/ISO/Packages directory. Create a local yum source in the following order.
- Install the createrepo package to create a local repository for installation and update of the yum source.
cd /ISO/Packagesll|grep createreporpm –ivh createrepo-0.9.9-18.e16.noarch.rpm
If you are prompted to install the dependency package during installation, follow the prompts to install the package.
- Run the createrepo command to create the repodata directory.
cd /ISO/Packagescreaterepo .
Cd/etc/yum. repo. dmv CentOS-Base.repo CentOS-Base.repo.bakcp CentOS-Media.repo CentOS-Base.repovi CentOS-Base.repo to make the following configuration changes: # yum source location baseurl = file: /// ISO/Packages/# do not check gpgcheck = 0 # Set to install enabled = 1 in yum through local media
Yum clean all
Yum makecache
Install Mysql database
Zabbix can be installed on multiple databases. In this solution, the database is mysql. The installation and database table creation are as follows:
- Install mysql5.6.28 by using rpm. If the old mysql instance already exists before installation, uninstall it.
rpm –ivh MySQL-server-5.6.28-1.el6.x86_64.rpmrpm –ivh MySQL-client-5.6.28-1.el6.x86_64.rpmrpm –ivh MySQL-devel-5.6.28-1.el6.x86_64.rpmrpm –ivh MySQL-shared-compat-5.6.28-1.el6.x86_64.rpm
- Add a soft connection to mysqlclient (if not added, the following error may be reported during zabbix installation ).
cd /usr/lib64ln -s libmysqlclient.so.16.0.0 libmysqlclient.so ln -s libmysqlclient_r.so.16.0.0 libmysqlclient_r.so
- After installation, the default configuration file is/usr/my. cnf. The default mysql root Account Password is saved in/root/. mysql_secret.
- Check whether mysql is in the random start list. If not, add and start mysql.
chkconfig --list|grep mysqlchkconfig --add mysqlchkconfig mysql on
service mysql start
- Modify the password of the root account.
mysql –uroot –pset password=password('123456');flush privileges;
- Create a zabbix database and its access account.
create database zabbix character set utf8 collate utf8_bin;grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';flush privileges;
- Initialize the zabbix database.
mysql -uzabbix –p zabbix < schema.sqlmysql -uzabbix –p zabbix < images.sqlmysql -uzabbix –p zabbix < data.sql
Install zabbix Server
- Download and decompress zabbix2.4.7
cd /usr/local/srctar –xvf zabbix-2.4.7.tar.gzcd zabbix-2.4.7
- Add zabbix account (note that zabbix server and client are both running under the zabbix account by default, and you need to add this account on your own. You can also modify the server configuration file to specify that zabbix server runs under the root account. This is not recommended)
groupadd zabbixuseradd –g zabbix zabbix
- Install zabbix. If any dependency package is missing, add it as prompted.
yum -y install net-snmp net-snmp-devel curl curl-devel libxml2 libxml2-devel
./configure --prefix=/usr/local/zabbix --enable-server --with-mysql --with-net-snmp --with-libcurl --with-libxml2
make && make install
- Modify the configuration file of zabbix server
vi /usr/local/zabbix/etc/zabbix_server.confLogFile=/var/log/zabbix/zabbix_server.logLogFileSize=10DBHost=localhostDBName=zabbixDBUser=zabbixDBPassword=zabbix
- Set the Log Path and access permissions of zabbix server
mkdir /var/log/zabbixchown -R zabbix:zabbix /var/log/zabbix
- Set zabbix server to random start and start
Cp/usr/local/src/zabbix-2.4.7/misc/init. d/Fedora/core/zabbix_server/etc/init. dvi/etc/init. d/zabbix_server # modify zabbix path BASEDIR =/usr/local/zabbixchkconfig -- add zabbix_serverchkconfig zabbix_server on
Service zabbix_server start
- Check whether zabbix server is correctly started
Netstat-tlnp | grep zabbix # You Can See That zabbix server is running on port 10051, ps-ef | grep zabbix # You Can See That zabbix server is running under zabbix account, and multiple process listening is enabled.
Install libjpeg & freetype
Zabbix server has graphical requirements and requires the support of PHP gd. These two items are required by PHP gd. Because PHP does not support the installation of these two components by default, you need to install these two components in advance.
- Install freetype-2.6.tar.gz
cd /usr/local/srctar -xvf freetype-2.6.tar.gz
cd freetype-2.6./configure --prefix=/usr/local/freetypemake && make install
- Install strongsrc.v6b.tar.gz
cd /usr/local/src
tar -xvf jpegsrc.v6b.tar.gz
cd jpeg-6b
./configure --prefix=/usr/local/jpeg --enable-shared
make && make install
During installation, if an error similar to "make:./libtool: Command not found" is reported, you must overwrite the libtool configuration file in the system to the old corresponding jpeg file.
cp /usr/share/libtool/config/config.sub .cp /usr/share/libtool/config/config.guess .make clean./configure --prefix=/usr/local/jpeg --enable-shared
During installation, if an error similar to "cannot create regular file '/usr/local/jpeg/include/jconfig. h': No such file or directory ", You need to manually create the corresponding directory.
mkdir -p /usr/local/jpeg/includemkdir -p /usr/local/jpeg/libmkdir -p /usr/local/jpeg/binmkdir -p /usr/local/jpeg/man/man1make && make install
Install PHP
Zabbix server is compiled by php, so you need to install the php runtime environment.
- Create a php Running Account
groupadd wwwuseradd –g www www
- Download and decompress php-5.6.16.tar.bz2
cd /usr/local/srctar –xvf php-5.6.16.tar.bz2cd php-5.6.16
yum -y install libpng-devel./configure --prefix=/usr/local/php --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --enable-sockets --with-gd --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype --with-gettext --enable-mbstring --enable-bcmath --with-config-file-path=/usr/local/php/etcmake && make install
If a dependency package is missing during installation, follow the prompts to install the package.
- Add the PHP Command to the environment variable.
Vi/etc/profile # Add: export PATH = $ PATH:/usr/local/php/bin # effective immediately: source/etc/profile
cd /usr/local/php/etccp php-fpm.conf.default php-fpm.conf
- Configure the php. ini file to meet the minimum running requirements of zabbix.
cp /usr/local/src/php-5.6.16/php.ini-production /usr/local/php/etc/php.inivi /usr/local/php/etc/php.inipost_max_size = 16Mmax_execution_time = 300max_input_time = 300always_populate_raw_post_data = -1date.timezone = Asia/Shanghai
- Set php to start at random.
# Boot vi/etc/rc. local/usr/local/php/sbin/php-fpm # Start/usr/local/php/sbin/php-fpm immediately
After the startup, you can observe that php runs on port 9000.
Install Nginx
Zabbix server needs to run on the web server. It is recommended to install it on apache on the official website. This solution runs on nginx by using the following method:
- Download and install nginx-1.8.0.tar.gz
cd /usr/local/srctar –xvf nginx-1.8.0.tar.gzcd nginx-1.8.0
yum -y install pcre-devel./configure --with-http_ssl_module --with-http_realip_modulemake && make install
If the dependency package is missing during the above installation, install it as prompted
- Modify the nginx configuration file as follows:
user www www;work_processes auto; location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
- Copy the running file of zabbix server to the nginx directory.
cd /usr/local/nginx/htmlmkdir zabbixcd zabbixcp -r /usr/local/src/zabbix-2.4.7/frontends/php/* .cd ..chown –R www:www zabbix
- Set nginx to start and start nginx.
# Start vi/etc/rc. local/usr/local/nginx/sbin/nginx # Start nginx/usr/local/nginx/sbin/nginx
Initialize zabbix server
After nginx is started, you can directly access zabbix server: http: // localhost/zabbix/index. php. The Initialization is configured on the GUI.
- First, check whether the php runtime environment is correct.
- Second, ensure that the database connection is correct
- Configure the port and host
- Confirm configuration options again
Now, the source code of zabbix server has been successfully installed. On the logon page, the default logon name and password are Admin/zabbix.
For more details, please continue to read the highlights on the next page:
[Content navigation] |
Page 1: source code Installation |
Page 2nd: yum Installation |
Page 3rd: agent installation |
Page 4th: mail Client installation |
Page 1: How to quickly build an alarm system |
Page 6th: zabbix server solves the problem on the Internet while the mail sending server is on the Intranet |
Page 7th: remotely operate the monitored Machine |
|