准备把国内的一些服务外迁,这里正好做个网络监控来监控以下,smokeping部署在aliyun Hong Kong B区
首先需要删除ECS Centos7中自带的一些阿里云监控
卸载安骑士以及监控:
wget http://update.aegis.aliyun.com/download/uninstall.sh
chmod +x uninstall.sh
./uninstall.sh
wget http://update.aegis.aliyun.com/download/quartz_uninstall.sh
chmod +x quartz_uninstall.sh
./quartz_uninstall.sh
删除残留服务:
pkill aliyun-service
rm -fr /etc/init.d/agentwatch
rm -rf /usr/sbin/aliyun*
rm -rf /usr/local/aegis*
rm -rf /etc/systemd/system/aliyun*
这样才算基本完成删除的aliyun的残留服务
某些文章上还会写有屏蔽云盾的IP,有时间还是得看看log来查看是不是有必要屏蔽云盾的IP
iptables -I INPUT -s 140.205.201.0/28 -j DROP
iptables -I INPUT -s 140.205.201.16/29 -j DROP
iptables -I INPUT -s 140.205.201.32/28 -j DROP
iptables -I INPUT -s 140.205.225.192/29 -j DROP
iptables -I INPUT -s 140.205.225.200/30 -j DROP
iptables -I INPUT -s 140.205.225.184/29 -j DROP
iptables -I INPUT -s 140.205.225.183/32 -j DROP
iptables -I INPUT -s 140.205.225.206/32 -j DROP
iptables -I INPUT -s 140.205.225.205/32 -j DROP
iptables -I INPUT -s 140.205.225.195/32 -j DROP
iptables -I INPUT -s 140.205.225.204/32 -j DROP
这篇文章到了这里才算是完成了服务器的初始清理工作
在安装之前我们需要关闭selinux, firewall, 同步一下时间
yum -y install ntpdate
ntpdate 0.pool.ntp.org
或者从www.ntppool.org中选择一个
下面开始进入安装工作 ,其实在作者的官方网站把过程写的清清楚楚:
https://oss.oetiker.ch/smokeping/doc/smokeping_install.en.html
- 安装epel package
yum install epel-release
2. 安装development tools
yum groupinstall "Development tools"
3. 安装fping (smokeping 2.7.2以上需要fping4.0以上,因此需要手动编译)
cd ~
wget https://fping.org/dist/fping-4.1.tar.gz
tar -zxvf fping-4.1.tar.gz
cd fping-4.1
./configure
make
make install
安装好的fping位于/usr/local/sbin/fping
4. 安装echoping (预防以后需要做tcp ping)
cd ~
wget https://fossies.org/linux/misc/old/echoping-6.0.2.tar.gz
tar -zxvf echoping-6.0.2.tar.gz
cd echoping-6.0.2
yum install -y popt-devel openssl openssl-devel
./configure --with-ssl --without-libidn
make
make install
安装好的echoping位于/usr/local/bin/echoping
5 安装需要的package
yum install rrdtool rrdtool-perl curl bind-utils gcc make gcc-c++
yum install perl-core
6. 安装apache
yum install httpd httpd-devel
yum install mod_fcgid
7. 安装nginx
yum install nginx -y
chkconfig nginx on
service nginx start
8 安装smokeping
cd ~
wget https://oss.oetiker.ch/smokeping/pub/smokeping-2.7.3.tar.gz
tar -zxvf smokeping-2.7.3.tar.gz
cd smokeping-2.7.3
./configure --prefix=/opt/smokeping PERL5LIB=/usr/lib64/perl5/
/usr/bin/gmake install
9 初始化smokeping, 我们需要建立三个文件夹,data用来存放rrd文件,var用来存放smokeping的pid, log用来存放smokeping.log
cd /opt/smokeping
mkdir data var log
chmod 777 data
chmod 777 var
chmod 777 log
touch log/smokeping.log
rename config file and set permission
cd /opt/smokeping/etc/
for foo in *.dist; do cp $foo `basename $foo .dist`; done
chmod 600 /opt/smokeping/etc/smokeping_secrets.dist
配置config文件
编辑/opt/smokeping/etc/config, 配置从github上download
10 设置apache
把/opt/smokeping/htdoc下面的文件copy到/var/www/html去
同时
mkdir cache
chmod 777 cache
把smokeping.fcgi.dist改名放到cgi-bin下面
11 编辑apache 配置文件
设置 /var/www/html
AllowOverride All
设置/var/www/cgi-bin
AllowOverride All
12 配置nginx
配置文件:
server{
listen 80;
server_name www.xxxxxx.com;
index index.html index.htm index.php default.html default.htm default.php;
access_log off;
error_log /var/log/nginx/www.xxxxxx.com.error.log;
location / {
proxy_pass http://127.0.0.1:8080;
#Proxy Settings
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_max_temp_file_size 0;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 128k;
proxy_buffers 6 32k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
client_max_body_size 50m;
}
}
13 进入/var/www/html, 设置.htaccess
RewriteEngine On
RewriteRule ^$ /cgi-bin/smokeping.fcgi [NC,L]
14. 写入smokeping自启动文件
编辑/etc/systemd/system/smokeping.service
[Unit]
Description=Latency Logging and Graphing System
After=syslog.target network.target
[Service]
ExecStart=/opt/smokeping/bin/smokeping
ExecReload=/bin/kill -HUP $MAINPID
StandardError=syslog
Type=forking
PIDFile=/opt/smokeping/var/smokeping.pid
[Install]
WantedBy=multi-user.target