CentOS7安装Zabbi4.4和mysql5.7


文章目录

  • 安装mysql-5.7
  • 安装zabbix-4.4
  • 配置zabbix前端

1. 安装 mysql-5.7

  1. 由于 centos 的源中没有mysql ,需要下载安装配置文件
##下载文件
# wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
##安装文件
# rpm -ivh mysql57-community-release-el7-9.noarch.rpm
  1. 安装完毕后修改源文件
##修改配置文件
## 可以使用nano vim vi 这里我是用的nano 没有的话可以执行 yum install nano 安装
# nano /etc/yum.repos.d/mysql-community.repo
  GNU nano 2.3.1                                      文件: /etc/yum.repos.d/mysql-community.repo                                                                                  

[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-connectors-community-el7-$basearch/
enabled=1
gpgcheck=1
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql

[mysql-tools-community]
name=MySQL Tools Community
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-tools-community-el7-$basearch/
enabled=1
gpgcheck=1
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql

[mysql-5.7-community]
name=MySQL 5.7 Community Server
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-$basearch/
enabled=1
gpgcheck=1
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql
                                                                                  [ 已读取21 行 ]
^G 求助                       ^O 写入                       ^R 读档                       ^Y 上页                       ^K 剪切文字                   ^C 游标位置
^X 离开                       ^J 对齐                       ^W 搜索                       ^V 下页                       ^U 还原剪切                   ^T 拼写检查

  1. 安装启动服务
##保存后更新
# yum update
##安装mysql
# yum -y install mysql-community-server
##启动服务
# systemctl start mysqld
##添加开机启动
# systemctl enable  mysqld
  1. 配置 mysql 数据库
## 数据库初始化
# mysqld --initialize --user=mysql
## 查看初始化密码grep 'temporary password' /var/log/mysqld.log
## 最后面的就是你的初始密码.我的是 vhld2:H;tRp*
2020-04-30T10:39:46.770531Z 1 [Note] A temporary password is generated for root@localhost: vhld2:H;tRp*
## 安装数据库
# mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root:         ##输入你的初始密码

The existing password for the user account root has expired. Please set a new password.

New password:      ##输入你的新密码

Re-enter new password:  ##再输入一遍新密码

VALIDATE PASSWORD PLUGIN can be used to test passwords ##验证密码插件可用于测试密码
and improve security. It checks the strength of password ##提高安全性。它检查密码的强度
and allows the users to set only those passwords which are ##并允许用户只设置
secure enough. Would you like to setup VALIDATE PASSWORD plugin? ##足够安全。是否要设置验证密码插件?

Press y|Y for Yes, any other key for No: n   ## 此处我不需要所以输入n
Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y #问你需不需要更改密码,我这里选的y

New password:  ##你的新密码

Re-enter new password: ##再输一遍
By default, a MySQL installation has an anonymous user, ##默认情况下,MySQL安装有一个匿名用户,
allowing anyone to log into MySQL 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.
##允许任何人登录MySQL而不必为他们创建的用户帐户。这只是为了测试,使安装更顺利。你应该在投入生产前把它们去掉环境。

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y ## 选择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? (Press y|Y for Yes, any other key for No) : n 

 ... skipping.
By default, MySQL 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.
##默认情况下,MySQL附带一个名为“test”的数据库任何人都可以进入。这也只是为了测试,在投入生产之前应该移除环境。

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : y ##重新加载特权
Success.

All done! 

注:至此 mysql 数据库配置完成,根据自己的情况选择,这个只是参考

2. 安装zabbix-4.4

参考官网配置 
https://www.zabbix.com/cn/download

  1. 安装zabbix包
## 个人切换为中国源
# rpm -Uvh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
## 依然切换为中国源
# nano /etc/yum.repos.d/zabbix.repo
  GNU nano 2.3.1                                      文件: /etc/yum.repos.d/zabbix.repo                                                                                  

[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.4/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

[zabbix-debuginfo]
name=Zabbix Official Repository debuginfo - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.4/rhel/7/$basearch/debuginfo/
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
gpgcheck=1

[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
                                                                                  [ 已读取21 行 ]
^G 求助                       ^O 写入                       ^R 读档                       ^Y 上页                       ^K 剪切文字                   ^C 游标位置
^X 离开                       ^J 对齐                       ^W 搜索                       ^V 下页                       ^U 还原剪切                   ^T 拼写检查

  1. 安装Zabbix server,Web前端,agent
# yum clean all 
# yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent
  1. 创建初始数据库
# mysql -uroot -p

Enter password:  ##输入你数据库密码
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.7.30 MySQL Community Server (GPL)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
## 创建数据库并设置编码
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.05 sec)
## 设置zabbix登录密码.默认账户Admin
mysql>  grant all privileges on zabbix.* to zabbix@localhost identified by '替换为自己的zabbix的密码';
Query OK, 0 rows affected, 1 warning (0.02 sec)

mysql> exit ##退出数据库
Bye

  1. 导入初始架构和数据,系统将提示你输入密码
# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Enter password:  ## 输入你设置的zabbix的密码
  1. 为zabbix配置数据库
##编辑配置文件 
# nano /etc/zabbix/zabbix_server.conf
## 找到DBPassword=取消注释 修改为DBPassword=password
  1. 为zabbix配置前端
##编辑配置文件 
# nano /etc/httpd/conf.d/zabbix.conf
##修改php_value date.timezone Asia/ShangHai     ##这里修改的是时区
  1. 启动Zabbix server和agent进程,并为它们设置开机自启:
# systemctl restart zabbix-server zabbix-agent httpd
# systemctl enable zabbix-server zabbix-agent httpd

注:关闭防火墙不然不能访问:个人学习为了简单关闭掉就好
防火墙设置

启动:service firewalld start
查看状态:service firewalld status
停止: service firewalld disable
禁用:service firewalld stop
重启:service firewalld restart
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值