centos7yum安装zabbix
一、准备搭建环境:
1、系统:CentOS7
2、默认有使用linux服务器的基础,会使用一些简单的命令和vim等命令。
二、安装过程:
一、首先查看SELinux状态
[root@localhost ~]# getenforce
Enforcing
三、关闭SELinux
1、修改SELinux状态,这个修改是重启后永久生效
[root@localhost ~]# vim /etc/selinux/config
在文件中可以看到这一行
SELINUX=enforcing
把后面的参数修改为disabled
SELinux=disabled
-----------------分割线,下面说下这三个参数什么作用-------------------------
1)、enforcing:开启防火墙
2)、permissive:关闭防火墙,但是会产生相应的日志
3)、disabled:彻底关闭防火墙,没日志产生
-----------------下面回归正题----------------------------------------------------------
2、现在在不关机情况下关闭SElinux,这个在重启之后会失效,但是当前有效
[root@localhost ~]# setenforce 0
四、关闭防火墙
4、永久关闭防火墙
[root@localhost ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.se
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.servic
5、当前环境关闭防火墙
[root@localhost ~]# systemctl stop firewalld.service
五、安装数据库
1、安装MariaDB数据库
[root@localhost ~]# yum -y install mariadb-server mariadb-devel
----------------------分割线,下面讲下MariaDB和MySQL的渊源--------------------
MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可。开发这个分支的原因之一是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方式来避开这个风险。 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。在存储引擎方面,10.0.9版起使用XtraDB(名称代号为Aria(英语:Aria (storage engine)))来代替MySQL的InnoDB。 MariaDB由MySQL的创始人麦克尔·维德纽斯(英语:Michael Widenius)主导开发,他早前曾以10亿美元的价格,将自己创建的公司MySQL AB卖给了SUN,此后,随着SUN被甲骨文收购,MySQL的所有权也落入Oracle的手中。MariaDB名称来自麦克尔·维德纽斯的女儿玛丽亚(英语:Maria)的名字。
PS:mariadb-devel是开发的头文件和静态库。
参考链接:
https://mariadb.com/kb/zh-cn/about-the-mariadb-rpm-files/
http://www.bing.com/knows/search?q=mariaDB&mkt=zh-cn
----------------------下面回归正题-----------------------------------------------------
2、开启MariaDB数据库[root@localhost ~]# systemctl start mariadb.service
3、查看MariaDB数据库在进程的状态
[root@localhost ~]# ss -tulnp | grep mysqld
tcp LISTEN 0 50 :3306 :*
----------------------关于ss命令,请查看以下链接--------------------------------------
ss命令可以用来获取socket统计信息,它可以显示和netstat类似的内容。但ss的优势在于它能够显示更多更详细的有关TCP和连接状态的信息,而且比netstat更快速更高效。
ss参数解释:
-t, --tcp 仅显示 TCP套接字(sockets)
-u, --udp 仅显示 UCP套接字(sockets)
-l, --listening 显示监听状态的套接字(sockets)
-n:把服务名称显示成端口号
-p, --processes 显示使用套接字(socket)的进程
更详细的命令介绍可以使用man来查看系统内的文档或者查看下面这个链接:
http://www.cnblogs.com/peida/archive/2013/03/11/2953420.html
----------------------下面回归正题------------------------------------------------------------
六、配置数据库
[root@localhost ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.52-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit
Bye
---------------------------说一下命令意思------------------------------------------------------
[root@localhost ~]# mysql
首次直接进入mysql数据库
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
create database zabbix是创建zabbix数据库
charcater set utf8是把默认字符集设置为utf8
collate utf8_bin是数据库校对规则
参考链接:
http://www.cnblogs.com/thinksasa/archive/2013/01/11/2856228.html
---------------------------下面回归正题---------------------------------------------------------
七、安装zabbix
1、获取并安装zabbix的yum源
[root@localhost ~]#wget http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
[root@localhost ~]#rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
2、生成yum源快照,这样可以直接用tab键来补全安装。
yum makecache
3、查看文件:
[root@localhost ~]# yum search zabbix
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
base: ftp.sjtu.edu.cn
extras: ftp.sjtu.edu.cn
updates: ftp.sjtu.edu.cn
========================================================= N/S matched: zabbix ===================================
pcp-export-zabbix-agent.x86_64 : Module for exporting PCP metrics to Zabbix agent
zabbix-agent.x86_64 : Zabbix Agent
zabbix-get.x86_64 : Zabbix Get
zabbix-java-gateway.x86_64 : Zabbix java gateway
zabbix-proxy-mysql.x86_64 : Zabbix proxy for MySQL or MariaDB database
zabbix-proxy-pgsql.x86_64 : Zabbix proxy for PostgreSQL database
zabbix-proxy-sqlite3.x86_64 : Zabbix proxy for SQLite3 database
zabbix-release.noarch : Zabbix repository configuration
zabbix-sender.x86_64 : Zabbix Sender
zabbix-server-mysql.x86_64 : Zabbix server for MySQL or MariaDB database
zabbix-server-pgsql.x86_64 : Zabbix server for PostgresSQL database
zabbix-web.noarch : Zabbix web frontend common package
zabbix-web-mysql.noarch : Zabbix web frontend for MySQL
zabbix-web-pgsql.noarch : Zabbix web frontend for PostgreSQL
zabbix-web-japanese.noarch : Japanese font settings for frontend
Name and summary matches only, use "search all" for everything.