Zabbix安装部署
修改镜像源为默认镜像源
[root@server2 ~]#cd /etc/yum.repos.d/[root@server2 ~]#cp CentOS-Base.repo_bak CentOS-Base.repo[root@server2 ~]#yum clean all[root@server2 ~]#yum makecache[root@server2 ~]#yum -y update
node1服务端
- 服务组件:Zabbix_Server & Zabbix_web & Mysql
- Linux我们也用的Centos7.因为免费好用.我们可以先改一下yum源到阿里云上面.这样安装速度快一点,访问国外的yum实在是太慢了.
[root@server2 ~]# yum install -y wget[root@server2 ~]#mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak[root@server2 ~]#ls /etc/yum.repos.d/[root@server2 ~]#wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo[root@server2 ~]#yum makecache[root@server2 ~]# yum -y update[root@server2 ~]#cat /etc/yum.repos.d/CentOS-Base.repo
- 安装zabbix
[root@server2 ~]# wget https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm[root@server2 ~]# rpm -ivh zabbix-release-4.0-2.el7.noarch.rpm
- 修改相关源配置文件
[root@server2 ~]# vi /etc/yum.repos.d/zabbix.repo[zabbix]name=Zabbix Official Repository - $basearchbaseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/$basearch/enabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591[zabbix-debuginfo]name=Zabbix Official Repository debuginfo - $basearchbaseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/$basearch/debuginfo/enabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591gpgcheck=1[zabbix-non-supported]name=Zabbix Official Repository non-supported - $basearchbaseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/non-supported/rhel/7/$basearch/enabled=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIXgpgcheck=1
- 安装组件
[root@server2 ~]# yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent -y
- 安装数据库
####因为我们一开始修改了镜像源,直接下载是会下载不成功的,所以我们要在目录下创建一个mariadb的镜像文件,并进行配置(这里我们选择中科大镜像)[root@server2 ~]# vi /etc/yum.repos.d/mariadb.repo[mariadb-main]name = MariaDB Server#baseurl = https://downloads.mariadb.com/MariaDB/mariadb-10.4/yum/rhel/$releasever/$basearchbaseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.4/centos7-amd64#gpgkey = file:///etc/pki/rpm-gpg/MariaDB-Server-GPG-KEYgpgkey = https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDBgpgcheck = 1enabled = 1[root@server2 ~]# yum install mariadb‐server ‐y#####国外镜像源[mariadb]name = MariaDBbaseurl = http://yum.mariadb.org/10.1/centos7-amd64gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDBgpgcheck=1
- 数据库启动和设置开机自启动
[root@server2 ~]# systemctl start mariadb.service[root@server2 ~]# systemctl enable mariadb.service
- 数据库安全初始化
[root@server2 ~]# mysql_secure_installationNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDBSERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!In order to log into MariaDB to secure it, we'll need the currentpassword for the root user. If you've just installed MariaDB, andhaven't set the root password yet, you should just press enter here.Enter current password for root (enter for none):。。。。。。Remove anonymous users? [Y/n] y。。。。。Disallow root login remotely? [Y/n] y。。。。。Remove test database and access to it? [Y/n] y。。。。。Reload privilege tables now? [Y/n] y。。。。。Thanks for using MariaDB!
- 创建zabbix相关数据库
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;Query OK, 1 row affected (0.001 sec)MariaDB [(none)]> grant all on zabbix.* to zabbix@‘localhost’ identified by '123456';Query OK, 0 rows affected (0.001 sec
- 导入zabbix表结构和初始数据
root@server2 ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p123456 zabbix
- 配置zabbix-server连接数据库
[root@server2 ~]# cat /etc/zabbix/zabbix_server.conf | grep -Ev "^$|^#"LogFile=/var/log/zabbix/zabbix_server.logLogFileSize=0PidFile=/var/run/zabbix/zabbix_server.pidSocketDir=/var/run/zabbixDBHost=localhostDBName=zabbixDBUser=zabbixDBPassword=123456SNMPTrapperFile=/var/log/snmptrap/snmptrap.logTimeout=4AlertScriptsPath=/usr/lib/zabbix/alertscriptsExternalScripts=/usr/lib/zabbix/externalscriptsLogSlowQueries=3000[root@server2 ~]# systemctl start zabbix-server[root@server2 ~]# systemctl enable zabbix-server
- 关闭防火墙等,然后Windows访问zabbix
[root@server2 ~]# setenforce 0[root@server2 ~]# systemctl stop firewalld
- 这时候我们需要修改时区
[root@server2 ~]# cat /etc/httpd/conf.d/zabbix.conf<IfModule mod_php5.c>php_value max_execution_time 300php_value memory_limit 128Mphp_value post_max_size 16Mphp_value upload_max_filesize 2Mphp_value max_input_time 300php_value max_input_vars 10000php_value always_populate_raw_post_data -1php_value date.timezone Asia/Shanghai</IfModule>[root@server2 ~]# systemctl restart httpd
