centos7.4记录zabbix安装步骤(没有及时记录,注意安装的版本)

1、安装zabbix-release包

[root@linux-node1 ~]# mkdir -p /home/lxy/tools

[root@linux-node1 ~]# cd /home/lxy/tools/

[root@linux-node1 tools]# wget -q http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm

[root@linux-node1 tools]# rpm -ivh zabbix-release-2.4-1.el6.noarch.rpm

warning: zabbix-release-2.4-1.el6.noarch.rpm: Header V4 DSA/SHA1 Signature, key ID 79ea5ed4: NOKEY

Preparing… ########################################### [100%]

1:zabbix-release ########################################### [100%]

[root@linux-node1 tools]# rpm -ql zabbix-release

/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX

/etc/yum.repos.d/zabbix.repo

/usr/share/doc/zabbix-release-2.4

/usr/share/doc/zabbix-release-2.4/GPL

[root@linux-node1 tools]# ll /etc/yum.repos.d/zabbix.repo

-rw-r–r-- 1 root root 401 9月 11 2014 /etc/yum.repos.d/zabbix.repo

2.开始安装zabbix

1)保留yum安装的rpm包

[root@linux-node1 tools]# sed -i ‘s#keepcache=1#keepcache=0#g’ /etc/yum.conf

[root@linux-node1 tools]# grep keepcache /etc/yum.conf

keepcache=0

2)开始安装zabbix

yum -y install zabbix zabbix-server zabbix-server-mysql #<==ZABBIX SERVER相关

yum -y install zabbix-web zabbix-web-mysql #<==Apache、Php Web界面环境

yum -y install zabbix-agent #<== ZABBIX客户端

yum -y install mysql-server mysql #<==MySQL客户端与服务端

3、配置zabbix服务相关

1)配置mysql

[root@linux-node1 tools]# \cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
//数据库改名字了用下面这个
[root@linux-node1 tools]# \cp /usr/share/mariadb/my-medium.cnf /etc/my.cnf

[root@linux-node1 tools]# vim /etc/my.cnf

在[mysqld](第26行)标签下增加如下三行后保存

[mysqld]

character-set-server = utf8
init-connect = ‘SET NAMES utf8’
collation-server = utf8_general_ci

注意新版
mariabd数据库启动
systemctl start mariadb
systemctl enable mariadb
[root@node1 ~]# yum install -y mariadb mariadb-server
[root@node1 ~]# systemctl start mariadb
[root@node1 ~]# systemctl enable mariadb
##安装完成后安全初始化,添加root密码,删除匿名登录账户,禁止远程使用root用户登录,删除测试数据库和使用##
[root@node1 ~]# mysql_secure_installation

[root@linux-node1 tools]# /etc/init.d/mysqld start

2)初始化数据库环境

创建数据库
重新安装了数据库:

mysql> create database zabbix character set utf8 collate utf8_bin;

Query OK, 1 row affected (0.00 sec)

授权数据库

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

Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;

导入表结构

[root@linux-node1 tools]# cd /usr/share/doc/zabbix-server-mysql-2.4.8/create/
注意版本号:2.4.8

开始导入数据库:
[root@linux-node1 create]# mysql -u root -p zabbix < schema.sql

[root@linux-node1 create]# mysql -u root -p zabbix < images.sql

[root@linux-node1 create]# mysql -u root -p zabbix < data.sql

[root@linux-node1 create]# mysqladmin -uroot password 123456
我这边没有修改成功;

3)设置apache时区

sed -i ‘s## php_value date.timezone Europe/Riga#php_value date.timezone Asia/Shanghai#g’ /etc/httpd/conf.d/zabbix.conf

grep Shanghai /etc/httpd/conf.d/zabbix.conf

php_value date.timezone Asia/Shanghai

4)更改zabbix server配置

[root@linux-node1 ~]# cp /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.bak

[root@linux-node1 ~]# sed -i ‘s@# DBPassword=@DBPassword=zabbix@g’ /etc/zabbix/zabbix_server.conf

[root@linux-node1 ~]# sed -i ‘s@# DBHost=localhost@DBHost=localhost@g’ /etc/zabbix/zabbix_server.conf


vim /etc/zabbix/zabbix_server.conf

LogFile=/var/log/zabbix/zabbix_server.log

DBHost=localhost

DBName=zabbix

DBUser=zabbix

DBPassword=zabbix

5)启动相关服务
7.0
systemctl restart zabbix-server

cannot create PID file [/var/run/zabbix/zabbix_server.pid]: [2] No such file or directory
chown zabbix.zabbix /var/run/zabbix/

解决花了好久
[root@elkstack ~]# mkdir -p /var/run/zabbix/
[root@elkstack ~]# chown zabbix.zabbix /var/run/zabbix/
[root@elkstack ~]# systemctl restart zabbix-agent.service

再重启systemctl restart zabbix-server

systemctl start httpd.service
启动http

systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
systemctl status firewalld.service #查看firewall的状态

[root@linux-node1 ~]# /etc/init.d/zabbix-server start

Starting Zabbix server: [确定]

[root@linux-node1 ~]# /etc/init.d/httpd start

正在启动 httpd: [确定]

[root@linux-node1 ~]# lsof -i:10051|wc -l

55

[root@linux-node1 ~]# lsof -i:80|wc -l

1
客户端安装和重启
得找到相对于的版本
rpm -Uvh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
yum install zabbix-agent –y

systemctl restart zabbix-agent.service

字体目录/usr/share/zabbix/

有时候会在zabbix下创建脚本,自定义监控项,在zabbix server上创建监控项前可以先使用zabbix_get来判断脚本是否正确。
在zabbix server端使用yum安装zabbix_get
配置yum源
rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
7.noarch.rpm
yum install zabbix-get.x86_64
可以使用zabbix_get -help查看用法
例如:zabbix_get -s 127.0.0.1 -p 10050 -k “system.cpu.load[all,avg1]”
其中zabbix agent自带有一个对mysql的监控,比如查看mysql的版本,对应的key是mysql.version,可以使用zabbix_get来验证mysql.version这个key是否可用(前提是客户端安装了mysql)
[root@s188 /etc/zabbix/zabbix_agentd.d]#zabbix_get -s 10.1.12.188 -p 10050 -k “mysql.version”
mysql Ver 14.14 Distrib 5.6.40, for Linux (x86_64) using EditLine wrapper

你可能感兴趣的:(linux,kail,linux学习)