zabbix
zabbix版本的选择
![9469008-dbf8a78d80da9757.png](https://i-blog.csdnimg.cn/blog_migrate/5072c22b6c73bd5bb3d5b456230cacaf.png)
image.png
安装zabbix 4.0
1.下载zabbix官方yum源
rpm -ivh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
2.更新zabbix安装源
[root@zabbix-server ~]# vim /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/zabbix/4.0/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
如果使用zabbix官方源的话可能会有点慢,清华也有相同的源,所以可以把下载连接换成清华源的下载连接
3.替换下载源为清华源
:%s#http://repo.zabbix.com#https://mirrors.tuna.tsinghua.edu.cn/zabbix#g
![9469008-548e8c5e24d0b911.png](https://i-blog.csdnimg.cn/blog_migrate/9316a16d54ece97e1a935c9a7369e9d9.png)
因为清华源也是同步的zabbix官方源的,路径差不多,只是比官方的多了一层zabbix目录
4.安装zabbix服务端和web端
[root@zabbix ~]# yum install zabbix-server-mysql zabbix-web-mysql -y
5.安装数据库
[root@zabbix ~]# yum install -y mariadb-server
[root@zabbix ~]# systemctl start mariadb && systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
6.对数据库进行安全初始化
[root@zabbix ~]# 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): ##输入root密码,没有就直接回车
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] n ##是否设置root密码
... skipping.
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] y ##是否禁止root远程登录,是的
... Success!
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 ##是否删除test库。删除
- 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!
6.创建数据库和授权用于
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
7.导入zabbix的表到zabbix的数据库
[root@zabbix ~]# ll /usr/share/doc/zabbix-server-mysql*/create.sql.gz
-rw-r--r-- 1 root root 1311368 Jun 26 19:24 /usr/share/doc/zabbix-server-mysql-4.0.10/create.sql.gz
[root@zabbix ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Enter password:
8.为zabbix server/proxy 配置数据库
[root@zabbix ~]# grep '^DB' /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
9.启动zabbix-server 并加入开机自启
[root@zabbix ~]# systemctl start zabbix-server.service
[root@zabbix ~]# systemctl enable zabbix-server.service
[root@zabbix ~]# netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 8441/mysqld
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 7156/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 7239/master
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 9568/zabbix_server
tcp6 0 0 :::22 :::* LISTEN 7156/sshd
tcp6 0 0 ::1:25 :::* LISTEN 7239/master
tcp6 0 0 :::10051 :::* LISTEN 9568/zabbix_server
udp 0 0 127.0.0.1:323 0.0.0.0:* 6154/chronyd
udp6 0 0 ::1:323 :::* 6154/chronyd
10.配置zabbix-web 前端
[root@zabbix /etc/zabbix]# 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 max_input_vars 10000
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai
zabbix 是基于httpd开发的,httpd 是通过一个php.so的文件调取php的。所以在承受的并发上面没有nginx高。但是监控并不是很多人看。看监控的也就只有运维这些人。还有就是nginx需要单独配置,而httpd自己起动httpd自己就可以了。
11.配置好之后起的httpd
systemctl start httpd
[root@zabbix /etc/zabbix]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
然后输入ip就可以访问zabbix了 10.0.0.81/zabbix
![9469008-96de04e7c3688237.png](https://i-blog.csdnimg.cn/blog_migrate/9ac67ec194d95a67a818739815c9b668.png)
image.png
![9469008-efcb033df8e11940.png](https://i-blog.csdnimg.cn/blog_migrate/2d7a7df1a03a31f9c7e14c9a33cde941.png)
image.png
输入创建数据库的时候设置的信息
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
![9469008-80c41f16f6c7e850.png](https://i-blog.csdnimg.cn/blog_migrate/ea96f29171319cd17d8b442ceee92a78.png)
如果数据库填写没问题的话就会进入看到这一个页面,如果报错了的话说明数据库信息填写有误。这里可以设置一个名字。
![9469008-334355df9d176071.png](https://i-blog.csdnimg.cn/blog_migrate/b7f700332745642ba2868287e77b5112.png)
image.png
最后会显示出你填写的信息
![9469008-5b6e4367382f3960.png](https://i-blog.csdnimg.cn/blog_migrate/049469867e652b6b234b74cb3622e77d.png)
image.png
点下一步后就安装成功了
![9469008-e4d91f1d57722f0e.png](https://i-blog.csdnimg.cn/blog_migrate/f49efcd90ad0d128720ec482dd0c4dca.png)
image.png
![9469008-0e902aa3370fa10a.png](https://i-blog.csdnimg.cn/blog_migrate/d9ec7a779e4274e23b5a8db23d57f9f6.png)
image.png
12。输入后台登录账户
这是官方在数据库的表里创建好的。账号Admin 密码 zabbix
![9469008-45f28932fa084462.png](https://i-blog.csdnimg.cn/blog_migrate/9c16573c0273e562a103130e6d482bdc.png)
image.png
zabbix安装成功
![9469008-b53999aa1098f214.png](https://i-blog.csdnimg.cn/blog_migrate/61601071ae558399c61d6fd505873f7f.png)
image.png
zabbix配置
要想学好zabbix就先把zabbix设置成中文。zabbix本身就支持中文
![9469008-e23712366e0f42d4.png](https://i-blog.csdnimg.cn/blog_migrate/c847e047751d674c01766564b7f28077.png)
image.png
![9469008-4f8e4e968bca8562.png](https://i-blog.csdnimg.cn/blog_migrate/2b42c5ef5d37ffc8c05792eedaa3e0ed.png)
image.png
![9469008-c5c5a8166ab2304b.png](https://i-blog.csdnimg.cn/blog_migrate/3a151bb29eac6657187ffb6573ec414d.png)
image.png
![9469008-46dbc0d8115b5d0d.png](https://i-blog.csdnimg.cn/blog_migrate/eaf7407c064fa5b50b9b18ae61756abc.png)
image.png