Zabbix学习笔记第贰篇,YUM联网安装

By admin in 美高梅手机版4858 on 2019年4月26日

软件条件

软件条件

前言

因为三个运转项目关心了瞬间开源监察和控制软件,比较了Nagios、Zabbix、Zenoss、Cacti、Ganglia等,最后选项了Zabbix,首假设因为Zabbix流行(研讨商讨的人多,文书档案多)、功效齐全(涵盖了监察和控制数据采集和可视化、至极报告警察方、与其他系统协同职业等功效)。

OS准备

Centos7.3

Centos7.3

安排采纳的读书方法

1、读书
二、看摄像教程
三、施行,边学边干
4、发生难题,寻求援助,化解难题

关闭selinux

LAMP

LAMP

上学笔记

vi /etc/selinux/config

Zabbix 3.2

Zabbix 3.2

实行笔记

setenforce 0

 1. Installing repository configuration
package

 1. Installing repository configuration
package

1、安装Zabbix

其一试验是二零一八年1月十10日开班的,官网的版本是三.四,如下图所示:

美高梅手机版4858 1

二零一八年5月四日Zabbix网址截图

CentOS 七 最小化安装,禁止使用Firewall和SeLinux,安装Apache、MySQL、PHP。
CentOS官网下载的“CentOS-7-x八六_6四-伊芙rything-170八.iso”安装镜像文件。

立异系统到最新版本

root@zabbix# yum update

查看系统版本(二〇一八年六月三日)

root@zabbix# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)

翻看内核版本(二零一八年二月5日)

root@zabbix# cat /proc/version
Linux version 3.10.0-693.el7.x86_64
(builder@kbuilder.dev.centos.org)
(gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) ) #1 SMP Tue Aug
22 21:09:27 UTC 2017

总是记不住vi编辑器的那多少个命令,所以先安装二个nano编辑器备用

root@zabbix# yum install nano

设置Apache服务器,开启Web访问服务,设置Apache开机运维。

root@zabbix# yum install httpd
root@zabbix# systemctl start httpd
root@zabbix# systemctl enable httpd.service

增添防火墙规则,允许HTTP和HTTPS协议,重新载入防火墙规则。

root@zabbix# firewall-cmd –permanent –zone=public
–add-service=http
success
root@zabbix# firewall-cmd –permanent –zone=public
–add-service=https
success
root@zabbix# firewall-cmd –reload
success

关闭SeLinux(修改完/etc/selinux/config文件,记得重新起动壹回CentOS)

root@zabbix# nano /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@zabbix# reboot -h now

美高梅手机版4858 2

Apache寻常办事

首先检查 MySQL 是还是不是已设置

root@zabbix# yum list installed | grep mysql

安装 MySQL 并绽放防火墙端口。

root@zabbix# rpm -Uvh
‘https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm’
root@zabbix#Zabbix学习笔记第贰篇,YUM联网安装。 yum repolist all | grep mysql
root@zabbix# yum install mysql-community-server
root@zabbix# systemctl start mysqld
root@zabbix# systemctl status mysqld
root@zabbix# firewall-cmd –permanent –zone=public
–add-port=3306/tcp
root@zabbix# firewall-cmd –permanent –zone=public
–add-port=3306/udp
root@zabbix# firewall-cmd –reload

为了抓牢安全性,MySQL
5.7为root用户自由生成了三个密码,在”error_log“文件中,默许是在
/var/log/mysqld.log。使用随机变化密码登入,然后改成密码。
MySQL
伍.柒版本暗中同意的密码计谋是:密码要含有数字、小写字母、大写字母、特殊字符且长度至少5人

root@zabbix# cat /var/log/mysqld.log | grep password
2018-02-02T01:22:10.814000Z 1 [Note] A temporary password is
generated for root@localhost: cnofwNLxj8.m
root@zabbix# mysql -u root -p’cnofwNLxj8.m’
mysql> SET PASSWORD = PASSWORD(‘XXXXXXXX’);
Query OK, 0 rows affected, 1 warning (0.00 sec)

设置PHP的伍.6版本,因为Zabbix集成的是五.X版本(安装过7.二版的PHP,结果在Zabbix
frontend的检查时,繁多模块都是off,搞了深入也没消除,绕路躲过)

root@zabbix# rpm -Uvh
https://mirror.webtatic.com/yum/el7/epel-release.rpm
root@zabbix# rpm -Uvh
https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
root@zabbix# yum install php56w.x86_64 php56w-cli.x86_64
php56w-common.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64
php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64
php56w-pdo.x86_64

美高梅手机版4858 3

PHP当下流行版

安装php-fpm

root@zabbix# yum install php56w-fpm

