作者:邓聪聪
为了工作之需要,在系统服务方面不断的摸爬打滚,有了这样点点滴滴的经验,留后在使用! 插件网盘取。
链接: https://pan.baidu.com/s/1i5u0ed3 密码: rx52
1:安装依赖包--(安装LNMP环境)
yum -y install lrzsz ntp gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre* make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel cmake gcc* ncurses-devel
2: 上传源码安装包nginx、mysql(我这里用yum源的安装方式来安装这两个软件)
yum -y install http://dl.fedoraproject.org/pub/epel//i386/epel-release--.noarch.rpm
yum -y install mysql-server mysql-devel net-snmp-devel nginx
3:源码编译安装PHP
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local/php --with-png-dir=/usr/local/php --with-freetype-dir=/usr/local/php --enable-gd-native-ttf --with-iconv-dir=/usr/local/php --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local/php --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath
make -j4 && make install
#在php的安装包文件内拷贝-到安装的php的etc目录中
cp php.ini-production /usr/local/php/etc/php.ini
#需要修改的参数
/usr/local/php/etc/php.ini
max_execution_time =
post_max_size = 16M
max_input_time =
date.timezone = PRC
#/usr/local/php/etc的路径下(原有的是纯默认文件,创建一个修改配置文件)
cp php-fpm.conf.default php-fpm.conf
4:安装zabbix
tar -zxvf zabbix-3.0..tar.gz
cd zabbix-3.0.
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2
make -j4 && make install
#创建zabbix用户
useradd zabbix -s /sbin/nologin
5:#导入sql文件,在/usr/local/src/zabbix-3.2.4下。#zabbix安装包下data的将数据重定向给数据库中的zabbix
mysql -u<mysql用户> -p<mysql密码> zabbix < database/mysql/schema.sql
mysql -u<mysql用户> -p<mysql密码> zabbix < database/mysql/images.sql
mysql -u<mysql用户> -p<mysql密码> zabbix < database/mysql/data.sql
6: #进入数据库查看表项
mysql
mysql> create database zabbix default charset utf8; #创建zabbix 的库
mysql> grant all privileges on zabbix.* to zabbix@'localhost' identified by 'zabbix'; #给zabbix库赋权限
mysql> flush privileges; #刷新表权限
mysql> show databases; #查看表结构
7:#创建WEB管理目录
mkdir -p /data/zabbix/web #为了方便管理创建管理库
mkdir -p /data/zabbix/log #为了方便管理创建管理库
mkdir -pv /usr/local/nginx/conf/zabbix #为了方便管理创建管理库
8:#把目录的文件取出
cp -rp /usr/local/src/zabbix/zabbix-3.2./frontends/php/* /data/zabbix/web/
cp /usr/local/src/zabbix/zabbix-3.2./misc/init.d/tru64/zabbix_* /etc/init.d/
9:#编辑WEB访问的nginx下的配置文件
cd /usr/local/nginx/conf/zabbix/
vim zabbix.conf
server {
listen ;
server_name web;
access_log /data/zabbix/log/zabbix.access.log main;
index index.html index.php index.html;
root /data/zabbix/web;
location /{
try_files $uri $uri/ /index.php?$args;
}
location ~ ^(.+.php)(.*)$ {
fastcgi_split_path_info ^(.+.php)(.*)$;
include fastcgi.conf;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
10:#编辑nginx的配置文件
user nginx;
worker_processes ;
#error_log logs/error.log warning;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections ;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
#tcp_nopush on; #keepalive_timeout ;
keepalive_timeout ; #gzip on;
include zabbix/*.conf;
}
11:#启动服务项的进程,检查端口,检查防火墙策略等
/usr/local/src/zabbix/sbin/zabbix_agentd
/usr/local/src/zabbix/sbin/zabbix_server
/etc/init.d/nginx start
/usr/local/php/sbin
./php-fpm
/etc/init.d/mysqld start
netstat -tunlp
iptables -vnL --line
12:#设置企业微信告警在/usr/local/zabbix/share/zabbix/alertscripts下创建一个shell脚本的配置文
find / -name alertscripts ==> /usr/lib/zabbix/alertscripts #脚本所在路径
[root@bogon alertscripts]# cat weixin
#!/bin/bash
PATH=/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
###SCRIPT_NAME:weixin.sh###
###send message from weixin for zabbix monitor### CropID='wwf15e7a8a0c2ee0e7'
Secret='hoZb2VoBXEmAnLL1_ZAXmTRfVrDaOpiIEpQN6BP1KIM'
GURL="https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$CropID&corpsecret=$Secret"
Gtoken=$(/usr/bin/curl -s -G $GURL | awk -F'access_token\":\"' '{print $2}' | awk -F'"' '{print $1}') PURL="https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=$Gtoken" function body() {
local int AppID=
local UserID=$
local PartyID=
local Msg=$(echo "$@" | cut -d" " -f3-)
printf '{\n'
printf '\t"touser": "'"$UserID"\"",\n"
printf '\t"toparty": "'"$PartyID"\"",\n"
printf '\t"msgtype": "text",\n'
printf '\t"agentid": "'" $AppID "\"",\n"
printf '\t"text": {\n'
printf '\t\t"content": "'"$Msg"\""\n"
printf '\t},\n'
printf '\t"safe":"0"\n'
printf '}\n'
}
/usr/bin/curl --data-ascii "$(body $1 $2 $3)" $PURL
#测试脚本的可用性
bash -x ./weixin test4
web端微信告警设置:
13:如果配置了公网地址就建议打开防火墙 iptables
iptables -I INPUT s 192.168.2.3 -J ACCEPT
iptables -A INPUT -s (IP地址/掩码) -p tcp -m tcp --dport -j ACCEPT
iptables -A INPUT -p tcp -m tcp -j DROP
=====后面的都是zabbix的web端口设置的问题了=====
*************** <当你发现自己的才华撑不起自己的野心时,请静下心来学习吧!!!> ***************