zabbix安装
Posted 一路翊扬
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zabbix安装相关的知识,希望对你有一定的参考价值。
1.安装mysql
下载
到mysql官网下载mysql安装包:安装
yum install mysql-community-{server,client,common,libs}-* 根据提示先后安装
完成后启动mysql serveice mysqld start建zabbix库
查找临时密码:grep 'temporary password' /var/log/mysqld.log
shell> mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
mysql> create database zabbix default charset utf8;mysql>grant all on zabbix.* to 'zabbix'@localhost identified by 'Zabbix@123';
mysql>flush privileges;
chkconfig --add mysqld
chkconfig mysqld on
2.php安装
下载
到php官网下载最新的php安装包:php-7.2.0.tar.gz解压
tar -zxvf php-7.2.0.tar.gz安装依赖包
yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel -y
可能还要安装freetype-devel-2.3.11-17.el6.x86_64 libevent-devel-1.4.13-4.el6.i686 OpenIPMI-devel-2.0.16-14.el6.x86_64等rpm包,根据编译时的报错需要到http://rpmfind.net/查找下载。编译安装
cd php-7.2.0
./configure --prefix=/usr/local/php-7.2.0 --with-config-file-path=/usr/local/php-7.2.0/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-jis-conv --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 --enable-mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath
make && make install
参数都要写上,不然zabbix配置时报错。php配置
cp php.ini-production /usr/local/php-7.2.0/etc/php.ini
cp /usr/local/php-7.2.0/etc/php-fpm.conf.default /usr/local/php-7.2.0/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
修改php.ini:
sed -i "s/;date.timezone =/date.timezone = Asia\/Shanghai/" /etc/php.ini
sed -i "s/max_execution_time = 30/max_execution_time = 300/" /etc/php.ini
sed -i "s/post_max_size = 8M/post_max_size = 32M/" /etc/php.ini
sed -i "s/max_input_time = 60/max_input_time = 300/" /etc/php.ini
修改www.conf:
修改user group为zabbix
php启动命令:
/usr/local/php-7.2.0/sbin/php-fpm -y /usr/local/php-7.2.0/etc/php-fpm.conf -c /usr/local/php-7.2.0/etc/php.ini
php -i | grep "phar.readonly"看当前值
php -i | grep "php.ini" 看加载的php.ini是哪个
3.nginx 安装
下载并解压
tar -zxvf nginx-1.13.7.tar.gz编译安装
./configure --prefix=/usr/local/nginx-1.13.7 --with-http_ssl_module --with-http_spdy_module --with-http_stub_status_module --with-pcre配置nginx
修改nginx.conf:
[root@zabbix conf]# vi /usr/local/nginx-1.13.7/conf/nginx.conf
#user nobody;
user zabbix zabbix;
worker_processes 1;
这段内容去掉注释:
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
增加index.php:
server {
listen 80;
server_name localhost;
location / {
root html;
index index.php index.html index.htm;
}
测试nginx:/usr/local/nginx-1.13.7/sbin/nginx -t //检查配置
启动nginx:/usr/local/nginx-1.13.7/sbin/nginx
启动php测试:
/usr/local/php-7.2.0/sbin/php-fpm -y /usr/local/php-7.2.0/etc/php-fpm.conf -c /usr/local/php-7.2.0/etc/php.ini
测试:echo "<?php phpinfo(); ?>" > /usr/local/nginx-1.13.7/html/index.php
LNMP环境搭建完成。
nginx 加入开机启动:echo "/usr/local/nginx-1.13.7/sbin/nginx" >> /etc/rc.local
4.zabbix 安装
下载安装
tar -zxvf zabbix-3.4.4.tar.gz
编译前安装好snmp,curl,mysql等./configure --prefix=/data/server/zabbix --sysconfdir=/etc/zabbix --enable-server --enable-agent --with-openipmi --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2 --enable-ipv6 --with-openssl
make && make install将表导入mysql
将zabbix 安装包中自带的数据库文件导入新建zabbix 数据库中,按顺序,不然会出现问题。
mysql -uzabbix -pZabbix@123 zabbix < database/mysql/schema.sql
mysql -uzabbix -pZabbix@123 zabbix < database/mysql/images.sql
mysql -uzabbix -pZabbix@123 zabbix < database/mysql/data.sql配置zabbix server
vi /etc/zabbix/zabbix_server.conf
DBHost=localhost #默认注释掉了,直接取消注释即可
DBName=zabbix #数据库用户,我们授权的用户也是 zabbix
DBUser=zabbix #默认是 root,我们授权的用户是 zabbix
DBPassword=Zabbix@123#密码配置zabbix agent
#配置agentd.conf,修改如下位置
UnsafeUserParameters=1设置开机启动
echo /usr/local/zabbix/sbin/zabbix_server >> /etc/rc.local复制zabbix文件到nginx html目录中
cp -r /tmp/zabbix-3.4.4/frontends/php/* /usr/local/nginx-1.13.7/html/重启nginx
/usr/local/nginx/sbin/nginx -s reload启动zabbix_server
[root@zabbix nginx-1.13.7]# /data/server/zabbix/sbin/zabbix_serverzabbix.conf.php文件内容:
[root@zabbix conf]# cat zabbix.conf.php
[root@zabbix conf]# cat zabbix.conf.php
<?php
// Zabbix GUI configuration file.
global $DB;
$DB['TYPE'] = 'MYSQL';
$DB['SERVER'] = '127.0.0.1';
$DB['PORT'] = '3306';
$DB['DATABASE'] = 'zabbix';
$DB['USER'] = 'zabbix';
$DB['PASSWORD'] = 'Zabbix@123';
// Schema name. Used for IBM DB2 and PostgreSQL.
$DB['SCHEMA'] = '';
$ZBX_SERVER = 'localhost';
$ZBX_SERVER_PORT = '10051';
$ZBX_SERVER_NAME = '';
$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
[root@zabbix conf]#
以上是关于zabbix安装的主要内容,如果未能解决你的问题,请参考以下文章