安装文档地址:https://www.zabbix.com/documentation/3.0/
下载地址:http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/
上次,从rpm安装到放弃http://blog.csdn.net/mchdba/article/details/51226751 ,事后仔细想了下,虽然rpm安装不成功,但是还有别的办法可以一试,比如resource,所以准备下载tar.gz准备源码安装。
对zabbix的安装做个大概的简介,zabbix安装需要安装以下4个重要的模块
(1)zabbix_server,zabbix服务器端,提供基础服务监控
(2)zabbix_agentd,zabbix客户端,为被监控的服务器与zabbix_server保持监控联系状态
(3)php,zabbix管理工程组件,zabbix-web是php工程
(4)nginx,通过nginx来控制访问zabbix-web工程界面
(5)mysql,存储zabbix监控数据和基础信息
[root@hch_test_121_12 zabbix-server-mysql-3.0.1]# setenforce 0 setenforce: SELinux is disabled [root@hch_test_121_12 zabbix-server-mysql-3.0.1]# getenforce Disabled [root@hch_test_121_12 zabbix-server-mysql-3.0.1]# |
# 为了支持rewrite功能,我们需要安装pcre yum install -y pcre* # 需要ssl的支持,如果不需要ssl支持,请跳过这一步 yum install -y openssl* # 安装nginx: tar -xvf nginx-1.8.1.tar.gz cd nginx-1.8.1 ./configure --prefix=/usr/local/nginx-1.8.1 --with-http_ssl_module --with-http_spdy_module --with-http_stub_status_module --with-pcre
#--with-http_stub_status_module:支持nginx状态查询 #--with-http_ssl_module:支持https #--with-http_spdy_module:支持google的spdy,想了解请百度spdy,这个必须有ssl的支持 #--with-pcre:为了支持rewrite重写功能,必须制定pcre
cd /usr/local/ ln -s nginx-1.8.1 nginx /usr/local/nginx/sbin/nginx |
Php5.6.20下载地址:
http://php.net/get/php-5.6.20.tar.gz/from/a/mirror |
原blog地址:http://blog.csdn.net/mchdba/article/details/51263871,谢绝转载。
开始源码安装php:
# 准备依赖的组件包 yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel -y # 安装命令 tar -xvf php-5.6.20.tar.bz2 cd php-5.6.20 ./configure --prefix=/usr/local/php-5.6.20 --with-config-file-path=/usr/local/php-5.6.20/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 make make install
cd /usr/local ln -s php-5.6.20 php cp /soft/php-5.6.20/php.ini-production /usr/local/php/etc/php.ini cp /soft/php-5.6.20/sapi/fpm/php-fpm.conf /usr/local/php/etc/php-fpm.conf ln -s /usr/local/php/sbin/* /usr/sbin/
# 启动php-fpm php-fpm [root@hch_test_121_12 local]# php-fpm [root@hch_test_121_12 local]#
# check下是否启动成功 [root@hch_test_121_12 local]# netstat -ntpl|grep 9000 tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 527/php-fpm [root@hch_test_121_12 local]# |
配置php.ini参数, vim /usr/local/php/etc/php.ini:
|
修改nginx配置文件/usr/local/nginx/conf/nginx.conf:
server { listen 80; server_name ys.zabbix.com; access_log /usr/local/nginx/logs/zabbix.access.log;
index index.php index.html index.html; root /usr/local/nginx/html/zabbix;
location / { try_files $uri $uri/ /index.php?$args; }
location ~ .*\.(php)?$ { expires -1s; try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; include fastcgi_params; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass 127.0.0.1:9000;
} } |
如果没有启用dns域名系统的话,可以在/etc/hosts加下ip地址和域名的配置:
# vim /etc/hosts 192.168.121.12 ys.zabbix.com # 启动nginx服务 /usr/local/nginx/sbin/nginx |
添加测试的info.php,在nginx的html目录:
mkdir -p /usr/local/nginx/html/zabbix vim /usr/local/nginx/html/zabbix/info.php # info.php录入以下内容
phpinfo(); ?> |
nginx将会连接回环地址9000端口执行PHP文件,需要使用tcp/ip协议,速度比较慢.建议大家换成使用socket方式连接。将fastcgi_pass127.0.0.1:9000;改成fastcgi_passunix:/var/run/phpfpm.sock;
检测php+nginx是否配置成功,在浏览器打开网址:ys.zabbix.com/info.php或者http://192.168.121.12/info.php,如下所示D:\study\zabbix\2.png:
注明php要5.4以上,curl需要7.20以上,下载地址是:
tar zxvf zabbix-3.0.2.tar.gz cd zabbix-3.0.2 ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 make make install |
安装mysql数据库:
http://blog.csdn.net/mchdba/article/details/51138063
创建zabbix的数据库:
mysql> create database zabbix charset set utf8; Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on zabbix.* to zabbix@'10.%' identified by 'zabbix0418'; Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on zabbix.* to zabbix@'192.%' identified by 'zabbix0418'; Query OK, 0 rows affected (0.01 sec)
mysql> |
PS:字符集要设置为utf8mb4,防止界面切换到中文的时候乱码。
导入create.sql.gz文件,建立zabbix-server的数据库(ps,以前的版本可能叫啥schema.sql之类的):
mysql> source “/data/create.sql”; |
编辑数据库配置文件,一般默认在/etc/zabbix/目录下:
# vim /etc/zabbix/zabbix_server.conf DBHost=192.168.121.61 DBName=zabbix DBUser=zabbix DBPassword=zabbix0418 DBPort=3307 DBSocket=/usr/local/mysql/mysql.sock |
# 启动: /usr/local/zabbix/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf 查看后台进程: [root@hch_test_121_12 zabbix-3.0.2]# ps -eaf|grep zabbix_server zabbix 28130 1 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf zabbix 28131 28130 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: configuration syncer [waiting 60 sec for processes] zabbix 28132 28130 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: db watchdog [synced alerts config in 0.003818 sec, idle 60 sec] zabbix 28133 28130 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: poller #1 [got 0 values in 0.000006 sec, idle 5 sec] zabbix 28134 28130 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: poller #2 [got 0 values in 0.000005 sec, idle 5 sec] zabbix 28135 28130 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: poller #3 [got 0 values in 0.000005 sec, idle 5 sec] zabbix 28136 28130 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: poller #4 [got 0 values in 0.000005 sec, idle 5 sec] zabbix 28137 28130 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: poller #5 [got 0 values in 0.000006 sec, idle 5 sec] zabbix 28138 28130 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: unreachable poller #1 [got 0 values in 0.000006 sec, idle 5 sec] zabbix 28139 28130 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: trapper #1 [processed data in 0.000000 sec, waiting for connection] zabbix 28140 28130 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: trapper #2 [processed data in 0.000000 sec, waiting for connection] zabbix 28141 28130 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: trapper #3 [processed data in 0.000000 sec, waiting for connection] zabbix 28142 28130 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: trapper #4 [processed data in 0.000000 sec, waiting for connection] zabbix 28144 28130 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: trapper #5 [processed data in 0.000000 sec, waiting for connection] zabbix 28145 28130 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: icmp pinger #1 [got 0 values in 0.000007 sec, idle 5 sec] zabbix 28147 28130 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: alerter [sent alerts: 0 success, 0 fail in 0.001611 sec, idle 30 sec] zabbix 28148 28130 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: housekeeper [startup idle for 30 minutes] zabbix 28149 28130 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: timer #1 [processed 0 triggers, 0 events in 0.000000 sec, 0 maintenances in 0.000000 sec, idle 9 sec] zabbix 28150 28130 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: http poller #1 [got 0 values in 0.001078 sec, idle 5 sec] zabbix 28151 28130 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: discoverer #1 [processed 0 rules in 0.000791 sec, idle 60 sec] zabbix 28153 28130 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: history syncer #1 [synced 0 items in 0.000001 sec, idle 1 sec] zabbix 28154 28130 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: history syncer #2 [synced 0 items in 0.000001 sec, idle 1 sec] zabbix 28155 28130 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: history syncer #3 [synced 0 items in 0.000001 sec, idle 1 sec] zabbix 28157 28130 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: history syncer #4 [synced 0 items in 0.000001 sec, idle 1 sec] zabbix 28159 28130 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: escalator #1 [processed 0 escalations in 0.000517 sec, idle 3 sec] zabbix 28160 28130 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: proxy poller #1 [exchanged data with 0 proxies in 0.000004 sec, idle 5 sec] zabbix 28162 28130 0 17:46 ? 00:00:00 /usr/local/zabbix/sbin/zabbix_server: self-monitoring [processed data in 0.000005 sec, idle 1 sec] root 28178 18398 0 17:46 pts/2 00:00:00 grep zabbix_server [root@hch_test_121_12 zabbix-3.0.2]# |
先找zabbix的管理网站应用,默认是在源码解压缩下面的frontends/php/目录,然后copy到/usr/local/nginx/html/zabbix:
# 如果不记得源码安装目录,可以通过find / -name frontends全盘检索找到 unalias cp cp -r -f /soft/zabbix-3.0.2/frontends/php/* /usr/local/nginx/html/zabbix/ |
单独为zabbix配置php.ini:
# vim /usr/local/php/etc/php.ini max_execution_time = 300 memory_limit = 128M post_max_size = 16M upload_max_filesize = 2M max_input_time = 300 date.timezone = PRC |
然后打开网址,http://ys.zabbix.com,出现如下界面D:\study\zabbix\3.png
zabbix编译报错信息:
checking for main in -lnetsnmp... yes checking for localname in struct snmp_session... yes checking for gawk... (cached) gawk checking for curl-config... no configure: error: Curl library not found
# 需要安装curl组件,而且需要在7.20版本以上: yum install -y libcurl* |
再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow