码迷,mamicode.com
首页 > 其他好文 > 详细

2019.10.31 Zabbix环境初始化及添加监控主机

时间:2019-11-02 10:11:11      阅读:87      评论:0      收藏:0      [点我收藏+]

标签:用户   mamicode   Fix   with   bak   curl   jdk   firewall   memory   

一、实验环境准备

Centos:192.168.200.111    server.zabbix.com

Centos:192.168.200.112    agent.zabbix.com

Windows10:192.168.200.110    windows10

111:

hostname server.zabbix.com

bash

vim /etc/hostname中添加:

server.zabbix.com

vim /etc/hosts中添加:

192.168.200.111 server.zabbix.com
192.168.200.112 agent.zabbix.com
192.168.200.110 windows10

scp /etc/hosts 192.168.200.112:/etc

112:

hostname agent.zabbix.com

bash

vim /etc/sysconfig/network中添加:

HOSTNAME=agent.zabbix.com

保证第一台主机能够上网:ping www.baidu.com

两台虚拟机都关闭防火墙及安全机制:

systemctl stop firewalld
setenforce 0
iptables -F

二、Server端

1、配置阿里云yum源

cd /etc/yum.repos.d/
wget http://mirrors.aliyun.com/repo/Centos-7.repo

[root@server yum.repos.d]# ls
a Centos-7.repo CentOS-Media.repo

 yum -y install httpd mariadb-server mariadb mariadb-devel php php-mbstring php-mysql php-bcmath php-gd php-xmlrpc php-ldap php-xml libevent libevent-devel net-snmp net-snmp-devel libxml2 libxml2-devel ntpdate(共19个软件包)

 ntpdate s1a.time.edu.cn               /同步时间  清华大学时间服务器

2、启动LAMP对应服务

cd
systemctl start mariadb
systemctl enable mariadb
systemctl start httpd
systemctl enable httpd

mysqladmin -u root password 123

3、准备java环境

自带的Java没有javac所以删掉

rm -rf /usr/bin/java

将jdk-8u191-linux-x64.tar.gz 上传并解压

tar xf jdk-8u191-linux-x64.tar.gz 

mv jdk1.8.0_191/ /usr/local/java

修改vim /etc/profile

export JAVA_HOME=/usr/local/java
export PATH=$PATH:$JAVA_HOME/bin

source /etc/profile

java -version

javac -version

4、源码安装zabbix

将zabbix-3.4.11.tar.gz 上传并解压

 tar xf zabbix-3.4.11.tar.gz -C /usr/src/

 cd /usr/src/zabbix-3.4.11/

先将下面的安装包安装

yum -y install gcc gcc-c++ make curl-devel

./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --enable-java && make -j2 && make install

5、Mariadb数据库授权

 cd

mysql -uroot -p123

MariaDB [(none)]> create database zabbix character set utf8;

MariaDB [(none)]> grant all on zabbix.* to zabbix@localhost identified by ‘zabbix‘;

MariaDB [(none)]> grant all on zabbix.* to zabbix@‘192.168.200.111‘ identified by ‘zabbix‘;

MariaDB [(none)]> flush privileges;

MariaDB [(none)]> exit

进入到解压路径下:

cd /usr/src/zabbix-3.4.11/

mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql
mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql
mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql

登陆查看:

mysql -uroot -p123

show databases;

use zabbix;

show tables;           /有140行

5、创建zabbix程序用户并授权防止权限报错

useradd -M -s /sbin/nologin zabbix
cd /usr/local/
chown -R zabbix:zabbix zabbix/
cd ./zabbix/
pwd
mkdir logs
chown zabbix:zabbix logs/
cp -p etc/zabbix_server.conf{,.bak}
cp -p etc/zabbix_agentd.conf{,.bak}

6、修改zabbix配置文件

cd /usr/local/zabbix/etc/

vim zabbix_server.conf      文件里内容:

LogFile=/usr/local/zabbix/logs/zabbix_server.log
PidFile=/tmp/zabbix_server.pid
DBHost=192.168.200.111
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/var/lib/mysql/mysql.sock
Include=/usr/local/zabbix/etc/zabbix_server.conf.d/*.conf

vim zabbix_agentd.conf

PidFile=/tmp/zabbix_agentd.pid
Server=127.0.0.1,192.168.200.111
ServerActive=192.168.200.111
Hostname=server.zabbix.com
LogFile=/usr/local/zabbix/logs/zabbix_agentd.log
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf

7、配置php与apache

mv /usr/src/zabbix-3.4.11/frontends/php/ /var/www/html/zabbix
chown -R apache:apache /var/www/html/zabbix/
vim /etc/php.ini

878:date.timezone = Asia/Shanghai

384:max_execution_time = 300

394:max_input_time = 300

672:post_max_size = 32M

405:memory_limit = 128M

854:   extension=bcmath.so(自己手动添加)

8、web安装zabbix(web界面)

访问192.168.200.111/zabbix

技术图片

 

2019.10.31 Zabbix环境初始化及添加监控主机

标签:用户   mamicode   Fix   with   bak   curl   jdk   firewall   memory   

原文地址:https://www.cnblogs.com/990624lty-jhc/p/11773985.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!