参考网站:
https://www.cnblogs.com/xiewenming/p/7732144.html
https://www.cnblogs.com/clsn/p/7885990.html Zabbix 3.0 从入门到精通(zabbix使用详解)
https://yq.aliyun.com/articles/43308
https://yq.aliyun.com/articles/94733
https://www.zabbix.com/documentation/3.0/manual/installation 附 官方英文版文档
说明:根据zabbix server3.0官方要求,目前zabbix server3.0在centos6 OS上不能进行yum安装。如果一定要在centos6 OS上进行安装zabbix server3.0的话,强烈建议通过源码方式进行编译安装,同时还需要注意PHP的版本。考虑到这些因素,所以在此我们是在centos7 OS上进行yum安装zabbix server3.0。
在centos7上安装zabbix server3.0之前,我们首先搭建zabbix所需要的lamp环境。
准备一台虚拟机Centos7 172.16.160.94
yum update -y yum repolist 列出yum仓库 yum clean all 清理yum 缓存 yum makecache 缓存yum仓库。
一,关闭selinux和iptables
[root@linux-node2 ~]# systemctl stop firewalld.service 永久关闭selinux防火墙 [root@zabbix zabbix]# vi /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. #SELINUX=enforcing SELINUX=disabled # SELINUXTYPE= can take one of three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. #SELINUXTYPE=targeted 临时关闭 [root@linux-node2 ~]# setenforce 0 setenforce: SELinux is disabled 查看是否关闭 [root@zabbix zabbix]# getenforce Permissive
二,安装Zabbix rpm包仓库
#安装zabbix源、aliyun YUM源 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
或以下命令:
wget -P /etc/yum.repos.d http://mirrors.aliyun.com/repo/Centos-7.repo
三,安装zabbix-server-mysql和zabbix-web-mysql
[root@linux-node2 ~]# yum install -y zabbix-server-mysql zabbix-web-mysql
四,安装并且启动mariadb
现在开始安装lamp环境,使用如下命令:
yum -y install mariadb mariadb-server php php-mysql httpd
lamp安装完毕后,我们现在来配置mysql数据库。
设置开机自启动mysql,并启动mysql,使用如下命令:
systemctl enable mariadb
systemctl start mariadb
初始化mysql数据库,并配置root用户密码。使用如下命令:
mysql_secure_installation
我们直接敲回车键即可。因为centos7上mysql的默认root用户密码为空。
五,创建zabbix数据库,创建zabbix账号
mysql初始化完毕后,我们现在来创建zabbix数据库及其用户,使用如下命令:
[root@linux-node2 ~]# mysql -uroot -p ... mysql> create database zabbix character set utf8 collate utf8_bin; Query OK, 1 row affected (0.00 sec) mysql> grant all privileges on zabbix.* to 'root'@'localhost' identified by 'zabbix'; Query OK, 0 rows affected (0.00 sec) mysql> grant all privileges on zabbix.* to 'zabbix'@'%' identified by 'zabbix'; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.01 sec)
六,导入默认的zabbix数据库信息
[root@linux-node2 zabbix-server-mysql-3.0.12]# zcat /usr/share/doc/zabbix-server-mysql-3.0.19/create.sql.gz | mysql zabbix -uzabbix -pzabbix
七,修改zabbix_server.conf的配置文件
[root@linux-node2 ~]# grep ^DB /etc/zabbix/zabbix_server.conf DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=zabbix
或:
#配置zabbixserver连接mysql sed -i.ori '115a DBPassword=zabbix' /etc/zabbix/zabbix_server.conf
八,修改配置文件/etc/httpd/conf.d/zabbix.conf,时区改成 Asia/Shanghai
php_value max_execution_time 300 php_value memory_limit 128M php_value post_max_size 16M php_value upload_max_filesize 2M php_value max_input_time 300 php_value always_populate_raw_post_data -1 php_value date.timezone Asia/Shanghai
或:
#添加时区 sed -i.ori '18a php_value date.timezone Asia/Shanghai' /etc/httpd/conf.d/zabbix.conf
九,启动apache/zabbix-server服务并设置为开机启动
解决中文乱码 yum -y install wqy-microhei-fonts cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf
[root@linux-node2 ~]# systemctl start httpd [root@linux-node2 ~]# systemctl enable httpd [root@linux-node2 ~]# netstat -an |grep 80 tcp 0 0 192.168.56.11:80 0.0.0.0:* LISTEN [root@linux-node2 ~]# systemctl start zabbix-server [root@linux-node2 ~]# systemctl enable zabbix-server
或:
#写入开机自启动 chmod +x /etc/rc.d/rc.local cat >>/etc/rc.d/rc.local<<EOF systemctl start mariadb.service systemctl start httpd systemctl start zabbix-server EOF
#输出信息 echo "浏览器访问 http://`hostname -I|awk '{print $1}'`/zabbix"
查看zabbix-server日志
[root@linux-node1 ~]# tailf /var/log/zabbix/zabbix_server.log
zabbix-server的web目录
[root@linux-node1 zabbix]# ls /usr/share/zabbix
十,访问网站,例如:http://本机IP/zabbix,如下图所示:
十一,选择下一步,Check of pre-requisites,如图所示:
十二,选择下一步,配置zabbix server detail,如下图所示:
十三,选择下一步,配置zabbix server detail,如下图所示:
十四:点击下一步,便完成安装,安装完成的界面如下图所示:
十五,安装完成,如下图所示:
十六:Zabbix·server的默认账号Admin 密码zabbix,如图所示:
十七,默认登陆首页,如下图所示:
十八,移除或改名web目录下面的setup.php文件
[root@linux-node2 zabbix]# pwd /usr/share/zabbix [root@linux-node2 zabbix]# mv setup.php setup.php.bak
十九,更改web登陆的Admin默认密码
二十,设置新的密码,这里也可以设置界面的主题、语言和登陆后显示的默认界面等
至此安装部分结束
二十一,安装zabbix客户端
yum install zabbix-agent -y sed -i.ori 's#Server=127.0.0.1#Server=172.16.160.94#' /etc/zabbix/zabbix_agentd.conf systemctl start zabbix-agent.service
二十二,服务端安装zabbix-get检测工具
[root@zabbix zabbix]# yum install zabbix-get -y
二十二,在服务端进行测试
#注意:只能在服务端进行测试 [root@zabbix zabbix]# zabbix_get -s 172.16.160.94 -p 10050 -k "system.cpu.load[all,avg1]" 0.030000 [root@zabbix zabbix]#
[root@zabbix tmp]# zabbix_get -s 172.16.160.35 -p 10050 -k "system.uname" Linux amoyzhu 3.10.0-693.5.2.el7.x86_64 #1 SMP Fri Oct 20 20:32:50 UTC 2017 x86_64 [root@zabbix tmp]#