一、准备Yum源,这里我们使用官方的Yum源
zabbix 3.0没有了zabbix_server这个包而是直接整合进zabbix_server_mysql里面
#rpm-Uivh #yumcleanall #yummakecache
二、安装zabbix各组件
服务端
#yuminstallzabbix-agentzabbix-server-mysqlzabbix-getzabbix-webzabbix-web-mysql{zabbix-agent|zabbix-sender}
安装mysql
#groupadd-r-g306mysql #useradd-g306-u306-r-Mmysql #tar-xfmysql-5.5.28-linux2.6-x86_64.tar.gz-C/usr/local/#cd/usr/local/ #chown-Rmysql.mysql./*#mkdir/data/mysql5.5.28 #chown-Rmysql.mysql/data/mysql5.5.28 #scripts/mysql_install_db--datadir=/data/mysql5.5.28--user=mysql
my.cnf配置
#cpmy-small.cnf/etc/my.cnf[client] port =3306socket =/data/mysql5.5.28/mysql.sock [mysqld] port =3306socket =/data/mysql5.5.28/mysql.sock server-id =1log-bin=mysql-bin pid-file=/data/mysql5.5.28/mysql.pid innodb-file-per-table=1datadir=/data/mysql5.5.28[mysqldump] quick max_allowed_packet=16M [mysql] no-auto-rehash [myisamchk] key_buffer_size=8M sort_buffer_size=8M [mysqlhotcopy] interactive-timeout
cp mysqld 并加入自动启动
#cpmysql.server/etc/init.d/mysqld #chmod+x/etc/init.d/mysqld #chkconfig--addmysqld #chkconfigmysqld--listmysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off#servicemysqldstart
创建zabbix库并授权
#mysql WelcometotheMariaDBmonitor.Commandsendwith;or\g. YourMySQLconnectionidis560Serverversion:5.5.28-logMySQLCommunityServer(GPL) Copyright(c)2000,2015,Oracle,MariaDBCorporationAbandothers.Type'help; 'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement. MySQL[(none)]>CREATEDATABASEzabbix; MySQL[(none)]>GRANTALLONzabbix.*TOzabbix@'127.0.0.1'IDENTIFIEDBY'zabbixpass'; MySQL[(none)]>FLUSHPRIVILEGES;
客户端:
#yuminstallzabbix-senderzabbix-agent-y
三、配置zabbix并启动
zabbix-server:
#grep-v"^#"zabbix_server.conf ListenPort=10051 SourceIP=172.16.0.2 LogFile=/var/log/zabbix/zabbix_server.log PidFile=/var/run/zabbix/zabbix_server.pid DBHost=127.0.0.1DBName=zabbix DBUser=zabbix DBPassword=zabbixpass DBSocket=/data/mysql5.5.28/mysql.sock StartPollers=2 SNMPTrapperFile=/var/log/snmptrap/snmptrap.log Timeout=4AlertScriptsPath=/usr/lib/zabbix/alertscripts ExternalScripts=/usr/lib/zabbix/externalscripts LogSlowQueries=3000#systemctlstartzabbix-server.service
zabbix-web:
#rpm-qfzabbix.confzabbix-web-3.0.5-1.el7.noarch #grep"Asia/Shanghai"/etc/httpd/conf.d/zabbix.conf #只需修改这里即可 Alias/zabbix/usr/share/zabbix php_valuedate.timezoneAsia/Shanghai#systemctlstarthttpd.service #ss-tnl|grep"10051\|80"LISTEN0128*:10051*:* LISTEN0128:::80:::* LISTEN0128:::10051:::*
然后访问http://serverIP/zabbix第一次它会自动跳到http://serverIP/zabbix/setup.php 根据提示填入相应的即可,很简单,配置完毕后会在生成zabbix.conf.php文件
#cat/etc/zabbix/web/zabbix.conf.php <?php//ZabbixGUIconfigurationfile.global $DB;$DB['TYPE']='MYSQL'; $DB['SERVER']='127.0.0.1'; $DB['PORT']='0'; $DB['DATABASE']='zabbix'; $DB['USER']='zabbix'; $DB['PASSWORD']='zabbixpass'; //Schemaname.UsedforIBMDB2andPostgreSQL.$DB['SCHEMA']='' ;$ZBX_SERVER='localhost'; $ZBX_SERVER_PORT='10051'; $ZBX_SERVER_NAME=''; $IMAGE_FORMAT_DEFAULT=IMAGE_FORMAT_PNG;
登入信息:
defaultlogin:username:adminpassword:zabbix