51.yum安装zabbix4.4

发表于 linux 分类,标签:
yum安装zabbix
1.确保防火墙,selinux已经关闭
# systemctl stop firewalld
# systemctl disable firewalld

# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

# setenforce 0


2.修改用户资源限制
vim /etc/security/limits.conf
root soft nofile 65535
root hard nofile 65535
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
* hard core unlimited
* soft core unlimited
 
3.安装zabbix yum源

rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm


安装epel源,用于支持nginx

yum install epel-release


安装zabbix相关软件包
yum search zabbix
yum -y install zabbix-*
或者只安装以下组件
for pkgs in  zabbix-server-mysql zabbix-web-mysql zabbix-web-mysql zabbix-agent zabbix-get zabbix-web zabbix-sender zabbix-nginx-conf ;do yum -y install $pkgs;done
zabbix-agent-4.4.7-1.el7.x86_64
zabbix-get-4.4.7-1.el7.x86_64
zabbix-release-4.4-1.el7.noarch
zabbix-server-mysql-4.4.7-1.el7.x86_64
zabbix-web-4.4.7-1.el7.noarch
zabbix-sender-4.4.7-1.el7.x86_64
zabbix-nginx-conf-4.4.7-1.el7.noarch

zabbix-web-mysql-4.4.7-1.el7.noarch


4.安装mariadb并初始化导入zabbix表结构数据
安装mariadb数据库并启动
yum -y install mariadb-*
systemctl enable mariadb

systemctl start mariadb


创建zabbix数据库
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix@123';
flush privileges;

quit;


导入数据

zcat /usr/share/doc/zabbix-server-mysql-*/create.sql.gz |mysql -uzabbix -p'zabbix@123' -b zabbix


5.修改zabbix_server.conf并启动zabbix_server

vim /etc/zabbix/zabbix_server.conf |grep -v "^#" |grep -v "^$" |grep -v grep

cat /etc/zabbix/zabbix_server.conf |grep -v "^#" |grep -v "^$" |grep -v grep  

LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
DebugLevel=3
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix@123
StartPollers=16
StartPollersUnreachable=4
StartTrappers=10
StartPingers=8
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
CacheSize=1024M
StartDBSyncers=8
HistoryCacheSize=1024M
HistoryIndexCacheSize=256M
TrendCacheSize=1024M
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000

StatsAllowedIP=127.0.0.1


systemctl enable zabbix-server

systemctl start zabbix-server


5.修改nginx/php-fpm配置,将server端口配置为8080,端口配置没有特殊要求,只要未被占用都可配置。若想使用80端口,则需要注释或修改nginx.conf的server {}段配置
vim /etc/nginx/conf.d/zabbix.conf
listen          8080;

server_name     monitor.com;


修改php时区
vi /etc/php-fpm.d/zabbix.conf

php_value[date.timezone] = Asia/Shanghai


systemctl enable php-fpm
systemctl restart php-fpm
systemctl enable nginx

systemctl start nginx


6.设置并登录zabbix系统

配置action,实现使安装有Zabbix Agent的Linux自动注册到Zabbix Server端;

步骤:configuration>>action>>Event source(选择Auto registration)>>Create Action,我们按如下步骤来定义个action。


7.安装zabbix-agent
yum -y install zabbix-agent
修改zabbix-agent配置,monitor01为Zabbix Server主机的hostname,所有Zabbix agent主机上都要添加Zabbix Server主机的hostname。
sed -i "s/Server=127.0.0.1/Server=monitor01/g" /etc/zabbix/zabbix_agentd.conf
sed -i "s/ServerActive=127.0.0.1/ServerActive=monitor01/g" /etc/zabbix/zabbix_agentd.conf
sed -i "s#Hostname=Zabbix server#Hostname=$(hostname)#g" /etc/zabbix/zabbix_agentd.conf

sed -i "s#\# HostMetadataItem=#HostMetadataItem=system.uname#g" /etc/zabbix/zabbix_agentd.conf


启动zabbix-agent
systemctl enable zabbix-agent
systemctl restart zabbix-agent
如果有几十上百个节点,我们就需要借助Ansible或SaltStack等批量部署工具来快速部署了。


0 篇评论

发表我的评论