zabbix 服务端一键安装脚本
#!/bin/bash #Zabbix-Server 5.0 #安装zabbix源、aliyun YUM源 cd /etc/yum.repos.d/ rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm sed -i.bak 's#repo.zabbix.com#mirrors.aliyun.com/zabbix#' zabbix.repo sed -i 's#enabled=0#enabled=1#' zabbix.repo #安装zabbix yum -y install zabbix-server-mysql zabbix-agent yum -y install centos-release-scl yum -y install zabbix-web-mysql-scl zabbix-apache-conf-scl #安装启动 mariadb数据库 yum -y install mariadb mariadb-server httpd systemctl start mariadb.service #创建数据库 mysql -e 'create database zabbix character set utf8 collate utf8_bin;' mysql -e 'grant all privileges on zabbix.* to zabbix@localhost identified by "zabbix";' mysql -e 'flush privileges;' #导入数据 zcat /usr/share/doc/zabbix-server-mysql-*/create.sql.gz|mysql -uzabbix -pzabbix -Dzabbix #配置zabbixserver连接mysql sed -i.bak '/^# DBPassword=*/i DBPassword=zabbix' /etc/zabbix/zabbix_server.conf #添加时区 sed -i.bak '/^; php_value[date.timezone]*/i php_value[date.timezone] = Asia/Shanghai' /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf #解决中文乱码 yum -y install wqy-microhei-fonts \cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf #启动服务 systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm #开机自启动 systemctl enable mariadb.service systemctl enable httpd systemctl enable zabbix-server
访问地址:echo "http://`hostname -I|awk '{print $1}'`/zabbix"
zabbix前端已经安装完成!超级用户名是Admin,密码是zabbix
zabbix客户端一键安装脚本
#!/bin/bash #Zabbix-Agent 5.0 Zabbix_Service=192.168.63.20 #安装zabbix源、aliyun YUM源 cd /etc/yum.repos.d/ rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm sed -i.bak 's#repo.zabbix.com#mirrors.aliyun.com/zabbix#' zabbix.repo sed -i 's#enabled=0#enabled=1#' zabbix.repo #安装zabbix yum -y install zabbix-agent #修改配置文件 sed -i.bak "s/^Server=127.0.0.1/Server=$Zabbix_Service/" /etc/zabbix/zabbix_agentd.conf sed -i "s/^ServerActive=127.0.0.1/ServerActive=$Zabbix_Service/" /etc/zabbix/zabbix_agentd.conf sed -i "/^Hostname=/c Hostname=$(echo `hostname`)" /etc/zabbix/zabbix_agentd.conf #开启zabbix-agent服务 10050 端口 systemctl start zabbix-agent #设置开机自启 systemctl enable zabbix-agent #输出提示 echo -e "Now you can use \033[32mnetstat -tnlp\033[0m check \033[33mport:10050\033[0m"
问题:
[root@localhost ~]# systemctl status zabbix-server ● zabbix-server.service - Zabbix Server Loaded: loaded (/usr/lib/systemd/system/zabbix-server.service; enabled; vendor preset: disabled) Active: activating (auto-restart) (Result: exit-code) since 二 2023-02-28 16:03:00 CST; 2s ago Process: 16549 ExecStop=/bin/kill -SIGTERM $MAINPID (code=exited, status=1/FAILURE) Process: 16463 ExecStart=/usr/sbin/zabbix_server -c $CONFFILE (code=exited, status=0/SUCCESS) Main PID: 16472 (code=exited, status=0/SUCCESS) CGroup: /system.slice/zabbix-server.service 2月 28 16:03:00 localhost.localdomain systemd[1]: zabbix-server.service: control process exited, code=exited status=1 2月 28 16:03:00 localhost.localdomain systemd[1]: Unit zabbix-server.service entered failed state. 2月 28 16:03:00 localhost.localdomain systemd[1]: zabbix-server.service failed.
解决方案:关闭selinux