查看系统基本信息

  1. #基本信息查看
  2. ifconfig ens33 |awk 'NR==2{print $2}'
  3. hostname
  4. sed -i 's/SELINUX=enforcing/SELINUX=desabled/' /etc/selinux/config
  5. getenforce 0
  6. systemctl disable --now firewalld

安装zabbix

  1. # server安装zabbix
  2. # 1.获取zabbix源
  3. rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
  4. sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#g' /etc/yum.repos.d/zabbix.repo
  5. sed -i 's/enabled=0/enabled=1/' /etc/yum.repos.d/zabbix.repo
  6. yum clean all
  7. yum makecache
  8. # 2.安装zabbix客户端
  9. yum -y install zabbix-server-mysql zabbix-agent
  10. # 3.安装多个版本的软件工具,并且不会影响整个系统的依赖环境
  11. yum -y install centos-release-scl
  12. # 4.修改前端源,安装前端环境(并且安装到scl环境下)
  13. yum -y install zabbix-web-mysql-scl zabbix-apache-conf-scl
  14. 或者nginx安装:yum -y install zabbix-web-mysql-scl zabbix-nignx-conf-scl
  15. # 5.安装数据库,配置数据库开机启动,查看端口
  16. yum -y install mariadb-server mariadb
  17. systemctl enable --now mariadb
  18. netstat -tunlp |grep 3306
  19. # 6.初始化数据库
  20. mysql_secure_installation [回车--y--password--password--y--n--y--y]
  21. mysql -uroot -p123
  22. # 7.添加数据库用户授权
  23. > show databases;
  24. > use mysql;
  25. > show tables;
  26. create database zabbix character set utf8 collate utf8_bin;
  27. create user zabbix@localhost identified by 'password';
  28. grant all privileges on zabbix.* to zabbix@localhost;
  29. flush privileges;
  30. exit;
  31. # 8.使用zabbix-mysql导入数据库信息【-u用户名 -p 后面是数据库的库名字 然后才需要输入密码】
  32. zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
  33. # 9.修改zabbix密码
  34. vim /etc/zabbix/zabbix_server.conf
  35. DBPassword=password
  36. # 10.修改php配置
  37. vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf //配置文件二
  38. listen.acl_users = apache,nginx
  39. php_value[date.timezone] = Asia/Shanghai
  40. ###(如果是Apache忽略)
  41. vim /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf //配置文件一
  42. listen 80;
  43. server_name 192.168.11.10;
  44. fastcgi_pass 127.0.0.1:9000;
  45. # fastcgi_pass unix:/var/opt/rh/rh-php72/run/php-fpm/zabbix.sock;
  46. vim /etc/opt/rh/rh-nginx116/nginx/nginx.conf //配置文件三
  47. server {
  48. listen 80 default_server;
  49. #listen [::]:80 default_server;
  50. #server_name _;
  51. #root /opt/rh/rh-nginx116/root/usr/share/nginx/html;
  52. # Load configuration files for the default server block.
  53. #include /etc/opt/rh/rh-nginx116/nginx/default.d/*.conf;
  54. }
  55. vim /etc/opt/rh/rh-php72/php.ini //配置文件四
  56. 383 max_execution_time = 300
  57. 393 max_input_time = 300
  58. 672 post_max_size = 16M
  59. 902 date.timezone = Asia/Shanghai
  60. # 11.启动zabbix相关服务
  61. systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
  62. systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
  63. #启动报错或Zabbix server is running NO
  64. 1. 查看日志 tail -5 /var/log/zabbix/zabbix_server.log
  65. 2. 检查配置文件
  66. 3. 数据库授权问题(可能不让localhost登录)
  67. # 12.访问zabbix入口
  68. http://ip/zabbix
  69. http://ip
  70. # 13.zabbix默认用户密码
  71. UAdmin
  72. Pzabbix
  73. # 同步时间
  74. yum install ntpdate -y
  75. ntpdate -u ntp.aliyun.com
  76. # 14.时区的统一
  77. mv /etc/localtime{,.bak}
  78. ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
  79. # 15.zabbix乱码问题 【zabbix-server安装中文字体】
  80. yum -y install wqy-microhei-fonts
  81. \cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf

client配置

  1. # client配置
  2. # 1. 获取zabbix源
  3. rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
  4. sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#g' /etc/yum.repos.d/zabbix.repo
  5. yum clean all
  6. yum makecache
  7. # 2. 安装zabbix-agent2(通过golang写的,并发好 端口 10050)
  8. yum -y install zabbix-agent2
  9. # 3 编写zabbix客户端配置文件
  10. vim /etc/zabbix/zabbix_agent2.conf
  11. Server=192.168.11.10
  12. # 4. 同步时间
  13. yum install ntpdate -y
  14. ntpdate -u ntp.aliyun.com
  15. date
  16. # 5. 启动zabbix-agent2程序
  17. systemctl restart zabbix-agent2