肯定一下PHP的本子,重启Apache

root@zabbix# php -v
PHP 5.6.33 (cli) (built: Jan 14 2018 08:07:11)
root@zabbix# systemctl restart httpd.service

编写“/var/www/html/index.php”,写入内容,浏览器张开PHP消息页面,验证安装是或不是准确

root@zabbix# nano /var/www/html/index.php
<?php
phpinfo();
?>

美高梅手机版4858 4

Web页面展现PHP音信

下载安装Zabbix的包音讯文件,安装Zabbix server,Zabbix frontend,Zabbix
agent。

root@zabbix# rpm -Uvh
‘http://repo.zabbix.com/zabbix/3.4/rhel/7/x86\_64/zabbix-release-3.4-2.el7.noarch.rpm’
root@zabbix# yum install zabbix-server-mysql zabbix-web-mysql
zabbix-agent

以root角色登录MySQL,创立zabbix数据库,用户名是”zabbix“,密码仍然要含有数字、小写字母、大写字母、特殊字符且长度至少8人。

root@zabbix# mysql -uroot -p
mysql> create database zabbix character set utf8 collate
utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost
identified by ‘XXXXXXXX’;
mysql> quit

依靠提醒输入root用户的密码,将Zabbix服务器的开头化数据导入到zabbix数据库中

root@zabbix# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz
| mysql -uroot -p zabbix

修改Zabbix server的计划文件”zabbix_server.conf“

root@zabbix# nano /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=password

运维”zabbix-server“和”zabbix-agent“服务并且将劳动设为开机自动运转

root@zabbix# systemctl start zabbix-server zabbix-agent
root@zabbix# systemctl enable zabbix-server zabbix-agent

修改“/etc/httpd/conf.d/zabbix.conf”文件,配置Zabbix frontend的PHP设置
注意:去掉“php_value
date.timezone”字段前边的“#”,将值改为“Asia/Shanghai”

root@zabbix# nano /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

给Zabbix Server和Zabbix Agent开放防火墙端口

root@zabbix# firewall-cmd –permanent –zone=public
–add-port=10050/tcp
root@zabbix# firewall-cmd –permanent –zone=public
–add-port=10050/udp
root@zabbix# firewall-cmd –permanent –zone=public
–add-port=10051/tcp
root@zabbix# firewall-cmd –permanent –zone=public
–add-port=10051/udp
root@zabbix# firewall-cmd –reload

好了,Zabbix Server就绪了。上边发轫配备Zabbix
frontend:在浏览器地址栏输入“http://ip\_address/zabbix”

美高梅手机版4858 5

Zabbix接待分界面

美高梅手机版4858 6

Zabbix配置页面开掘错误

编排“/etc/php.ini”文件,修改“date.timezone =
Asia/Shanghai”后,重启Apache,难点消除。

root@zabbix# nano /etc/php.ini

[Date]
; Defines the default timezone used by the date functions
;
http://php.net/date.timezone
date.timezone = Asia/Shanghai

root@zabbix# systemctl restart httpd

美高梅手机版4858 7

Zabbix配置OK

遵守页面中的配置向导,一步一步实施,就要落成。

美高梅手机版4858 8

Zabbix配置就要完毕

美高梅手机版4858 9

Zabbix配置实现

美高梅手机版4858 10

Zabbix初次登录

Zabbix
frontend安装落成后,系统自动生成“/etc/zabbix/web/zabbix.conf.php”文件。用浏览器张开:http://X.X.X.X/zabbix,暗中认可用户名和密码:Admin/zabbix。第二遍中标登入后纪念修改密码。

开启防火墙80端口访问

Install the repository configuration
package. This package contains yum (software package manager)
configuration files.

Install the repository configuration
package. This package contains yum (software package manager)
configuration files.

firewall-cmd –permanent –add-rich-rule ‘rule family=ipv4 port port=80
protocol=tcp accept’

# rpm -ivh

# rpm -ivh

firewall-cmd –reload

Now you are ready to install Zabbix
server with
MySQL
or server with
PostreSQL,
agent
and
proxy.

Now you are ready to install Zabbix
server with
MySQL
or server with
PostreSQL,
agent
and
proxy.

联网安装REPO源

2. Installing apache and php

2. Installing apache and php

rpm -ivh

[root@localhost ~]# yum -y install httpd php
php-mysql php-mbstring php-gd php-bcmath php-ldap php-xml

[root@localhost ~]# yum -y install httpd php
php-mysql php-mbstring php-gd php-bcmath php-ldap php-xml

yum安装前端筹划

 2.1 配备php时区参数

 2.1 布署php时区参数

安装apache,php,java,mysql

