查看系统基本信息
#基本信息查看ifconfig ens33 |awk 'NR==2{print $2}' hostname sed -i 's/SELINUX=enforcing/SELINUX=desabled/' /etc/selinux/configgetenforce 0systemctl disable --now firewalld
安装zabbix
# server安装zabbix# 1.获取zabbix源rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpmsed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#g' /etc/yum.repos.d/zabbix.reposed -i 's/enabled=0/enabled=1/' /etc/yum.repos.d/zabbix.repoyum clean all yum makecache# 2.安装zabbix客户端yum -y install zabbix-server-mysql zabbix-agent # 3.安装多个版本的软件工具,并且不会影响整个系统的依赖环境yum -y install centos-release-scl # 4.修改前端源,安装前端环境(并且安装到scl环境下)yum -y install zabbix-web-mysql-scl zabbix-apache-conf-scl 或者nginx安装:yum -y install zabbix-web-mysql-scl zabbix-nignx-conf-scl # 5.安装数据库,配置数据库开机启动,查看端口yum -y install mariadb-server mariadbsystemctl enable --now mariadbnetstat -tunlp |grep 3306# 6.初始化数据库mysql_secure_installation [回车--y--password--password--y--n--y--y]mysql -uroot -p123# 7.添加数据库用户授权> show databases;> use mysql;> show tables;create database zabbix character set utf8 collate utf8_bin;create user zabbix@localhost identified by 'password';grant all privileges on zabbix.* to zabbix@localhost;flush privileges;exit;# 8.使用zabbix-mysql导入数据库信息【-u用户名 -p 后面是数据库的库名字 然后才需要输入密码】zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix# 9.修改zabbix密码vim /etc/zabbix/zabbix_server.conf DBPassword=password# 10.修改php配置vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf //配置文件二listen.acl_users = apache,nginx php_value[date.timezone] = Asia/Shanghai###(如果是Apache忽略)vim /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf //配置文件一listen 80;server_name 192.168.11.10;fastcgi_pass 127.0.0.1:9000;# fastcgi_pass unix:/var/opt/rh/rh-php72/run/php-fpm/zabbix.sock;vim /etc/opt/rh/rh-nginx116/nginx/nginx.conf //配置文件三server { listen 80 default_server; #listen [::]:80 default_server; #server_name _; #root /opt/rh/rh-nginx116/root/usr/share/nginx/html; # Load configuration files for the default server block. #include /etc/opt/rh/rh-nginx116/nginx/default.d/*.conf;}vim /etc/opt/rh/rh-php72/php.ini //配置文件四383 max_execution_time = 300393 max_input_time = 300672 post_max_size = 16M902 date.timezone = Asia/Shanghai# 11.启动zabbix相关服务systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpmsystemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm#启动报错或Zabbix server is running NO1. 查看日志 tail -5 /var/log/zabbix/zabbix_server.log2. 检查配置文件3. 数据库授权问题(可能不让localhost登录)# 12.访问zabbix入口http://ip/zabbixhttp://ip# 13.zabbix默认用户密码U:AdminP:zabbix# 同步时间yum install ntpdate -yntpdate -u ntp.aliyun.com# 14.时区的统一mv /etc/localtime{,.bak}ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime# 15.zabbix乱码问题 【zabbix-server安装中文字体】yum -y install wqy-microhei-fonts\cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf
client配置
# client配置# 1. 获取zabbix源rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpmsed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#g' /etc/yum.repos.d/zabbix.repoyum clean allyum makecache# 2. 安装zabbix-agent2(通过golang写的,并发好 端口 10050)yum -y install zabbix-agent2# 3 编写zabbix客户端配置文件 vim /etc/zabbix/zabbix_agent2.confServer=192.168.11.10# 4. 同步时间yum install ntpdate -yntpdate -u ntp.aliyun.comdate# 5. 启动zabbix-agent2程序systemctl restart zabbix-agent2