同时安装server和agent,并支持将数据放入mysql中,可是有类似如下配置命令: ./configure--enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp--with-libcurl
如果仅安装server,并支持将数据放入mysql数据中,可使用类似如下配置命令: ./configure--enable-server --with-mysql --with-net-snmp --with-libcurl
如果仅安装proxy,并支持将数据放入mysql数据中,可使用类似如下配置命令: ./configure--prefix=/usr --enable-proxy --with-mysql --with-net-snmp --with-ssh2
如果仅安装agent,可使用类似如下配置命令: ./configure--enable-agent
而后编译安装zabbix即可: make && makeinstall
时间同步 selinux关闭 防火墙关闭 服务开启 主机名、IP地址,对应
在centos7下搭建zabbix2.4
服务端配置: 1、创建用户和组 groupadd zabbix useradd zabbix -gzabbix -s /sbin/nologin
2、环境准备(php、http、数据库) yum install phpphp-gd php-mysql php-bcmath php-mbstring php-xml curl curl-devel net-snmp net-snmp-devel perl-DBI yum install httpdmariadb* systemctl startmariadb.service chkconfig mariadb on systemctl starthttpd.service chkconfig httpd on
3、配置数据库 mysql -u root -p create databasezabbix character set utf8; insert intomysql.user(Host,User,Password) values('localhost','zabbix',password('zabbix')); flush privileges; grant all onzabbix.* to 'zabbix'@'127.0.0.1' identified by 'zabbix' with grant option; flush privileges; quit
4、安装zabbix yum install gcc yum install wget tar -zxvfzabbix-2.4.5.tar.gz cd zabbix-2.4.5 ./configure--with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl--enable-server --enable-agent --enable-proxy --prefix=/usr/local/zabbix make && makeinstall
5、导入数据库文件 mysql -u root -p use zabbix; source/root/zabbix-2.4.5/database/mysql/schema.sql source/root/zabbix-2.4.5/database/mysql/data.sql source/root/zabbix-2.4.5/database/mysql/images.sql quit
6、查看zabbix服务是否存在,不存在则添加 cat /etc/services|grep zabbix zabbix-agent 10050/tcp # Zabbix Agent zabbix-agent 10050/udp # Zabbix Agent zabbix-trapper 10051/tcp # Zabbix Trapper zabbix-trapper 10051/udp # Zabbix Trapper
7、创建日志目录 mkdir/var/log/zabbix chown zabbix.zabbix/var/log/zabbix
8、拷贝service启动脚本 cd/root/zabbix-2.4.5 cpmisc/init.d/fedora/core/zabbix_* /etc/init.d/ chmod 755/etc/init.d/zabbix_* sed -i"s#BASEDIR=/usr/local#BASEDIR=/usr/#g" /etc/init.d/zabbix_server sed -i"s#BASEDIR=/usr/local#BASEDIR=/usr/#g" /etc/init.d/zabbix_agentd
9、修改server配置文件 mkdir -p /etc/zabbix cp -r/root/zabbix-2.4.5/conf/* /etc/zabbix/ chown -Rzabbix:zabbix /etc/zabbix vi/etc/zabbix/zabbix_server.conf 30:LogFile=/var/log/zabbix/zabbix_server.log ##日志文件地址 68:DBHost=localhost ##数据库主机 78:DBName=zabbix ##数据库名 94:DBUser=zabbix ##数据库用户名 102:DBPassword=zabbix ##数据库密码 282:ListenIP=127.0.0.1 ##数据库IP地址 425:AlertScriptsPath=/etc/zabbix/alertscripts ##zabbix运行脚本存放目录 或者是/usr/local/zabbix/share/zabbix/alertscripts
10、修改agentd配置文件 vi/etc/zabbix/zabbix_agentd.conf 11:PidFile=/tmp/zabbix_agentd.pid ##进程PID 21:LogFile=/tmp/zabbix_agentd.log ##日志保存位置 59:EnableRemoteCommands=1 ##允许执行远程命令 81:Server=127.0.0.1 ##server端的ip 122:ServerActive=127.0.0.1:10051 133:Hostname=server1 ##必须与zabbix创建的hostname相同 252:Include=/usr/local/etc/zabbix_agentd.conf.d/ 265:UnsafeUserParameters=1 ##启动自定义key
11、配置PHP相关参数 vi /etc/php.ini 384max_execution_time = 300 394 max_input_time =300 405 memory_limit =128M 800upload_max_filesize = 2M 878 date.timezone =Asia/Shanghai 672 post_max_size =28M
12、配置web站点 cd/root/zabbix-2.4.5/ cp -r frontends/php/var/www/html/zabbix chown -R apache.apache /var/www/html/zabbix vi/etc/httpd/conf/httpd.conf 164 DirectoryIndex index.html index.php
13、启动配置 cd/root/zabbix-2.4.5/ cpmisc/init.d/fedora/core5/zabbix_server /etc/rc.d/init.d/zabbix_server cpmisc/init.d/fedora/core5/zabbix_server /etc/rc.d/init.d/zabbix_agentd chmod u+x/etc/rc.d/init.d/zabbix_server chmod u+x/etc/rc.d/init.d/zabbix_agentd chkconfigzabbix_server on chkconfigzabbix_agentd on servicezabbix_server start servicezabbix_agentd start /usr/local/zabbix/sbin/zabbix_serverstart /usr/local/zabbix/sbin/zabbix_agentdstart
14、关闭防火墙和selinux vi /hostname server1 hostname server1 setenforce 0 vi/etc/sysconfig/selinux disabled getenforce 0 iptables -F systemctl stopebtables systemctl stopfirewalld systemctl disableiptables systemctl disableebtables systemctl disablefirewalld
15、重启相关服务 systemctl restartmariadb chkconfig mariadb on
systemctl restarthttpd chkconfig httpd on
chkconfigzabbix_server on chkconfigzabbix_agentd on servicezabbix_server start servicezabbix_agentd start
16、浏览器中开始安装zabbix 浏览器-192.168.0.194/zabbix
17、更改字体 通过xftp将ttf格式字体上传到/var/www/html/zabbix/fonts目录下
修改如下两处配置文件中的默认字体 vim/var/www/html/zabbix/include/defines.inc.php //define('ZBX_GRAPH_FONT_NAME','DejaVuSans'); // font file name define('ZBX_GRAPH_FONT_NAME','simkai'); // font file name //define('ZBX_FONT_NAME','DejaVuSans'); define('ZBX_FONT_NAME','simkai'); 刷新页面
服务端测试命令:/usr/local/zabbix/bin/zabbix_get-s 192.168.0.78 -p10050 -k"net.if.in[eth0,bytes]"
客户端配置 1、确定IP地址 vi/etc/sysconfig/network-scripts/ifcfg-eno16777736 systemctl restartnetwork ifconfig
2、创建用户和组 groupadd zabbix -g201 useradd -g zabbix -u201 -m zabbix
3、下载安装 tar -zxvfzabbix-2.4.5.tar.gz cd zabbix-2.4.5 yum install gcc make ./configure--prefix=/usr --sysconfdir=/etc/zabbix --enable-agent make && makeinstall
4、配置启动 mkdir/var/log/zabbix chown zabbix.zabbix/var/log/zabbix cpmisc/init.d/fedora/core/zabbix_agentd /etc/init.d/ chmod 755/etc/init.d/zabbix_agentd sed -i"s#BASEDIR=/usr/local#BASEDIR=/usr/#g" /etc/init.d/zabbix_agentd cat /etc/services |grep zabbix
5、配置文件修改 sed -i"s/Server\=127.0.0.1/Server\=127.0.0.1,192.168.0.194/g"/etc/zabbix/zabbix_agentd.conf sed -i"s/ServerActive\=127.0.0.1/ServerActive\=192.168.0.194:10051/g"/etc/zabbix/zabbix_agentd.conf sed -i"s#tmp/zabbix_agentd.log#var/log/zabbix/zabbix_agentd.log#g"/etc/zabbix/zabbix_agentd.conf sed -i"#UnsafeUserParameters=0#aUnsafeUserParameters=1\n"/etc/zabbix/zabbix_agentd.conf vi/etc/zabbix/zabbix_agentd.conf 改Hostname 为server2
6、关闭防火墙和selinux vi /etc/hostname server2 hostname server2 iptables -F systemctl stopebtables systemctl stopfirewalld systemctl disableebtables systemctl disablefirewalld vi/etc/sysconfig/selinux disabled setenforce 0
7、启动服务 chkconfigzabbix_agentd on servicezabbix_agentd start
|