zabbix:CentOS7下部署zabbix3
安装环境:
CentOS Linux release 7.0.1406 (Core) nginx/1.10.0 MySQL 5.7.11 PHP 5.6.22 Jemalloc zabbix-3.2.3
#lnmp环境安装 mkdir -p /opt/tmp && cd /opt/tmp wget http://soft.vpser.net/lnmp/lnmp1.3.tar.gz tar zxvf lnmp1.3.tar.gz && cd ./install
#zabbix_server编译安装 yum localinstall jdk-8u73-linux-x64.rpm -y #JMX监控需要JDK支持。 yum install -y curl curl-devel net-snmp net-snmp-devel perl-DBI mysql-devel OpenIPMI OpenIPMI-devel rpm-build openldap openldap-devel libssh2-devel unixODBC-devel fping cd /opt/tmp wget https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.2.3/zabbix-3.2.3.tar.gz tar zxvf zabbix-3.2.3.tar.gz cd zabbix-3.2.3 ./configure --prefix=/opt/zabbix --enable-server --enable-agent --enable-proxy --enable-ipv6 --enable-java -with-mysql -with-libcurl -with-libxml2 -with-unixodbc -with-openipmi -with-openssl -with-ldap -with-net-snmp -with-ssh2 make -j 16 #并行编译,参考服务器负载设置,推荐为逻辑核数2倍 make install
groupadd zabbix && useradd -g zabbix zabbix #增加用户和组
mysql -uroot -p create database zabbix default charset utf8; quit;
#初始化数据库,严格按顺序执行 cd /opt/tmp/zabbix-3.2.3 mysql -uroot -p zabbix < database/mysql/schema.sql Quyiyuan@zabbix_2017&*() mysql -uroot -p zabbix < database/mysql/images.sql mysql -uroot -p zabbix < database/mysql/data.sql
#配置文件修改,确保有以下内容 vim /opt/zabbix/etc/zabbix_server.conf DBUser=root DBPassword=123456 DBSocket=/tmp/mysql.sock
#配置为服务 ln -s /opt/zabbix/etc/ /etc/zabbix ln -s /opt/zabbix/sbin/zabbix_server /usr/local/sbin/zabbix_server ln -s /opt/zabbix/sbin/zabbix_agentd /usr/local/sbin/zabbix_agentd cp /opt/tmp/zabbix-3.2.3/misc/init.d/fedora/core5/zabbix_agentd /opt/tmp/zabbix-3.2.3/misc/init.d/fedora/core5/zabbix_server /etc/rc.d/init.d/ chkconfig zabbix_server on chkconfig zabbix_agentd on chkconfig --list |grep zabbix service zabbix_server start service zabbix_agentd start
#web安装,www.exp.com为例 lnmp vhost add # cp -arp /opt/tmp/zabbix-3.2.3/frontends/php/* /home/wwwroot/www.exp.com chown -R www:www /home/wwwroot/www.exp.com/
vim /usr/local/php/etc/php.ini max_input_time = 600 always_populate_raw_post_data = -1 lnmp restart
访问http://www.exp.com 开始安装 默认用户名:Admin,密码:zabbix 中文乱码问题:用windows下微软雅黑字体替换掉/home/wwwroot/www.exp.com/fonts下的DejaVuSans.ttf
./configure –prefix=/opt/zabbix-3.0.1 –enable-server –enable-agent –with-mysql –enable-ipv6 –with-net-snmp –with-libcurl –with-libxml2 –with-unixodbc –with-ssh2 –with-openipmi –with-openssl
configure不过 提示mysql报错
需要指定mysqlclientlib路径
此处需要打一个链接:
查找系统内有没有 libmysqlclient.so
cd /usr/lib
ln -s /usr/local/mariadb/lib/libmysqlclient.so.18.0.0 libmysqlclient.so
ln -s /usr/local/mariadb/lib/libmysqlclient_r.so.18.0.0 libmysqlclient_r.so
db.c:39: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
db.c:166: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
db.c: In function ‘is_recoverable_mysql_error’:
db.c:181: error: ‘conn’ undeclared (first use in this function)
db.c:181: error: (Each undeclared identifier is reported only once
db.c:181: error: for each function it appears in.)
db.c:183: error: ‘CR_CONN_HOST_ERROR’ undeclared (first use in this function)
db.c:184: error: ‘CR_SERVER_GONE_ERROR’ undeclared (first use in this function)
db.c:185: error: ‘CR_CONNECTION_ERROR’ undeclared (first use in this function)
db.c:186: error: ‘CR_SERVER_LOST’ undeclared (first use in this function)
db.c:187: error: ‘CR_UNKNOWN_HOST’ undeclared (first use in this function)
db.c:188: error: ‘ER_SERVER_SHUTDOWN’ undeclared (first use in this function)
db.c:189: error: ‘ER_ACCESS_DENIED_ERROR’ undeclared (first use in this function)
db.c:190: error: ‘ER_ILLEGAL_GRANT_FOR_TABLE’ undeclared (first use in this function)
db.c:191: error: ‘ER_TABLEACCESS_DENIED_ERROR’ undeclared (first use in this function)
db.c:192: error: ‘ER_UNKNOWN_ERROR’ undeclared (first use in this function)
db.c: In function ‘zbx_db_connect’:
db.c:217: error: ‘my_bool’ undeclared (first use in this function)
db.c:217: error: expected ‘;’ before ‘mysql_reconnect’
db.c:315: error: ‘conn’ undeclared (first use in this function)
db.c:321: error: ‘CLIENT_MULTI_STATEMENTS’ undeclared (first use in this function)
db.c:333: error: ‘MYSQL_OPT_RECONNECT’ undeclared (first use in this function)
db.c:333: error: ‘mysql_reconnect’ undeclared (first use in this function)
db.c: In function ‘zbx_db_close’:
db.c:607: error: ‘conn’ undeclared (first use in this function)
db.c: In function ‘zbx_db_vexecute’:
db.c:1077: error: ‘conn’ undeclared (first use in this function)
db.c: At top level:
db.c:1207: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
db.c:1536: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
db.c:1665: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘zbx_db_fetch’
GCC报错,需要yum install -y mysql-devel
客户端快速部署:
wget ‘http://101.96.8.164/repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-agent-3.0.7-1.el7.x86_64.rpm’ && yum localinstall -y zabbix-agent-3.0.7-1.el7.x86_64.rpm
groupadd zabbix && useradd -g zabbix -m zabbix
zabbix_agentd
服务器端验证:
zabbix_get -s192.168.21.128 -p10050 -k”system.uptime”
scandir() has been disabled for security reasons [profile.php:199 → CView->render() → include() → getSounds() → scandir() in include/sounds.inc.php:24]
Invalid argument supplied for foreach() [profile.php:199 → CView->render() → include() → getSounds() in include/sounds.inc.php:25]
yum install mysql-connector-odbc -y
1.zabbix web页面登陆密码遗忘的问题
# mysql -u root -p
> use zabbix;
>UPDATE users SET passwd=md5(‘123456′) WHERE alias=’Admin’;
>flush privileges;
>quit
mysql root密码遗忘问题
# /etc/init.d/mysql stop
# mysqld_safe –skip-grant-tables&
mysql -u root -p
> UPDATE user SET password=PASSWORD(‘123456′) WHERE user=’root’;
> flush privileges;
2.Zabbix alerter processes more than 75% busy
解决办法:
修改zabbix_server.conf配置文件
# vim /usr/local/zabbix/etc/zabbix_server.conf
将其默认值修改为:
StartPollers=20
# /etc/init.d/zabbix_server restart
3. 报错:Undefined index: lastfailedstep [dashboard.php:158 → make_webmon_overview() in /usr/local/nginx/html/zabbix/include/blocks.inc.php:1115]
问题原因:数据库删除历史数据导致
解决方案:删除所有web监控项,重新添加
zabbix安装视频
链接: https://pan.baidu.com/s/1dF2A0fB 密码: ycg9
直接下载zabbix源: rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
yum install -y zabbix-server-mysql zabbix-get ——服务端安装的包
yum install -y zabbix-web zabbix-web-mysql ——web-GUI端安装的包
yum install -y zabbix-agent zabbix-sender ——agent端安装的包