Monitoring system set up zabbix

Building automation services platform --- zabbix monitoring platform

Preparing the environment

  1. Prepare a Linux host (CentOS 7, for example)
  2. LAMP platform has been installed
  3. Turn off the firewall and SELinux
  4. Set the IP address
  5. Set up yum source
  6. Individual symbol of the blog linux text editing language instruction in conflict, I will read easily separated by a space specific to the actual subject grammar

Beginning of the experiment

Zabbix ready platform environment

Server Address Settings

Change the hostname

[root@zabbix-server ~] hostnamectl set-hostname zabbix-server   //设置主机名

Configure the IP address

[root@ zabbix-server ~] nmcli connection modify ens33 ipv4.addresses 192.168.139.132  //设置IP地址
[root@ zabbix-server ~] nmcli connection up ens33  //激活网卡

Add Host Mapping

[root@ zabbix-server ~] vim /etc/hosts  

192.168.139.132 zabbix zabbix-server.com   //在vim中写入该指令 另起一行

Check whether the site can ping settings

[root@ zabbix-server ~] ping zabbix-server.com  //ping刚才在vim写入的网址
PING zabbix (192.168.139.132) 56(84) bytes of data.
64 bytes from zabbix (192.168.139.132): icmp_seq=1 ttl=64 time=0.032 ms
64 bytes from zabbix (192.168.139.132): icmp_seq=2 ttl=64 time=0.034 ms

LAMP platform installed and enabled

Install LAMP components

[root@ zabbix-server ~] yum -y install httpd mariadb mariadb-server php php-mysql   //安装软件包
已安装:
  httpd.x86_64 0:2.4.6-89.el7.centos         mariadb.x86_64 1:5.5.60-1.el7_5    
  mariadb-server.x86_64 1:5.5.60-1.el7_5     php.x86_64 0:5.4.16-46.el7         
  php-mysql.x86_64 0:5.4.16-46.el7          

Check whether the installation was successful

[root@zabbix-server ~]# yum list httpd mariadb mariadb-server php php-mysql
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: ap.stykers.moe
 * updates: mirrors.aliyun.com
已安装的软件包
httpd.x86_64                                                       2.4.6-89.el7.centos                                              @updates
mariadb.x86_64                                                     1:5.5.60-1.el7_5                                                 @base   
mariadb-server.x86_64                                              1:5.5.60-1.el7_5                                                 @base   
php.x86_64                                                         5.4.16-46.el7                                                    @base   
php-mysql.x86_64                                                   5.4.16-46.el7        

Enable LAMP Services

[root@zabbix-server ~] systemctl restart httpd mariadb  //重启服务
[root@zabbix-server ~] systemctl enable httpd mariadb  //设置开机自启
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.s

Set up a firewall and SELinux

Turn off the firewall

[root@zabbix-server ~] systemctl stop firewalld.service  //关闭防火墙
[root@zabbix-server ~] systemctl disable firewalld.service  //进制开机自启
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

Close SELinux mechanism

[root@zabbix-server ~] setenforce 0  //使SELinux失效
[root@zabbix-server ~] vim /etc/selinux/config  //开机时禁止
// 进入到vim编辑模式 更改第一个SELinux的值
# 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=disabled**
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

zabbix installation and initialization

Installation zabbix related packages

Confirmation package
may be used on CentOS 7 XFTP even prepared zabbix-server files to / under the root directory of
the installation zabbix Server dependencies

[root@ zabbix-server ~] ls  /root/zabbix-server/
[root@ zabbix-server ~] yum  -y  install  zabbix-server/ *.rpm
[root@zabbix-server ~] yum list "zabbix*"
已安装的软件包
zabbix-agent.x86_64                                                      3.4.15-1.el7                                              @zabbix  
zabbix-release.noarch                                                    3.4-2.el7                                                 installed
zabbix-server-mysql.x86_64                                               3.4.15-1.el7                                              @zabbix  
zabbix-server-pgsql.x86_64                                               3.4.15-1.el7                                              @zabbix  
zabbix-web.noarch                                                        3.4.15-1.el7                                              @zabbix  
zabbix-web-mysql.noarch                                                  3.4.15-1.el7        

Analysis of environmental change your time zone configuration

Zabbix modify web server configuration

[root@zabbix-server ~] vim  /etc/httpd/conf.d/zabbix.conf
...
php_value date.timezone Asia/Shanghai   //删掉#号 将时区改为上海
...
[root@zabbix-server ~] systemctl  restart  httpd  //重启web服务

