雾里看浮光
不管遇到什么事情,都要调整好自己的心态,用最好的自己重新开始,自甘堕落只会越来越糟糕!加油!

一、环境准备

操作系统:CentOS_Server_7.5_x64_1804.iso

部署组件:Zabbix

二、操作步骤:

Zabbix_Server安装部署

2.0.安装依赖组件

[root@localhost ~]# yum -y install net-snmp-devel libevent-devel

2.1.创建zabbix用户组和用户

[root@localhost ~]# groupadd zabbix

[root@localhost ~]# useradd -r -g zabbix zabbix

2.2.安装zabbix服务

[root@localhost ~]# cd /usr/local/src/

[root@localhost src]# tar -xzf zabbix-4.2.6.tar.gz -C /usr/local/data/

[root@localhost src]# cd /usr/local/data/zabbix-4.2.6/

[root@localhost zabbix-4.2.6]# ./configure --prefix=/usr/local/data/zabbix --enable-server --enable-agent --with-mysql=/usr/local/data/mysql/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2

[root@localhost zabbix-4.2.6]# make

[root@localhost zabbix-4.2.6]# make install

#设置环境变量

[root@localhost zabbix-4.2.6]# vim /etc/profile

# Zabbix Environment
export PATH=$PATH:/usr/local/data/zabbix/sbin/:/usr/local/data/zabbix/bin/

[root@localhost zabbix-4.2.6]# source /etc/profile

#导入数据库表

[root@localhost zabbix-4.2.6]# mysql -uroot -p

Enter password:
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@'localhost' identified by 'lixiaozhe';
mysql> flush privileges;
mysql> set names utf8;
mysql> use zabbix;
mysql> source /usr/local/data/zabbix-4.2.6/database/mysql/schema.sql
mysql> source /usr/local/data/zabbix-4.2.6/database/mysql/data.sql
mysql> source /usr/local/data/zabbix-4.2.6/database/mysql/images.sql
mysql> exit

#编译zabbix_server的配置文件

[root@localhost zabbix-4.2.6]# vim /usr/local/data/zabbix/etc/zabbix_server.conf

### Option: LogFile
LogFile=/usr/local/data/zabbix/logs/zabbix_server.log
### Option: LogFileSize
LogFileSize=0
### Option: DBHost
DBHost=localhost
### Option: DBName
DBName=zabbix
### Option: DBUser
DBUser=zabbix
### Option: DBPassword
DBPassword=lixiaozhe
### Option: DBSocket
DBSocket=/tmp/mysql.sock
### Option: DBPort
DBPort=3306
### Option: Timeout
Timeout=30
### Option: AlertScriptsPath
AlertScriptsPath=/usr/local/data/zabbix/alertscripts
### Option: ExternalScripts
ExternalScripts=/usr/local/data/zabbix/externalscripts
### Option: LogSlowQueries
LogSlowQueries=3000

#授权

[root@localhost zabbix-4.2.6]# mkdir /usr/local/data/zabbix/logs

[root@localhost zabbix-4.2.6]# mkdir /usr/local/data/zabbix/pid

[root@localhost zabbix-4.2.6]# chown -R zabbix:zabbix /usr/local/data/zabbix/

#安装PHP时已添加过,需重新更新配置

[root@localhost zabbix-4.2.6]# more /etc/ld.so.conf

include ld.so.conf.d/*.conf
/usr/local/lib64
/usr/local/lib /*添加此路径*/
/usr/lib
/usr/lib64

[root@localhost zabbix-4.2.6]# ldconfig

#启动zabbix

[root@localhost zabbix-4.2.6]# zabbix_server

#杀死进程

[root@localhost zabbix-4.2.6]# ps -ef | grep zabbix_server | grep -v grep | awk '{print $2}' | xargs kill -9

#zabbix_server开机启动

[root@localhost zabbix-4.2.6]# vi /usr/lib/systemd/system/zabbix-server.service

[Unit]
Description=Zabbix
After=network.target

[Service]
Environment="CONFFILE=/usr/local/data/zabbix/etc/zabbix_server.conf"
Type=forking
Restart=on-failure
PIDFile=/tmp/zabbix_server.pid
KillMode=control-group
ExecStart=/usr/local/data/zabbix/sbin/zabbix_server -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s

[Install]
WantedBy=multi-user.target

#启动命令

[root@localhost zabbix-4.2.6]# systemctl daemon-reload

[root@localhost zabbix-4.2.6]# systemctl enable zabbix-server

[root@localhost zabbix-4.2.6]# systemctl stop zabbix-server

[root@localhost zabbix-4.2.6]# systemctl start zabbix-server

[root@localhost zabbix-4.2.6]# systemctl restart zabbix-server

#nginx/html/下创建zabbix目录,并拷贝zabbix-4.2.6/frontends/php/至nginx/html/zabbix目录下

[root@localhost zabbix-4.2.6]# mkdir -p /usr/local/data/nginx/html/zabbix

[root@localhost zabbix-4.2.6]# cp -a /usr/local/data/zabbix-4.2.6/frontends/php/* /usr/local/data/nginx/html/zabbix/