(a) php.ini

(a) php.ini

yum clean all

(b)
/etc/httpd/conf.d/zabbix.conf

(b)
/etc/httpd/conf.d/zabbix.conf

yum list

 
 php_value date.timezone Asia/Shanghai

 
 php_value date.timezone Asia/Shanghai

yum grouplist

2.2 启动web服务

2.2 启动web服务

yum groupinstall “Web Server” “PHP Support” “MySQL Database server”
“MySQL Database client” “Java Platform”

[root@localhost
~]# systemctl start httpd.service

[root@localhost
~]# systemctl start httpd.service

设置增加包

#
systemctl enable httpd.service
 

#
systemctl enable httpd.service
 

yum install gcc mysql-devel php-mbstring php-bcmath php-mysql OpenIPMI
OpenIPMI-devel libcurl libcurl-devel libxml2 libxml2-devel net-snmp
net-snmp-devel

3. **Installing mariadb  **

3. **Installing mariadb  **

yum install fping

# yum -y install mariadb mariadb-server

# yum -y install mariadb mariadb-server

安装zabbix组件

# systemctl start mariadb.service

# systemctl start mariadb.service

yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent

# systemctl enable mariadb.service 

# systemctl enable mariadb.service 

数据库安装配备

4. Installing Zabbix server and web
packages

4. Installing Zabbix server and web
packages

yum install mariadb-server mariadb -y

# yum -y install zabbix-server-mysql
zabbix-web-mysql  zabbix-agent

# yum -y install zabbix-server-mysql
zabbix-web-mysql  zabbix-agent

安顿创制数据库

4.1 Creating initial mariadb database 

4.1 Creating initial mariadb database 

布署数据库密码

# mysql_secure_installation

# mysql_secure_installation

mysqladmin -uroot password <newpassword>

# mysql -u root -p <root_password>

# mysql -u root -p <root_password>

# mysql -uroot -p

mysql> create database zabbix character set utf8 collate utf8_bin;

mysql> create database zabbix character set utf8 collate utf8_bin;

password

mysql> create user ‘zabbix’@’localhost’ identified by
‘zabbix_password’;

mysql> create user ‘zabbix’@’localhost’ identified by
‘zabbix_password’;

mysql> create database zabbix character set utf8 collate utf8_bin;

mysql> create user ‘zabbix’@’192.168.1.%’ identified by
‘zabbix_password’;

mysql> create user ‘zabbix’@’192.168.1.%’ identified by
‘zabbix_password’;

mysql> grant all privileges on zabbix.* to zabbix@localhost
identified by ‘password’;

mysql> grant all on zabbix.* to ‘zabbix’@‘localhost’;

mysql> grant all on zabbix.* to ‘zabbix’@‘localhost’;

mysql> quit;

mysql> grant all on zabbix.* to ’zabbix‘@‘192.168.1.%’;
mysql> quit 

mysql> grant all on zabbix.* to ’zabbix‘@‘192.168.1.%’;
mysql> quit 

数据库导入

4.2 Now import initial schema and data. Make sure to insert correct
version for 3.2.*. You will be prompted to enter your newly created
password.  

4.2 Now import initial schema and data. Make sure to insert correct
version for 3.2.*. You will be prompted to enter your newly created
password.  

# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql
-uzabbix -p zabbix

In order to check the version you have in your package, use the
following command:  

In order to check the version you have in your package, use the
following command:  

配置Zabbix server的数据库

# rpm -q zabbix-server-mysql  

# rpm -q zabbix-server-mysql  

vi /etc/zabbix/zabbix_server.conf

# zcat /usr/share/doc/zabbix-server-mysql-3.2.*/create.sql.gz | mysql
-u zabbix -p -D zabbix  

# zcat /usr/share/doc/zabbix-server-mysql-3.2.*/create.sql.gz | mysql
-u zabbix -p -D zabbix  

DBPassword=password

5. Database configuration for Zabbix
server

5. Database configuration for Zabbix
server

配置ZABBIX前端

Edit server host name, user and password
in zabbix_server.conf as follows, where DBPassword is the password
you’ve set creating initial database:

Edit server host name, user and password
in zabbix_server.conf as follows, where DBPassword is the password
you’ve set creating initial database:

vi /etc/httpd/conf.d/zabbix.conf,

# vi
/etc/zabbix/zabbix_server.conf
DBHost=localhost ##database host
name
DBName=zabbix ##database name
DBUser=zabbix   ##database user
name
DBPassword=<zabbix_password>
  ##database user password

# vi
/etc/zabbix/zabbix_server.conf
DBHost=localhost ##database host
name
DBName=zabbix ##database name
DBUser=zabbix   ##database user
name
DBPassword=<zabbix_password>
  ##database user password