Initialize the database connection

New zabbix library zabbix authorized users to access password pwd @ 123

[root@zabbix-server ~] mysql  -uroot
MariaDB [(none)]> create  database  zabbix  character  set  utf8  collate   utf8_bin;
MariaDB [(none)]> grant  all  on zabbix.*  to  zabbix@localhost   identified  by   'pwd@123';
MariaDB [(none)]> quit;

Import initial library services provided zabbix

[root@zabbix-server ~] zcat   /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql  -uzabbix  -ppwd@123   zabbix

Setting up the database connection

[root@zabbix-server ~] vim  /etc/zabbix/zabbix_server.conf
...
DBName=zabbix    //数据库名
DBUser=zabbix     //数据库用户
DBPassword=pwd@123     //连接密码

zabbix monitoring interface

Open zabbix related services

启动zabbix-serer、zabbix-agent

[root@zabbix-server ~] systemctl restart zabbix-server zabbix-agent
[root@zabbix-server ~] systemctl enable zabbix-server zabbix-agent

Confirm httpd web service is turned on

[root@zabbix-server ~] systemctl restart httpd

Access the web interface initialization settings

Access monitoring systems deployed zabbix page
accessed in the browser http://192.168.139.132/zabbix/
click the Next Step button
Monitoring system set up zabbix

The confirmation of the status of the correct and click Next Step
Monitoring system set up zabbix

Set library name zabbix, the user name zabbix, password pwd @ 123 Click Next Step
Monitoring system set up zabbix

name a name here again Click Next Step
Monitoring system set up zabbix

Once again points to the point Finish Next Step
Monitoring system set up zabbix

zabbix basic settings

回到登录界面 开始登陆
使用默认管理员的账号登陆
Username:Admin
Password:zabbix

登录成功后 显示zabbix监控的网页
Monitoring system set up zabbix

更改语言设置 点击zabbix监控平台右上方的头像标识
在language选项中选择Chinese
Monitoring system set up zabbix

可以更换一个炫酷一点的主题 在刚才设置中文下面的选项中选择dark
Monitoring system set up zabbix

常见问题

下面这些问题是我个人这几天遇到的 希望能让你们少走弯路

提示安装php服务出错

Monitoring system set up zabbix

这个问题可能是yum仓库设置的时候有问题
两种解决方法

  • 检查设置yum仓库的命令是否正确

设置完yum源一定要repolist检查一下看看数据正不正常
理论上说 --add后面不加-repo也行 但是我就是不行 还是加上吧

[root@zabbix-server ~] yum-config-manager --add-repo file:///repo/cos7dvd/
  • 可能是软件依赖关系的问题
[root@zabbix-server ~] yum -y remove httpd-tools php-common mariadb-libs
[root@zabbix-server ~] yum -y install httpd mariadb mariadb-server php php-mysql
[root@zabbix-server ~] yum -y install postfix

安装zabbix-server包时出错

可能是linux的版本跟zabbix-server的版本不一致导致的
CentOS 7-1804版本的是9个包 16版本的包更多一点 需要下载对应的包

mysql -uroot登录数据库时报错ERROR2002

这个错误指令应该是数据库没启动
如果启动了还是这样的话 可能跟上面的问题原因一样
16版本的话安装不是mariadb包 应该是:mysql-community-server.x86_64

解决方法:

[root@zabbix-server ~] wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
[root@zabbix-server ~] yum localinstall mysql57-community-release-el7-8.noarch.rpm
[root@zabbix-server ~] yum repolist enabled |grep "mysql.*-community.*"
[root@zabbix-server ~] yum -y install mysql-community-server.x86_64 
[root@zabbix-server ~] systemctl start mysqld
[root@zabbix-server ~] systemctl status mysqld
[root@zabbix-server ~] systemctl enable mysqld

进入数据库设置密码时报错ERROR3009

由于曾经升级过数据库,升级完成后没有使用mysql_upgrade升级数据结构造成

解决方法:

[root@zabbix-server ~] mysql_upgrade -uroot

总结

The above problem is these cards for several days, slowly pondering, Baidu only solve these problems, I hope you can help to
build zabbix or necessary, many companies are using zabbix, operation and maintenance is an essential skill
generally easy is in the wrong place yum source version of this is also often petty problems are often easily overlooked
any cultural problems in the wrong place can comment or private letter to tell me

Guess you like

Origin blog.51cto.com/14309999/2406268