zabbix监控服务器部署

1.安装mysql5.7

cd /App/src
rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
yum install mysql-* --skip-broken 

2.安装apache+php

yum install httpd -y
yum install php -y
#启动
systemctl start httpd
systemctl enable httpd
#php扩展
yum install php-mysqlnd php-gd libjpeg* php-snmp php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash php-common php-ctype php-xml php-xmlreader php-xmlwriter php-session php-mbstring php-gettext php-ldap php-mysqli --skip-broken
#安装其他依赖
yum install wget telnet net-tools python-paramiko gcc gcc-c++ dejavu-sans-fonts python-setuptools python-devel sendmail mailx net-snmp net-snmp-devel net-snmp-utils freetype-devel libpng-devel perl unbound libtasn1-devel p11-kit-devel OpenIPMI unixODBC mysql-devel curl-devel libxml2-devel libevent-devel

3.配置并启动mysql

datadir=/App/mysql/data
socket=/App/mysql/mysql.sock
#编辑配置文件
log-error=/App/mysql/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
#根据服务器配置调整参数
innodb_file_per_table = 1 
innodb_status_file = 1 
innodb_buffer_pool_size = 6G
innodb_flush_log_at_trx_commit = 2 
innodb_log_buffer_size = 16M 
innodb_log_file_size = 64M 
innodb_support_xa = 0 
default-storage-engine = innodb
bulk_insert_buffer_size = 8M
join_buffer_size = 16M 
max_heap_table_size = 32M 
tmp_table_size = 32M 
max_tmp_tables = 48
read_buffer_size = 32M 
read_rnd_buffer_size = 16M 
key_buffer_size = 32M 
thread_cache_size = 32
innodb_thread_concurrency = 8 
innodb_flush_method = O_DIRECT
innodb_rollback_on_timeout = 1 
query_cache_size = 16M 
query_cache_limit = 16M 
collation_server = utf8_bin
character_set_server = utf8
#启动
systemctl start mysqld
systemctl enable mysqld

4.设置zabbix数据库

#启动后查看临时密码
vim /App/mysql/log/mysqld.log
A temporary password is generated for root@localhost: Yuuqa)UWu77d
#创建zabbix所需库
create database zabbix character set utf8;
create user zabbix@'%' identified by 'zabbix@test';
grant all privileges on zabbix.* to zabbix@'%';
flush privileges;

5.编译安装zabbix

wget https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.4.7/zabbix-3.4.7.tar.gz/download
tar -zxvf zabbix-3.4.7.tar.gz
#创建用户
groupadd zabbix
useradd -g zabbix zabbix -s /sbin/nologin
#编译安装
cd zabbix-3.4.7
./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2
make install

6.设置开机启动

cp /App/src/zabbix-3.4.7/misc/init.d/fedora/core5/zabbix_server /etc/init.d/
cp /App/src/zabbix-3.4.7/misc/init.d/fedora/core5/zabbix_agentd /etc/init.d/

vim /etc/init.d/zabbix_server
#修改如下行
ZABBIX_BIN="/App/zabbix/sbin/zabbix_server"
vim /etc/init.d/zabbix_agentd
#修改如下行
ZABBIX_BIN="/App/zabbix/sbin/zabbix_agentd"
#开机启动
chkconfig zabbix_server on
chkconfig zabbix_agentd on
#启动
systemctl start zabbix_server
systemctl start zabbix_agentd

7.导入数据库

cd /App/src/zabbix-3.4.7/database/mysql
按顺序依次导入schema.sql,images.sql,data.sql
mysql -S /App/mysql/mysql.sock -p zabbix < schema.sql
mysql -S /App/mysql/mysql.sock -p zabbix < images.sql
mysql -S /App/mysql/mysql.sock -p zabbix < data.sql

8.配置zabbix web登录

#创建web目录
mkdir -p /App/zabbix_web/zabbix
cp -rf /App/src/zabbix-3.4.7/frontends/php/* /App/zabbix_web/zabbix/
#修改apache配置,否则出现403
vim /etc/httpd/conf/httpd.conf
<Directory />
    AllowOverride none
    Require all granted
</Directory>
#创建虚拟主机
<VirtualHost *:80>
ServerName 192.168.5.244
DocumentRoot /App/zabbix_web
</VirtualHost>

9.登录

192.168.5.244/zabbix
#默认用户名/密码
Admin/zabbix

10.客户端安装

#!/bin/bash
#zabbix-server地址
zabbix_serverIP=192.168.5.254
#zabbix-agent地址
HOSTNAME=192.168.5.111

#rhel7
rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm

#rhel6
#rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/6/x86_64/zabbix-release-3.4-1.el6.noarch.rpm

#rhel5
#rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/5/x86_64/zabbix-release-3.4-1.noarch.rpm

yum install zabbix-agent -y

sed -i "s/Server=127.0.0.1/Server=$zabbix_serverIP/" /etc/zabbix/zabbix_agentd.conf
sed -i "s/ServerActive=127.0.0.1/Server=$zabbix_serverIP/" /etc/zabbix/zabbix_agentd.conf
sed -i "s/Hostname=Zabbix server/Hostname=$HOSTNAME/" /etc/zabbix/zabbix_agentd.conf

#rhel6开机启动
#chkconfig zabbix-agent on
#service zabbix-agent start
#rhel7开机启动
systemctl restart zabbix-agent
systemctl enable zabbix-agent

猜你喜欢

转载自blog.csdn.net/yanggd1987/article/details/79424931