zabbix3.2.5编译安装部署

Posted 会飞的鱼

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zabbix3.2.5编译安装部署相关的知识,希望对你有一定的参考价值。

 
LNMP基础环境安装
下载mysql,为了更加快的部署 采用的二进制安装包
[[email protected] ~]# wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
 
安装需要的依赖包
[[email protected] ~]# yum -y install perl perl-devel libaio
 
新建mysql用户
[[email protected] ~]# useradd -s /sbin/nologin -M mysql
 
创建目录
[[email protected] ~]# mkdir -p /data/mysql/data
[[email protected] ~]# chown -R mysql:mysql /data/mysql/data/
 
解压和初始化
[[email protected] ~]# tar zxvf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
[[email protected] ~]# mv mysql-5.6.35-linux-glibc2.5-x86_64 /usr/local/mysql
[[email protected] ~]# cd /usr/local/mysql/
[[email protected] ~]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql/data/
 
拷贝配置文件
[[email protected] ~]# cp support-files/my-default.cnf /etc/my.cnf
[[email protected] ~]# cp support-files/mysql.server /etc/init.d/mysqld
 
[[email protected] ~]# chmod 755 /etc/init.d/mysqld
[[email protected] ~]# vim /etc/init.d/mysqld # 找到bashedir 增加下面的路径
basedir=/usr/local/mysql    
datadir=/data/mysql/data         
 
设置开机启动
[[email protected] ~]# chkconfig --add mysqld
[[email protected] ~]# chkconfig mysqld on
[[email protected] ~]# service mysqld start
[[email protected] ~]# netstat -lnpt
 
php安装
#安装依赖包关系
[[email protected] ~]# yum install -y libxml2-devel openssl openssl-devel bzip2 bzip2-devel libpng libpng-devel freetype freetype-devel gcc-c++ libcurl-devel libjpeg-devel pcre-devel
 
#下载php安装包
[[email protected] ~]# wget http://mirrors.sohu.com/php/php-5.6.9.tar.gz
[[email protected] ~]# tar zxvf php-5.6.9.tar.gz
 
解压安装
[[email protected] ~]# cd php-5.6.9
[[email protected] ~]# ./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
 
[[email protected] ~]# make && make install
 
#拷贝配置文件
[[email protected] ~]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[[email protected] ~]# useradd -s /sbin/nologin -M php-fpm
[[email protected] ~]# cp /root/php-5.6.9/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[[email protected] ~]# chmod +x /etc/init.d/php-fpm
[[email protected] ~]# chkconfig --add php-fpm
[[email protected] ~]# service php-fpm start
 
#拷贝php.ini
[[email protected] ~]# cp php.ini-production /usr/local/php/etc/php.ini
[[email protected] ~]# vim /usr/local/php/etc/php.ini #修改以下参数,否则zabbix安装不了
 
max_execution_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_input_time = 300
date.timezone = PRC
 
#重启
[[email protected] ~]# service php-fpm restart
 
 
安装nginx
下载nginx
[[email protected] ~]# wget http://mirrors.sohu.com/nginx/nginx-1.13.0.tar.gz
[[email protected] ~]# tar zxvf nginx-1.13.0.tar.gz
[[email protected] ~]# cd nginx-1.13.0
[[email protected] ~]# ./configure --prefix=/usr/local/nginx --with-http_realip_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --with-pcre
 
[[email protected] ~]# make && make install
[[email protected] ~]# vim /etc/init.d/nginx
[[email protected] ~]# chmod 755 /etc/init.d/nginx
[[email protected] ~]# chkconfig --add nginx
[[email protected] ~]# chkconfig nginx on
[[email protected] ~]# service nginx start
[[email protected] ~]# mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak
[[email protected] ~]# vim /usr/local/nginx/conf/nginx.conf
[[email protected] ~]# /usr/local/nginx/sbin/nginx -t
[[email protected] ~]# service nginx reload
 
安装zabbix
下载 安装包
[[email protected] ~]# wget https://ncu.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.2.5/zabbix-3.2.5.tar.gz
 
增加用户
[[email protected] ~]# useradd -M -s /sbin/nlogin zabbix
 
解压
[[email protected] ~]# tar zxvf zabbix-3.2.5.tar.gz
[[email protected] ~]# cd zabbix-3.2.5
 
#新建数据并导入数据
[[email protected] ~]# mysql -uroot
mysql> create database zabbix character set utf8 collate utf8_general_ci;
mysql> grant all on zabbix.* to [email protected]‘localhost‘ identified by ‘zabbix‘;
 
[[email protected] ~]# mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql
[[email protected] ~]# mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql
[[email protected] ~]# mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql
 
安装
 
[[email protected] ~]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurl
[[email protected] ~]# make install
 
安装zabbix过程中
configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config
[[email protected] zabbix-3.2.5]# yum install net-snmp-devel
 
