基于LNMP的Zabbbix之Zabbix Server源码详细安装,但不给图
Zabbix Server安装
看到那里有错或者有什么问题的话,求指点
邮箱:losbyday@163.com
上一篇PHP源码安装参见基于LNMP的Zabbbix之PHP源码安装:https://i.cnblogs.com/EditPosts.aspx?postid=5828058
关于zabbix详细:http://www.iyunv.com/thread-179791-1-1.html
Begin
#建立一个用于zabbix的用户
useradd zabbix passwd zabbix
#我的密码123看个人
#到官网找到Zabbix Server源码安装包
wget http://120.52.73.49/tenet.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.0.3/zabbix-3.0.3.tar.gz tar -zxvf zabbix-3.0.3.tar.gz cd zabbix-3.0.3 ./configure --prefix=/usr/local/zabbix/ --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --enable-java make && make install
#MySQL导入SQL语句
mysql -uroot -e"create database zabbix character set utf8 collate utf8_bin;" mysql -uroot -e"grant all privileges on zabbix.* to zabbix@'%' identified by 'losnau';" mysql -uroot -e"flush privileges;"
#按照SQL语句顺序导入SQL:
mysql -uzabbix -plosnau zabbix < /usr/local/setup/zabbix-3.0.3/database/mysql/schema.sql mysql -uzabbix -plosnau zabbix < /usr/local/setup/zabbix-3.0.3/database/mysql/images.sql mysql -uzabbix -plosnau zabbix < /usr/local/setup/zabbix-3.0.3/database/mysql/data.sql
#修改/usr/local/zabbix/etc/zabbix_server.conf
DBName=zabbix #数据库名称 DBUser=zabbix #数据库用户名 DBPassword=losnau #数据库密码 ListenIP=192.168.1.5 #数据库ip地址 AlertScriptsPath=${datadir}/zabbix/alertscripts #zabbix运行脚本存放目录
#修改php.ini ------PHP option
post_max_size 16M max_execution_time 300 max_input_time = 300 # zone Asia/Shanghai
#重启php-fpm服务
ps aux |grep php #查看php-fpm是否开启 #如果开启就 ps aux |grep php-fpm |xargs kill -9 # 关闭啦 cp /usr/local/php/sbin/php-fpm /usr/bin #^_^ php-fmp #启动php-fpm服务
#zabbix提供init.d脚本
cp misc/init.d/tru64/zabbix_* /etc/init.d/
chmod +x /etc/init.d/zabbix_*
#将前端文件拷贝到nginx站点目录下
cd /usr/local/setup/zabbix-3.0.3/frontends #进入zabbix解压缩目录 cp -rf php /www #将解压缩的zabbix里面php文件拷贝到nginx的root目录下
#修改Nginx的配置文件
我的nginx.conf如下
user daemon; worker_processes 1; error_log logs/error.log; pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #access_log logs/access.log main; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; root /www; location / { index index.html index.htm index.php; } error_page 404 /404.html; # redirect server error pages to the static page /50x.html error_page 500 502 503 504 /50x.html; location = /50x.html { } #解决open() “/usr/local/nginx/html/favicon.ico” failed (2: No such file or directory) location = /favicon.ico { log_not_found off; access_log off; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { fastcgi_pass unix:/tmp/phpfpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location /zabbix { alias /www/zabbix; } } }
# 重启Nginx
cp /usr/local/nginx/nginx /usr/bin nginx -t #检查nginx配置文件是否有错误 nginx -s stop #停止nginx服务 nginx #启动nginx服务
#启动服务
/usr/local/zabbix/sbin/zabbix_server /usr/local/zabbix/sbin/zabbix_agentd
或者service zabbix_server start
service zabbix_agentd start
#在web 192.168.1.5,看你怎么配置的了
zabbix初始登录帐号:Admin #A必须大写
密码:zabbix
End
#碰到的错误及解决:
------------------------check-error 1-------------------------------------------------
#checking for net-snmp-config... no
#configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config
#提示unable to find net-snmp-config,说明缺少相关的依赖性,找出net-snmp-config属于哪个软件包,然后安装即可。
#yum search net-snmp-config,发现net-snmp-config属于软件包net-snmp-devel,安装该软件包,解决该问题。
yum install net-snmp*
------------------------check-error 2--------------------------------------------------
#checking for javac... no
#configure: error: Unable to find "javac" executable in path,没装java-jdk
#解决
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u20-b26/jdk-8u20-linux-x64.tar.gz mkdir /usr/local/java tar zxvf jdk-8u20-linux-x64.tar.gz -C /usr/local/java/ echo "JAVA_HOME=/usr/local/java/jdk1.8.0_20/ JRE_HOME=/usr/local/java/jre PATH=\$JAVA_HOME/bin:\$PATH:\$JRE_HOME/bin CLASSPATH=.:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib/tools.jar:\$JRE_HOME/lib export JAVA_HOME JRE_HOME PATH CLASSPATH" >> /etc/profile source /etc/profile java -version
------------------------MySQL导入SQL语句错误 3----------------------------------------
#Warning: Using a password on the command line interface can be insecure.
#ERROR 1045 (28000): Access denied for user 'zabbix'@'localhost' (using password: YES)
mysql -uroot -e"delete from user where user=' ';" mysql -uroot -e"flush privileges;"
------------------------打开网页出现403错误 4----------------------------------------
403有很多原因,查看logs有( FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream)
错误解决方法:在Nginx配置文件中找到定义调用脚本文件的地方
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; #注释
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #添加
提示:$document_root 代表当前请求在root指令中指定的值。
------------------------nginx日志中还看到下面那个错误 5-------------------------------
open() “/usr/local/nginx/html/favicon.ico” failed (2: No such file or directory)
只需要关闭 favicon.ico 的 log:
location = /favicon.ico {
log_not_found off;
access_log off;
}
-----------------------nginx日志中还看到下面那个错误 6-------------------------------
-2016/09/01 11:05:15 [error] 118206#118206: *1 FastCGI sent in stderr: "PHP message: PHP Warning: phpinfo(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /www/index.php on line 2" while reading response header from upstream, client: 192.168.1.209, server: localhost, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://unix:/tmp/phpfpm.sock:", host: "192.168.1.5"
解决方法:
在php.ini里加上
date.timezone = "Asia/Shanghai"(去掉前面的;)
-----------------------zabbix 服务启动错误 7-------------------------------
[root@localhost mysql]# /usr/local/zabbix/sbin/zabbix_server
/usr/local/zabbix/sbin/zabbix_server: error while loading shared libraries:
libmysqlclient.so.18: cannot open shared object file: No such file or directory
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/
# 如果是32位系统需要做连接到/usr/lib/下 64位放到lib64
------------------------Nginx 错误汇总:http://blog.csdn.net/cjfeii/article/details/49511829
------------------------zabbix密码修改:http://www.361way.com/zabbix-change-passord/3652.html
------------------------本文参考:
记录一次基于LNMP环境下的Zabbix3.0部署:http://www.tuicool.com/articles/ZJfYzyF
Zabbix安装图解教程:http://www.osyunwei.com/archives/7984.html