# ZABBIX

5.1Starting Zabbix server 

5.1Starting Zabbix server 

<VirtualHost *:80>

It’s time to start Zabbix server process
and make it start at system boot:

It’s time to start Zabbix server process
and make it start at system boot:

   ServerName zbserver

# systemctl start zabbix-server
# systemctl enable
zabbix-server   

# systemctl start zabbix-server
# systemctl enable
zabbix-server   

   ServerAdmin root@localhost

5.2 PHP configuration for Zabbix web

5.2 PHP configuration for Zabbix web

   DocumentRoot /usr/share/zabbix

Apache configuration file for Zabbix
frontend is located in /etc/httpd/conf.d/zabbix.conf.
Some PHP settings are already configured.

Apache configuration file for Zabbix
frontend is located in /etc/httpd/conf.d/zabbix.conf.
Some PHP settings are already configured.

Alias /zabbix /usr/share/zabbix

But it’s necessary to uncomment the
“date.timezone” setting and set the right timezone for you.

But it’s necessary to uncomment the
“date.timezone” setting and set the right timezone for you.

<Directory “/usr/share/zabbix”>

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
Europe/Riga   

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
Europe/Riga   

Options FollowSymLinks

5.3 SELinux configuration

5.3 SELinux configuration

AllowOverride None

Having SELinux status enabled in enforcing
mode, you need to execute the following command to enable successful
connection of Zabbix frontend to the server:

Having SELinux status enabled in enforcing
mode, you need to execute the following command to enable successful
connection of Zabbix frontend to the server:

Require all granted

# setsebool -p
httpd_can_美高梅手机版4858 ,network_connect on

# setsebool -p
httpd_can_network_connect on

<IfModule mod_php5.c>

# setsebol -p http_can_connect_zabbix
on

# setsebol -p http_can_connect_zabbix
on

php_value max_execution_time 300

# setsebool -p -p zabbix_can_network
on

# setsebool -p -p zabbix_can_network
on

php_value memory_limit 128M

5.4 Firwall configuration

5.4 Firwall configuration

php_value post_max_size 16M

#f irewall-cmd –permanent
–add-port=80/tcp

#f irewall-cmd –permanent
–add-port=80/tcp

php_value upload_max_filesize 2M

# firewall-cmd –permanent
–add-port=443/tcp

# firewall-cmd –permanent
–add-port=443/tcp

php_value max_input_time 300

# firewall-cmd –permanent
–add-port=10050-10052/tcp

# firewall-cmd –permanent
–add-port=10050-10052/tcp

php_value always_populate_raw_post_data -1

# firewall-cmd  –reload 

# firewall-cmd  –reload 

php_value date.timezone Aisa/Shanghai

As frontend and SELinux configuration is
done, you need to restart Apache web server:

As frontend and SELinux configuration is
done, you need to restart Apache web server:

</IfModule>

# systemctl restart httpd

# systemctl restart httpd

</Directory>

# systemctl restart zabbix-server

# systemctl restart zabbix-server

<Directory “/usr/share/zabbix/conf”>

# systemctl restart
zabbix-agent 

# systemctl restart
zabbix-agent 

Require all denied

5.5 Installing and configuration
Zabbix-web

5.5 Installing and configuration
Zabbix-web

</Directory>

webUI site:

webUI site:

<Directory “/usr/share/zabbix/app”>

username:Admin

username:Admin

Require all denied

password: zabbix

password: zabbix

</Directory>

Zabbix web configuration file

Zabbix web configuration file

<Directory “/usr/share/zabbix/include”>

# cat /etc/zabbix/web/zabbix.config.php
   

# cat /etc/zabbix/web/zabbix.config.php
   

Require all denied

</Directory>

<Directory “/usr/share/zabbix/local”>

Require all denied

</Directory>

   ErrorLog /var/log/httpd/zabbix/error.log

   # Possible values include: debug, info, notice, warn, error, crit,

   # alert, emerg.

   LogLevel warn

   CustomLog /var/log/httpd/zabbix/access.log combined

   ServerSignature On

</VirtualHost>

积谷防饥日志文件夹

mkdir /var/log/httpd/zabbix/

touch /var/log/httpd/zabbix/error.log

touch /var/log/httpd/zabbix/access.log

启航进程

systemctl enable mariadb zabbix-server zabbix-agent httpd

systemctl restart mariadb zabbix-server zabbix-agent httpd

布置前端

配备进程参考Installing
frontend

难题处理

图片呈现乱码

端口监察和控制

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图
Copyright @ 2010-2019 美高梅手机版4858 版权所有