4532 发表于 2016-7-29 09:14:42

centos7下搭建zabbix2.4

同时安装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 zabbixuseradd 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-DBIyum install httpdmariadb*systemctl startmariadb.servicechkconfig mariadb onsystemctl starthttpd.servicechkconfig httpd on
3、配置数据库mysql -u root -pcreate 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、安装zabbixyum install gccyum install wgetwget http://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.4.5/zabbix-2.4.5.tar.gztar -zxvfzabbix-2.4.5.tar.gzcd 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/zabbixmake && makeinstall
5、导入数据库文件mysql -u root -puse zabbix;source/root/zabbix-2.4.5/database/mysql/schema.sqlsource/root/zabbix-2.4.5/database/mysql/data.sqlsource/root/zabbix-2.4.5/database/mysql/images.sqlquit

6、查看zabbix服务是否存在,不存在则添加cat /etc/services|grep zabbixzabbix-agent    10050/tcp               # Zabbix Agentzabbix-agent    10050/udp               # Zabbix Agentzabbix-trapper10051/tcp               # Zabbix Trapperzabbix-trapper10051/udp               # Zabbix Trapper
7、创建日志目录mkdir/var/log/zabbixchown zabbix.zabbix/var/log/zabbix
8、拷贝service启动脚本cd/root/zabbix-2.4.5cpmisc/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_serversed -i"s#BASEDIR=/usr/local#BASEDIR=/usr/#g" /etc/init.d/zabbix_agentd
9、修改server配置文件mkdir -p /etc/zabbixcp -r/root/zabbix-2.4.5/conf/* /etc/zabbix/chown -Rzabbix:zabbix /etc/zabbixvi/etc/zabbix/zabbix_server.conf30: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.ini384max_execution_time = 300394 max_input_time =300405 memory_limit =128M800upload_max_filesize = 2M878 date.timezone =Asia/Shanghai672 post_max_size =28M
12、配置web站点cd/root/zabbix-2.4.5/cp -r frontends/php/var/www/html/zabbixchown -R apache.apache /var/www/html/zabbixvi/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_servercpmisc/init.d/fedora/core5/zabbix_server /etc/rc.d/init.d/zabbix_agentdchmod u+x/etc/rc.d/init.d/zabbix_serverchmod u+x/etc/rc.d/init.d/zabbix_agentdchkconfigzabbix_server onchkconfigzabbix_agentd onservicezabbix_server startservicezabbix_agentd start/usr/local/zabbix/sbin/zabbix_serverstart/usr/local/zabbix/sbin/zabbix_agentdstart

14、关闭防火墙和selinuxvi /hostname server1hostname server1setenforce 0vi/etc/sysconfig/selinux disabledgetenforce 0iptables -Fsystemctl stopebtablessystemctl stopfirewalldsystemctl disableiptablessystemctl disableebtablessystemctl disablefirewalld
15、重启相关服务systemctl restartmariadbchkconfig mariadb on
systemctl restarthttpdchkconfig httpd on
chkconfigzabbix_server onchkconfigzabbix_agentd onservicezabbix_server startservicezabbix_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 namedefine('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"


客户端配置1、确定IP地址vi/etc/sysconfig/network-scripts/ifcfg-eno16777736systemctl restartnetworkifconfig
2、创建用户和组groupadd zabbix -g201useradd -g zabbix -u201 -m zabbix
3、下载安装wget http://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.4.5/zabbix-2.4.5.tar.gztar -zxvfzabbix-2.4.5.tar.gzcd zabbix-2.4.5yum install gcc make./configure--prefix=/usr --sysconfdir=/etc/zabbix --enable-agentmake && makeinstall
4、配置启动mkdir/var/log/zabbixchown zabbix.zabbix/var/log/zabbixcpmisc/init.d/fedora/core/zabbix_agentd /etc/init.d/chmod 755/etc/init.d/zabbix_agentdsed -i"s#BASEDIR=/usr/local#BASEDIR=/usr/#g" /etc/init.d/zabbix_agentdcat /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.confsed -i"s/ServerActive\=127.0.0.1/ServerActive\=192.168.0.194:10051/g"/etc/zabbix/zabbix_agentd.confsed -i"s#tmp/zabbix_agentd.log#var/log/zabbix/zabbix_agentd.log#g"/etc/zabbix/zabbix_agentd.confsed -i"#UnsafeUserParameters=0#aUnsafeUserParameters=1\n"/etc/zabbix/zabbix_agentd.confvi/etc/zabbix/zabbix_agentd.conf 改Hostname 为server2
6、关闭防火墙和selinuxvi /etc/hostname server2hostname server2iptables -Fsystemctl stopebtablessystemctl stopfirewalldsystemctl disableebtablessystemctl disablefirewalldvi/etc/sysconfig/selinux disabledsetenforce 0
7、启动服务chkconfigzabbix_agentd onservicezabbix_agentd start

页: [1]
查看完整版本: centos7下搭建zabbix2.4