目录
zabbix([`zæbiks])是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。
zabbix能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。
zabbix由2部分构成,zabbix server与可选组件zabbix agent。
zabbix server可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在Linux,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平台上。
- 安装与配置简单,学习成本低
- 支持多语言(包括中文)
- 免费开源
- 自动发现服务器与网络设备
- 分布式监视以及WEB集中管理功能
- 可以无agent监视
- 用户安全认证和柔软的授权方式
- 通过WEB界面设置或查看监视结果
- email等通知功能
操作系统:Red Hat Enterprise Linux Server release 7.6 (Maipo)
Jdk版本:jdk 1.8.181
Zabbix版本:zabbix 4.2
本文案例环境信息如下
发行版 | 版本 | ip | 软件 |
Mysql | 5.7 | 10.0.0.9 | Mysql |
Zabbix server | 4.2 | 10.0.0.7 | server |
Zabbix agent | 4.2 | 10.0.0.9 | agent |
Oracle | 12c | 10.78.136.18 | Oracle |
OracleHat | 12c | 10.78.207.22 | Oracle |
下载地址:https://www.zabbix.com/cn/download
JAVA_HOME,设置JDK的安装目录;
PATH,需要将java的bin目录配置到path目录下;
CLASSPATH,需要将JDK的tools.jar配置到classpath目录中。
本文采用源码安装的方式
1-4步骤为root用户操作
5-6步骤为zabbix用户操作
7 步骤用mysql用户操作
8-11为zabbix用户操作
rz命令将下载的源码包传送到服务器
systemctl stop firewalld systemctl disable firewalld sed -i 's/=enforcing/=disabled/g' /etc/selinux/config setenforce 0 |
yum install httpd php php-mysql php-devel php-xml php-bcmath php-mbstring php-gd wget net-snmp gcc libxml2-devel net-snmp-devel libevent-deve l mysql-devel curl-devel php-ldap –y |
groupadd mnt useradd zabbix -u 1307 -g mnt |
tar -zxvf zabbix-4.2.4.tar.gz -C /home/zabbix cd /home/zabbix/zabbix-4.2.4 ./configure --enable-server --enable-agent --enable-java --prefix=/home/zabbix --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 make install |
Zabbix前端为PHP语言编写,所以要配置PHP服务
cp -r frontends/php/ /var/www/html/zabbix #开机启动 vi /home/zabbix/zabbix-4.2.4/misc/init.d/fedora/core5/zabbix_server ZABBIX_BIN="/home/zabbix/sbin/zabbix_server" ln -s /home/zabbix/zabbix-4.2.4/misc/init.d/fedora/core5/zabbix_server /etc/init.d/ chkconfig --add zabbix_server chkconfig zabbix_server on ln -s /home/zabbix/sbin/zabbix_server /usr/lib/systemd/system/zabbix_server.service rm -rf /etc/php.ini cat > /etc/php.ini <<EOF max_execution_time = 300 memory_limit = 128M post_max_size = 16M upload_max_filesize = 2M max_input_time = 300 date.timezone = Africa/Nairobi EOF #修改后重启http服务 systemctl restart httpd
|
复制 /home/zabbix/zabbix-4.2.4/database/mysql/schema.sql; images.sql;data.sql; 到mysql服务器
以root用户,密码abcd1234为例:
#新建zabbix用户,密码Zabbix@2020,新建数据库zabbix
mysql -uroot -pabcd1234 -e "create database zabbix character set utf8 collate utf8_bin;"
mysql -uroot -pabcd1234 -e "grant all privileges on zabbix.* to zabbix@'%' identified by 'Zabbix@2020';"
mysql -uroot -pabcd1234 -e "flush privileges;"
mysql -uzabbix -pZabbix@2020 -e "use zabbix;source schema.sql;source images.sql;source data.sql;" |
cd ~ mkdir {logs,externalscripts} rm -rf /home/zabbix/etc/zabbix_server.conf cat > /home/zabbix/etc/zabbix_server.conf <<EOF LogFile=/home/zabbix/logs/zabbix_server.log PidFile=/home/zabbix/logs/zabbix_server.pid DBHost=10.0.0.9 DBName=zabbix DBUser=zabbix DBPassword=Zabbix@2020 DBPort=3306 JavaGateway=10.0.0.7 JavaGatewayPort=10052 StartJavaPollers=8 ListenIP=10.0.0.7 Timeout=4 AlertScriptsPath=/home/zabbix/alertscripts ExternalScripts=/home/zabbix/externalscripts LogSlowQueries=3000 Include=/home/zabbix/etc/zabbix_server.conf.d/*.conf StatsAllowedIP=0.0.0.0/0 StartPollers=32 StartTrappers=150 StartDiscoverers=32 StartTimers=10 HousekeepingFrequency=1 MaxHousekeeperDelete=500 CacheSize=256M CacheUpdateFrequency=75 StartDBSyncers=32 HistoryCacheSize=64M HistoryIndexCacheSize=16M ValueCacheSize=128M Timeout=30 UnreachablePeriod=120 LogSlowQueries=3000EOF |
Zabbix-java 是 jvm监控插件,默认安装位置为/home/zabbix/sbin/zabbix_java
cd /home/zabbix/sbin/zabbix_java vi settings.sh LISTEN_IP="10.0.0.7" LISTEN_PORT=10052 PID_FILE="/home/zabbix/logs/zabbix_java.pid" START_POLLERS=8 #启动 sh startup.sh |
mkdir /home/zabbix/etc/orabbix cd /home/zabbix/etc/orabbix unzip orabbix-1.2.3.zip chmod 755 *.sh mv conf/config.props.sample conf/config.props cp init.d/orabbix /etc/init.d/ chmod +x /etc/init.d/orabbix chkconfig orabbix on vi /etc/rc.d/init.d/orabbix orabbix=/home/zabbix/etc/orabbix |
注意:红色是修地方
vi conf/config.props #comma separed list of Zabbix servers ZabbixServerList=ZabbixServer ZabbixServer.Address=0.0.0.0 #zabbix监控IP ZabbixServer.Port=10051 #zabbix监控端口 #pidFile OrabbixDaemon.PidFile=./logs/orabbix.pid #frequency of item's refresh OrabbixDaemon.Sleep=60 #MaxThreadNumber should be >= than the number ofyour databases OrabbixDaemon.MaxThreadNumber=200
#put here your databases in a comma separated list DatabaseList=10.78.136.18,10.78.207.22 #被监控ORACALEIP地址,采用,分开
#Configuration of Connection pool #if not specified Orabbis is going to use defaultvalues (hardcoded) #Maximum number of active connection inside pool DatabaseList.MaxActive=10 #The maximum number of milliseconds that the poolwill wait #(when there are no available connections) for aconnection to be returned #before throwing an exception, or <= 0 to waitindefinitely. DatabaseList.MaxWait=100 DatabaseList.MaxIdle=1
#define here your connection string foreach database 10.78.136.18.Url=jdbc:oracle:thin:@10.78.136.18:1521/syslog 10.78.136.18.User=zabbix 10.78.136.18.Password=zabbix #Those values are optionals if notspecified Orabbix is going to use the general values 10.78.136.18.MaxActive=10 10.78.136.18.MaxWait=100 10.78.136.18.MaxIdle=1 10.78.136.18.QueryListFile=./conf/query.props
#define here your connection string foreach database 10.78.207.22.Url=jdbc:oracle:thin:@10.78.207.22:1521/sjyyt 10.78.207.22.User=zabbix 10.78.207.22.Password=zabbix #Those values are optionals if notspecified Orabbix is going to use the general values 10.78.207.22.MaxActive=10 10.78.207.22.MaxWait=100 10.78.207.22.MaxIdle=1 10.78.207.22.QueryListFile=./conf/query.props
|
1.登录ORACLE 命令行 su– oracale sqlplus/ as sydba selectinstance_name from v$instance; # 查看实例 2、创建用户 CREATE USER ZABBIX IDENTIFIED BY ZABBIX DEFAULT TABLESPACE SYSTEM TEMPORARY TABLESPACE TEMP PROFILE DEFAULT ACCOUNT UNLOCK; 3、赋予角色权限 GRANT CONNECT TO ZABBIX; GRANT RESOURCE TO ZABBIX; ALTER USER ZABBIX DEFAULT ROLE ALL; 4、赋予系统权限 GRANT SELECT ANY TABLE TO ZABBIX; GRANT CREATE SESSION TO ZABBIX; GRANT SELECT ANY DICTIONARY TO ZABBIX; GRANT UNLIMITED TABLESPACE TO ZABBIX; GRANT SELECT ANY DICTIONARY TO ZABBIX; 5.添加acl权限 exec dbms_network_acl_admin.create_acl(acl => 'resolve.xml',description => 'resolve acl', principal =>'ZABBIX', is_grant => true, privilege => 'resolve'); exec dbms_network_acl_admin.assign_acl(acl => 'resolve.xml', host =>'*'); commit;
|
/etc/init.d/orabbix start #重新加载配置文件用下面命令 systemctl daemon-reload
|
日志位置${ORABBIX_HOME}/logs
验证zabbix是否运行正常,通过访问http://IP/zabbix即可。