美文网首页
centos7安装zabbix3.0

centos7安装zabbix3.0

作者: Anwar_ec28 | 来源:发表于2018-10-16 11:59 被阅读0次

关闭防火墙,并设置成开机不自启

[root@localhost ~]# systemctl stop

firewalld.service

[root@localhost ~]# systemctl disable

firewalld.service

关闭selinux

临时关闭SELinux

[root@localhost ~]#setenforce 0

安装mysql5.7.11版本

上传mysql安装包 mysql57-community-release-el7-7.noarch.rpm

安装mysql

[root@localhost ~]# rpm -ivh

mysql57-community-release-el7-7.noarch.rpm

[root@localhost ~]# yum -y install

mysql-community-server

启动mysql,并将设置成开机自启。

[root@localhost ~]# systemctl start

mysqld.service

[root@localhost ~]# systemctl enable

mysqld.service

Mysql账号密码设置:

查找mysql的随机密码

[root@localhost ~]# cat /var/log/mysqld.log

| grep password

[if !vml]

[endif]

给mysql权限  chown -R mysql:mysql/var/lib/mysql

修改mysql初始密码

1、登录到mysql,设置安全级别

mysql> set global

validate_password_policy=0;

Query OK, 0 rows affected (0.00 sec)

2、设置密码长度。默认密码长度为8,可以设置为其它值,最小4位

mysql> set global

validate_password_length=4;

Query OK, 0 rows affected (0.00 sec)

修改mysql密码

mysql> set password =

password("123456");

Query OK, 0 rows affected, 1 warning (0.01

sec)

[if !vml]

[endif]

安装apache2

[root@localhost ~]# yum -y install httpd

开启apache2服务并设置成开机自启

[root@localhost ~]# systemctl start

httpd.service

[root@localhost ~]# systemctl enable

httpd.service

检查apache2的测试页面

在浏览器中输入  http://ip

[if !vml]

[endif]

补充说明: 

Apache默认文档根目录:/var/www/html,配置文

件:/etc/httpd/conf/httpd.conf,配置存储在/etc/httpd/conf.d/。

安装php5

[root@localhost ~]# yum -y install php

设置httpd端口

修改 ServerName localhost:80 

# vi /etc/httpd/conf/httpd.conf

重启httpd服务

[root@localhost ~]# systemctl restart

httpd.service

测试php

[root@localhost ~]# vi

/var/www/html/info.php

文件内容: 

<?php 

phpinfo() 

?>

查看PHP配置细节 

用浏览器访问例如http://IP地址/info.php

[if !vml]

[endif]

安装mysql相关的php模块

[root@localhost ~]# yum -y install

php-mysql php-gd php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc

php-bcmath

重启httpd服务

[root@localhost ~]# systemctl restart

httpd.service

检查php模块

重新打开http://IP地址/info.php页面,新增很多模块,包括MySQL模块:

[if !vml]

[endif]

安装phpMyAdmin

上传安装包  epel-release-latest-7.noarch.rpm

[root@localhost ~]# rpm -ivh

epel-release-latest-7.noarch.rpm

[root@localhost ~]# yum -y install

phpmyadmin

修改phpMyAdmin配置

phpMyAdmin默认安装目录: /usr/share/phpMyAdmin, 

在 Apache 的配置文件目录中自动创建虚拟主机配置文件 :/etc/httpd/conf.d/phpMyAdmin.conf 

# vi /etc/httpd/conf.d/phpMyAdmin.conf 修改其中的部分: 

[root@localhost ~]# vi

/etc/httpd/conf.d/phpMyAdmin.conf

[if !vml]

[endif]

重启httpd服务

[root@localhost ~]# systemctl restart

httpd.service

通过http://IP地址/phpMyAdmin访问

[if !vml]

[endif]

安装zabbix

[root@localhost ~]#                                 wgethttp://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm

[root@localhost ~]# rpm -ivh

zabbix-release-3.0-1.el7.noarch.rpm

[root@localhost ~]# yum -y install

zabbix-server-mysql zabbix-web-mysql