配置zabbix_server配置文件,
[[email protected] ~]# vim /usr/local/zabbix/etc/zabbix_server.conf
增加一下的配置内容,配置zabbix连接mysql
DBName=zabbix
DBUser=root
DBPassword=zabbix
DBPort=3306
[[email protected] ~]# vim /usr/local/zabbix/etc/zabbix_agentd.conf
Server=127.0.0.1 #默认监控服务器自己,这三行不用改
ServerActive=127.0.0.1
Hostname=Zabbix server
UnsafeUserParameters=1 #允许所有的字符是在用户定义的参数,参数传递,也就是支持自定义脚本
[[email protected] ~]# /usr/local/zabbix/sbin/zabbix_server #直接启动zabbix_server
#启动有报错,解决方法如下
[[email protected] ~]# find / -name libmysqlclient.so.18
[[email protected] ~]# echo "/usr/local/mysql/lib" >> /etc/ld.so.conf
[[email protected] ~]# ldconfig
 
[[email protected] ~]# /usr/local/zabbix/sbin/zabbix_server #修改后重新启动
[[email protected] ~]# netstat -lnpt #查看端口是否启动
 
Zabbix默认有部分启动脚本,如果你自己也可以通过脚本的方式来实现,可以使用他的模板来实现
脚本在源码目录的misc/init.d/下面(使用fedora下面的core即可,也可以使用fedroa core5的脚本均可)
复制脚本到 init.d目录下
[[email protected] ~]# cd zabbix-3.2.5/misc/init.d/
[[email protected] ~]# cp fedora/core/zabbix_server /etc/init.d/
[[email protected] ~]# cp fedora/core/zabbix_agentd /etc/init.d/
 
修改脚本配置
[[email protected] ~]# vim /etc/init.d/zabbix_server
BASEDIR=/usr/local/zabbix  #找到此行,并修改成zabbix安装的绝对路径
[[email protected] ~]# vim /etc/init.d/zabbix_agentd
BASEDIR=/usr/local/zabbix  #找到此行,并修改成zabbix安装的绝对路径
设置开机启动
[[email protected] ~]# chkconfig --add zabbix_agentd
[[email protected] ~]# chkconfig --add zabbix_server
[[email protected] ~]# chkconfig zabbix_agentd on
[[email protected] ~]# chkconfig zabbix_server on
 
[[email protected] ~]# service zabbix_agentd start
[[email protected] ~]# service zabbix_server restart
 
 
修改完成后,配置nginx 的虚拟主机,修改完成后拷贝php安装文件到虚拟主机的目录
 
cp -r /root/zabbix-3.2.5/frontends/php/* /data/zabbix/
然后在网页上进行安装
安装可能会出现的问题 always-populate-raw-post-data = -1
vim /目录/zabbix/include/classes/setup/CFrontendSetup.php
找到下面代码、关于always-populate-raw-post-data;

添加 $current = -1;

public function checkPhpAlwaysPopulateRawPostData() {
$current = ini_get(‘always_populate_raw_post_data‘);
$current = -1;
return array(
‘name‘ => _(‘PHP always_populate_raw_post_data‘),
‘current‘ => ($current != -1) ? _(‘on‘) : _(‘off‘),
‘required‘ => _(‘off‘),
‘result‘ => ($current != -1) ? self::CHECK_FATAL : self::CHECK_OK,
‘error‘ => _(‘PHP always_populate_raw_post_data must be set to -1.‘)
);
}
 
 
客户端安装
[[email protected] ~]# tar zxvf zabbix-3.2.5.tar.gz
[[email protected] ~]# cd zabbix-3.2.5
[[email protected] ~]# ./configure --prefix=/usr/local/zabbix --enable-agent
useradd -M -s /sbin/nlogin zabbix
 
方法二 rpm直接安装
rpm -ivh zabbix-agent-3.2.5-1.el6.x86_64.rpm
vim /etc/zabbix/zabbix_agentd.conf
修改客户端的配置文件,修改一下信息
Server=125.88.37.28
ServerActive=125.88.37.28
Hostname=hadoop server2
HostMetadata=linux
UnsafeUserParameters=1
 
 
/etc/init.d/zabbix-agent start
#记得要关闭防火墙 以免不能启动报错。
 
 
Zabbix 监控 Windows 的 CPU 百分比

以上是关于zabbix3.2.5编译安装部署的主要内容,如果未能解决你的问题,请参考以下文章

RAMCloud编译部署指南

源码编译安装LNMP及论坛部署

LNMP源码编译安装及一键部署LNMP架构

Spark入门实战系列--2.Spark编译与部署(下)--Spark编译安装

Spark入门实战系列--2.Spark编译与部署(下)--Spark编译安装

Spark入门实战系列--2.Spark编译与部署(中)--Hadoop编译安装