Erlo

Centos7编译安装zabbix-4.0.1

时间:2018-11-09 17:00   阅读:25次   来源:博客园页面报错

架构组合:nginx1.9.10+php7.0.32+mysql5.7.22+zabbix4.0.1

nginx1.9.10

 先装依赖

openssl-1.1.0f

tar zxvf openssl-1.1.0f.tar.gz
cd openssl-1.1.0f
./config --prefix=/usr/local/lib/openssl-1.1.0f
make && make install

pcre-8.40

tar zxvf pcre-8.40.tar.gz
cd pcre-8.40
./configure --prefix=/usr/local/lib/pcre-8.40
make && make install

zlib-1.2.11

tar zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure --prefix=/usr/local/lib/zlib-1.2.11
make && make install

nginx-1.9.10

tar -zxvf nginx-1.9.10.tar.gz
cd nginx-1.9.10

编译

./configure --prefix=/usr/local/nginx-1.9.10/ --with-pcre=/usr/local/lib/pcre-8.40/ --with-openssl=/usr/local/lib/openssl-1.1.0f/ --with-zlib=/usr/local/lib/zlib-1.2.11/

安装

make && make install

php7.0.32

php使用yum方式安装

更新yum源

CentOS/RHEL 7:

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
url:https://centos.pkgs.org/7/webtatic-x86_64/webtatic-release-7-3.noarch.rpm.html

yum

yum install php70w-common php70w-fpm php70w-opcache php70w-gd php70w-mysqlnd php70w-mbstring php70w-pecl-redis php70w-pecl-memcached php70w-devel php70w-xml -y

验证

php -v

查看所有已安装的模块

php -m 

配置文件详解

php.ini
php-fpm.conf

测试

mkdir -p /usr/local/zabbix-4.0.1/php
vim index.php

index.php

<?php
phpinfo();
?> 

nginx+php配置

cd /usr/local/nginx-1.9.10/conf
vim zabbix.conf

zabbix.conf

server{
	listen 9088;
	server_name localhost;
	access_log logs/zabbix.log;
	error_log  logs/error.log;
	location / {
		proxy_http_version 1.1;
		root /usr/local/zabbix-4.0.1/php;
		index index.html index.htm index.php;
	}
	location ~* .php$ {
		root /usr/local/zabbix-4.0.1/php;
		fastcgi_pass 127.0.0.1:9000;
		fastcgi_index index.php;
		fastcgi_param SCRIPT_FILENAME /usr/local/zabbix-4.0.1/php$fastcgi_script_name;
		include fastcgi_params;
	}
}

在nginx.conf htpp选项中加入zabbix.conf

include	  zabbix.conf;

浏览器访问:ip+9088

mysql5.7.22

解压

tar -zxvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz

新建data,logs目录用来存放数据和日志

cd /opt/mysql
mkdir data logs

my.cnf

[mysqld]
federated
datadir=/opt/mysql/data
socket=/tmp/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
skip-grant-tables
server-id=148
log-bin=mysql-bin
lower_case_table_names=1
sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
[mysqld_safe]
log-error=/opt/mysql/logs/error.log
pid-file=/opt/mysql/mysql.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

初始化

/opt/mysql/bin/mysqld --defaults-file=/etc/my.cnf --user=mysql --basedir=/opt/mysql --datadir=/opt/mysql/data --initialize

启动命令

/opt/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf &

登陆后重新设置root密码

修改授权远程zabbix密码
ALTER USER 'zabbix'@'%' IDENTIFIED BY 'zabbix';

创建zabbix远程%用户
CREATE USER 'zabbix'@'%' IDENTIFIED WITH mysql_native_password BY 'zabbix';

授权
GRANT ALL PRIVILEGES ON *.* TO 'zabbix'@'%';

刷新
flush PRIVILEGES;

zabbix4.0.1

https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.0.1/zabbix-4.0.1.tar.gz

依赖

yum install libevent libevent-devel libaio gcc libxml* unixODBC-devel mysql-devel net-snmp-devel libxml2-devel libcurl-devel libevent-devel pcre* -y

ld.so.conf

vim /etc/ld.so.conf

include ld.so.conf.d#zs#.conf
/opt/mysql/lib

编译

./configure --prefix=/usr/local/zabbix-4.0.1/ --enable-server --enable-agent --with-mysql=/opt/mysql/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2l

目录展示

[root@localhost etc]# cd /usr/local/zabbix-4.0.1/
[root@localhost zabbix-4.0.1]# cd sbin/
[root@localhost sbin]# ls
zabbix_agentd  zabbix_server
[root@localhost sbin]# cd ../etc/
[root@localhost etc]# ls
zabbix_agentd.conf  zabbix_agentd.conf.d  zabbix_server.conf  zabbix_server.conf.d
[root@localhost etc]#

php站点转移

cd /usr/local/zabbix/zabbix-4.0.1/frontends
cp -r php /usr/local/zabbix-4.0.1

zabbix_agentd.conf

zabbix_server.conf

重启nginx!

浏览器访问:ip+9088

前面还有配置图, 我当时没有截图,页面配置好进入登录界面,默认账号密码是admin/zabbix

下面就是配置添加主机分配监控之类的事了。

自家脚本一键操作

客户端启动

zagentstartall.sh

#/bin/bash
/usr/local/nginx-1.9.10/sbin/nginx
/usr/local/php/bin/php-fpm
/opt/mysql/start.sh
/usr/local/zabbix-4.0.1/sbin/zabbix_agentd

 

服务器启动

zserverstartall.sh

#/bin/bash
sudo -u chenglee /usr/local/nginx-1.9.10/sbin/nginx
/usr/local/php/bin/php-fpm
/opt/mysql/start.sh
/usr/local/zabbix-4.0.1/sbin/zabbix_serverl

效果

查看状态

status.sh

#/bin/bash
echo "***************************************"
echo "nginx status ..."
ps aux | grep nginx
echo "php status ..."
ps aux | grep php
echo "mysql status ..."
ps aux | grep mysql
echo "zabbix status ..."
ps aux | grep zabbix
echo "***************************************"l

效果

一键kill

stopall.sh

#/bin/bash
chengkill nginx
chengkill php
chengkill mysql
chengkill zabbix

效果

chengkill

#!/bin/sh
#pid kill thread for chenglee
#if fileformat=dos, update fileformat=unix
#code:set fileformat=unix
#check:set ff ?
if [ $# -lt 1 ]
then
  echo "not procedure_name"
  exit 1
fi

PROCESS=`ps -ef|grep $1|grep -v grep|grep -v PPID|awk '{ print $2}'`
for i in $PROCESS
do
  echo "Kill the $1 process [ $i ]"
  kill -9 $i
done

把chengkill扔进/usr/bin

 

下一篇:接口技术的实现:规范用户类的成员与类型

评论留言

还没有评论留言,赶紧来抢楼吧~~

Erlo大厅()

* 这里是“Erlo大厅”,在这发言所有人都可以看到。只保留当天信息

  • Erlo.vip2018-11-19 16:17:01Hello、欢迎使用Erlo大厅,这里是个吐槽的地方。
  • 首页 源码分享 新闻资讯 ERLO 搜索
    鼠标试试
    返回顶部