#zabbix_web需要php配置优化,编辑php.ini文件(在安装PHP服务时已调优配置完成,在这里无需调改配置)

[root@localhost zabbix-4.2.6]# vim /usr/local/data/php7/etc/php.ini

max_execution_time = 30      修改为350-(zabbix_web优化)
max_input_time = 60        修改为350-(zabbix_web优化)
post_max_size = 8M        修改为32M-(zabbix_web优化)
date.timezone = Asia/Shanghai  添加-(zabbix_web优化)

[root@localhost zabbix-4.2.6]# systemctl restart php-fpm

[root@localhost zabbix-4.2.6]# nginx -s reload

#通过浏览器访问zabbiweb页面,对zabbix进行初始化配置

http://ip/zabbix

第一步操作:

Welcome to Zabbix 4.2.6(默认)

下一步(Next step)

第二步操作:

Check of pre-requisites(默认)

下一步(Next step)

第三步操作:

Configure DB connection(添加)

#数据库类型

Database type :MySQL

#数据库地址

Database host :localhost

#数据库端口 0 - use default port

Database port :0

#数据库名称

Database name :zabbix

#数据库用户

user :zabbix

#数据库密码

password :lixiaozhe

下一步(Next step)

第四步操作:

Zabbix server defils(添加)

#定义主机名称

Host :localhost

#端口号

Port :10051

#名称

Name :Zabbix

下一步(Next step)

第五步操作:
Pre-installation summary(默认)

下一步(Next step)

第六步操作:

Install(配置)

#需要下载zabbix.conf.php文件,并上传指定目录

1.点击 Download the configuration file 下载zabbix.conf.php文件;

2.把 zabbix.conf.php 文件拷贝到服务器 /usr/local/data/nginx/html/zabbix/conf/目录下;

点击完(Finish)

Congratulations! You have successfully installed Zabbix frontend.

点击完(Finish)

第七步操作:

Zabbix页面登陆

Username:Admin

Password:zabbix

点击登陆(Sign in)

三、客户端服务安装部署

安装PCRE库

[root@master-node1 ~]# yum -y install prce-devel

创建zabbix用户组和用户

[root@master-node1 ~]# groupadd zabbix

[root@master-node1 ~]# useradd -r -g zabbix zabbix

安装zabbix_agentd客户端

[root@master-node1 ~]# cd /usr/local/src/

[root@master-node1 src]# tar -xzf zabbix-4.2.6.tar.gz -C /usr/local/data/

[root@master-node1 src]# cd /usr/local/data/zabbix-4.2.6/

[root@master-node1 zabbix-4.2.6]# ./configure --prefix=/usr/local/data/zabbix/zabbix_agentd --enable-agent

[root@master-node1 zabbix-4.2.6]# make

[root@master-node1 zabbix-4.2.6]# make install

编译zabbix_agentd的配置文件

[root@master-node1 zabbix-4.2.6]# vim /usr/local/data/zabbix/zabbix_agentd/etc/zabbix_agentd.conf

### Option: PidFile
PidFile=/usr/local/data/zabbix/zabbix_agentd/pid/zabbix_agentd.pid
### Option: LogFile
LogFile=/usr/local/data/zabbix/zabbix_agentd/logs/zabbix_agentd.log
### Option: Server
Server=192.168.13.100
### Option: ServerActive
ServerActive=192.168.13.100
### Option: Hostname
Hostname=localhost
### Option: EnableRemoteCommands
EnableRemoteCommands=1
### Option: LogRemoteCommands
LogRemoteCommands=1
### Option: LogFileSize
LogFileSize=1
### Option: DebugLevel
DebugLevel=3

#授权

[root@master-node1 zabbix-4.2.6]# mkdir /usr/local/data/zabbix/zabbix_agentd/logs

[root@master-node1 zabbix-4.2.6]# mkdir /usr/local/data/zabbix/zabbix_agentd/pid

[root@master-node1 zabbix-4.2.6]# chown -R zabbix:zabbix /usr/local/data/zabbix/

添加zabbix_agentd客户端开机自启动

[root@master-node1 zabbix-4.2.6]# cp /usr/local/data/zabbix-4.2.6/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd

[root@master-node1 zabbix-4.2.6]# chmod 755 /etc/init.d/zabbix_agentd

[root@master-node1 zabbix-4.2.6]# chkconfig zabbix_agentd on

[root@master-node1 zabbix-4.2.6]# vim /etc/init.d/zabbix_agentd

# Variables
# Edit these to match your system settings

# Zabbix-Directory
BASEDIR=/usr/local/data/zabbix/zabbix_agentd/

[root@master-node1 zabbix-4.2.6]# systemctl daemon-reload

[root@master-node1 zabbix-4.2.6]# systemctl stop zabbix_agentd.service

[root@master-node1 zabbix-4.2.6]# systemctl start zabbix_agentd.service

[root@master-node1 zabbix-4.2.6]# systemctl restart zabbix_agentd.service

posted on 2019-10-14 17:26  雾里看浮光  阅读(308)  评论(0编辑  收藏  举报