Zabbix4.0 LTS企业级监控系统之二进制安装

Zabbix4.0 LTS企业级监控系统安装

在这里插入图片描述

1. 初始化centos 7
[root@localhost ~]# yum -y install wget  #安装wget命令
[root@localhost ~]# yum -y install vim #安装vim编辑器
[root@localhost ~]# yum -y install bash-completion  #安装命令补齐功能,安装完成关闭重启xShell或者secureCRT即可

2. 防火墙和selinux设置

方式一:关闭防火墙和selinux(测试环境)

[root@Zabbix-Server ~]# systemctl stop firewalld.service 
[root@Zabbix-Server ~]# systemctl enable firewalld.service 
[root@Zabbix-Server ~]# getenforce
[root@Zabbix-Server ~]# vim /etc/selinux/config 
	SELINUX=disabled

方式二:添加防火墙策略和修改selinux的sebool值(生产环境)
firewall防火墙(开启状态下)
本服务器同为server和agent端,所以以下命令都需执行

server端:

[root@Zabbix-Server ~]# firewall-cmd --zone=public --add-port=10050/tcp --permanent 
[root@Zabbix-Server ~]# firewall-cmd --zone=public --add-port=10051/tcp --permanent
[root@Zabbix-Server ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent

agentd端:

[root@docker-web-test~]# firewall-cmd --zone=public --add-port=10050/tcp --permanent
[root@docker-web-test~]# firewall-cmd --reload		#重启
[root@docker-web-test~]# firewall-cmd --list-all		#查询

配置selinux(开启状态下)

[root@Zabbix-Server ~]# getsebool httpd_can_network_connect
[root@Zabbix-Server ~]# setsebool -P httpd_can_network_connect on
3. 在CentOS7添加 Zabbix 软件仓库

安装软件仓库配置包,这个包包含了 yum(软件包管理器)的配置文件。

#centos 7 添加阿里云镜像
[root@localhost ~]#wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@localhost ~]#yum install epel-release
#增加Zabbix镜像源
[root@localhost ~]# rpm -ivh http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
4. 安装 Zabbix Server/Frontend(前端Web展示)
[root@localhost ~]# yum -y install  zabbix-server-mysql zabbix-web-mysql
5. 安装MariaDB

MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。开发这个分支的原因之一是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方式来避开这个风险。

[root@localhost ~]# yum search mariadb-server
	mariadb-server.x86_64 : The MariaDB server and related files
[root@localhost ~]# yum -y install mariadb-server.x86_64 #安装mariadb
[root@localhost ~]# systemctl  start mariadb.service  #启动mariadb
[root@localhost ~]# systemctl  enable mariadb.service #开机自启mariadb
[root@localhost ~]# ps -ef | grep mysql  /  ps aux | grep mysql
#查看mariadb进程
[root@localhost ~]# systemctl  status mariadb.service #查看服务

初始化mariadb

[root@localhost ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):  #当前没有密码直接回车
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y #是否设置root密码
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y #是否移除匿名用户
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n #不允许root远程登陆
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y #移除测试数据库
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y  #是否重新加载权限表
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
至此初始化完成

创建用户及导入数据

[root@localhost ~]# mysql -uroot -p
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin; #创建zabbix数据库字符集为utf8
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; #创建用户zabbix并授权
MariaDB [(none)]> flush privileges; #刷新权限
MariaDB [(none)]> quit #退出 

[root@localhost ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix #导入Zabbix server 的初始数据库 schema 和数据
Enter password: 
[root@localhost ~]# mysql -uroot -p
Enter password: 
 MariaDB [(none)]> use zabbix;
 MariaDB [zabbix]> show tables;
 144 rows in set (0.00 sec) #至此导入数据完成
6. 配置Zabbix Server

编辑 zabbix_server.conf

[root@localhost ~]#vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix

启动 Zabbix server 进程

[root@localhost ~]# systemctl start zabbix-server.service 
[root@localhost ~]# systemctl enable zabbix-server.service
more /var/log/zabbix/zabbix_server.log
[root@localhost ~]# cat /var/log/zabbix/zabbix_server.log
cannot start preprocessing service: Cannot bind socket to "/var/run/zabbix/zabbix_server_preprocessing.sock": [13] Permission denied. #报错是因为设置selinux没有重启,重启解决
7. Zabbix 前端配置

Zabbix 前端的 Apache 配置文件位于 /etc/httpd/conf.d/zabbix.conf。

[root@localhost ~]# vim /etc/httpd/conf.d/zabbix.conf
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

[root@localhost ~]# systemctl start httpd.service #启动Apache
[root@localhost ~]# systemctl enable httpd.service #开机自启
8. 访问前端

浏览器访问:http://zabbix-server-ip/zabbix
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
安装 Zabbix agent :

[root@localhost ~]# yum -y install zabbix-agent
[root@localhost ~]# systemctl start zabbix-agent.service 
[root@localhost ~]# systemctl enable zabbix-agent.service

重新刷新页面;
在这里插入图片描述

9. 解决中文乱码

在这里插入图片描述

[root@localhost ~]# yum search lrzsz 
[root@localhost ~]# yum -y install lrzsz.x86_64 #安装上传下载功能,lrzsz是一款在linux里可代替ftp上传和下载的程序

在window系统C:\Windows\Fonts找一个字体;

[root@localhost ~]# cd /usr/share/zabbix/assets/fonts/
[root@localhost fonts]# ls
graphfont.ttf
[root@localhost fonts]# rz #选择刚才的字体
[root@localhost fonts]# ll -h
总用量 14M
lrwxrwxrwx. 1 root root  33 5月  28 16:56 graphfont.ttf -> /etc/alternatives/zabbix-web-font
-rw-r--r--  1 root root 14M 6月  11 2016 YaheiConsolasHybrid.ttf
[root@localhost fonts]# \mv YaheiConsolasHybrid.ttf graphfont.ttf  #强制吧YaheiConsolasHybrid重命名为graphfont覆盖,刷新页面查看

在这里插入图片描述
至此二进制安装zabbix完成;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章