[root@localhost ~]# yum -y install zabbix-agent

配置zabbix数据库

[root@localhost ~]# 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 zabbix@localhost identified by 'zabbix';

Query OK, 0 rows affected, 1 warning (0.00

sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> quit

Bye

将zabbix导入数据库

[root@localhost ~]# cd

/usr/share/doc/zabbix-server-mysql-3.0.9/

[root@localhost zabbix-server-mysql-3.0.9]#

ls

AUTHORS ChangeLog  COPYING  create.sql.gz NEWS  README

[root@localhost zabbix-server-mysql-3.0.9]#

gzip -d create.sql.gz

[root@localhost zabbix-server-mysql-3.0.9]#

mysql -uzabbix -pzabbix zabbix

mysql> source create.sql;

mysql> quit

mysql -uzabbix -p zabbix < /usr/share/doc/zabbix-server-mysql-3.0.9/create.sql

[if !vml]

[endif]

启动zabbix服务

[root@localhost ~]# vi

/etc/zabbix/zabbix_server.conf

# DBHost=localhost

DBName=zabbix

DBUser=zabbix

DBPassword=zabbix

启动zabbix服务

[root@localhost ~]# systemctl start

zabbix-server

配置Zabbix.conf文件

#vi /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

重启http服务

[root@localhost ~]# systemctl restart

httpd.service

配置zabbix的web

在浏览器输入   http://192.168.252.20/zabbix

[if !vml]

[endif]

[if !vml]

[endif]

[if !vml]

[endif]

Mysql远程连接设置

将mysql设置成允许远程连接

[root@localhost ~]# mysql -uroot -p

mysql> use mysql;

mysql> update user set host='%' where

user='root';

Query OK, 1 row affected (0.00 sec)

Rows matched: 1  Changed: 1 Warnings: 0

mysql> update user set host='%' where

user='zabbix';

Query OK, 1 row affected (0.00 sec)

Rows matched: 1  Changed: 1 Warnings: 0

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

[if !supportLists]五、[endif]Zabbix之fping安装配置

yum -y install gcc gcc-c++

1.zabbix在监控主机存活状态时用的是fping指令,默认情况下fping软件是没有安装的。

下载-解压-安装

[root@zhu1 ~]# wget

http://www.fping.org/dist/fping-3.5.tar.gz

[root@zhu1 ~]# tar zxvf fping-3.5.tar.gz

root@zhu1 fping-3.5]# ./configure

--prefix=/opt/fping

[root@zhu1 fping-3.5]# make && make

install

修改配置文件

[root@zhu1 fping-3.5]# vi

/opt/zabbix/etc/zabbix_server.conf

FpingLocation=/usr/sbin/fping

3.修改fping指令的权限

[root@zhu1 ~]# chown root.zabbix /usr/sbin/fping

[root@zhu1 ~]# chmod 4710 /usr/sbin/fping

搭建邮件服务器

yum -y install postfix*

yum -y install mailx

更改postfix配置文件中的参数

# postconf -e

myhostname=mail.zabbix.example.cn

# postconf -e myorigin=zabbix.example.cn

# postconf -e mydomain=zabbix.example.cn

# postconf -e mydestination=localhost

# postconf -e mynetworks=127.0.0.0/8

vi /etc/postfix/main.cf

inet_interfaces = all  ← 接受来自所有网络的请求

mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

  ← 指定发给本地邮件的域名

home_mailbox = Maildir/

  ← 指定用户邮箱目录

<保存退出!>

# vi /etc/hosts

添加一行:

------------

127.0.0.1 mail.zabbix.example.cn

zabbix.example.cn

  echo127.0.0.1

mail.zabbix.example.cn zabbix.example.cn>> /etc/hosts

 

重启postfix服务

# service postfix restart

测试发送一封邮件到公网邮箱

# mail abc@example.com

动态查看发送的邮件日志

# tail -f /var/log/maillog

若远程邮箱收到,则配置成功

相关文章

网友评论

      本文标题:centos7安装zabbix3.0

      本文链接:https://www.haomeiwen.com/subject/dqthzftx.html