open-falcon分布式监控(多个IDC机房)

一、背景
基于Open-falcon二次开发搭建一套新的统一监控平台,对服务器性能进行实时监控,故障告警,定期输出监控报表,收集服务器监控情况并进行图表展示,方便统一管理服务器资源,促进资源合理利用。
二、服务器组件分布情况:
服务器 分区情况
192.168.100.21 /boot 200M、swap 64G、/ 158.9G、/data 8T
192.168.100.22 /boot 200M、swap 64G、/ 158.9G、/data 20T

服务器 组件
192.168.100.21 hbs(6031,6030)、nodata(6090)、aggregator(6055)、api(8080)、alarm(9912)、dashboard(8081)
192.168.100.22 graph(6071,6070)、judge(6082,6080)、transfer(6060,8433)、Mysql(13506)、Redis(16579)
客户端 agent(20050)

服务器 目录分布
192.168.100.21 基础组件:/data/open-falcon
192.168.100.22 基础组件:/data/open-falcon、Mysql:/data/mysql、RRD:/data/datarrd
三、安装前准备

# systemctl stop firewalld
# systemctl disable firewalld
# sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
        yum install ntp git -y
        sed -i "s/^server/#server/g" /etc/ntp.conf
        grep "^server ntp1.aliyun.com" /etc/ntp.conf &> /dev/null || sed -i '21i\server ntp1.aliyun.com' /etc/ntp.conf
        systemctl stop ntpd
        ntpdate ntp1.aliyun.com;hwclock --systohc
        systemctl enable ntpd
        systemctl restart ntpd

四、Mysql配置 (192.168.100.22)
1.1 下载安装mysql

# wget http://repo.mysql.com/mysql57-community-release-el7.rpm
rpm -ivh mysql57-community-release-el7.rpm
yum install -y mysql-server
systemctl enable mysqld

1.2 更改/etc/my.cnf等mysql配置

# vim /etc/my.cnf
port=13506
datadir=/data/mysql/
systemctl start mysqld
#获取临时登录密码
[root@localhost ~]# grep 'temporary password' /var/log/mysqld.log
2018-07-09T08:43:08.265032Z 1 [Note] A temporary password is generated for root@localhost: r=fLuQ!o=9*d
[root@localhost ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.22

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> set global validate_password_policy=0;

mysql> set global validate_password_length=1;

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'test!1DC';

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'test!1DC' WITH GRANT OPTION;

mysql> FLUSH PRIVILEGES;

1.3 初始化Mysql表结构

yum install git epel-release -y
cd /tmp/ && git clone https://github.com/open-falcon/falcon-plus.git 
cd /tmp/falcon-plus/scripts/mysql/db_schema/
mysql -h127.0.0.1 -uroot -P13506 -p < 1_uic-db-schema.sql
mysql -h127.0.0.1 -uroot -P13506 -p < 2_portal-db-schema.sql
mysql -h127.0.0.1 -uroot -P13506 -p < 3_dashboard-db-schema.sql
mysql -h127.0.0.1 -uroot -P13506 -p < 4_graph-db-schema.sql
mysql -h127.0.0.1 -uroot -P13506 -p < 5_alarms-db-schema.sql
cd /data/open-falcon
rm -rf /tmp/falcon-plus/

五、redis安装(192.168.100.22)
2.1 安装redis

# yum install -y redis

2.2 更改redis配置文件

    # vim /etc/redis.conf  
#bind 127.0.0.1
protected-mode no
port 16579
daemonize yes   #开启redis守护进程
# systemctl enable redis 
# systemctl start redis 

六、下载open-falcon
2.1 上传open-falcon压缩包至/data/open-falcon

# cd /data/open-falcon
# tar -zxf openfalcon-aops-v0.1.tar.gz

2.2 修改配置文件里面的数据库密码

# cd /data/open-falcon
# grep -Ilr 3306  ./
./hbs/config/cfg.json
./api/config/cfg.json
./nodata/config/cfg.json
./graph/config/cfg.json
./aggregator/config/cfg.json
./alarm/config/cfg.json
# grep -Ilr 3306  ./ | xargs -n1 -- sed -i 's/root:password/root:test!1DC/g'
# grep -Ilr 3306  ./ | xargs -n1 -- sed -i 's/3306/13506/g'

七、192.168.100.22安装transfer

# cd /data/open-falcon
# vim transfer/config/cfg.json
{
    "debug": true,
    "minStep": 30,
    "http": {
        "enabled": true,
        "listen": "0.0.0.0:6060"
    },
    "rpc": {
        "enabled": true,
        "listen": "0.0.0.0:8433"
    },
    "socket": {
        "enabled": false,
        "listen": "0.0.0.0:4444",
        "timeout": 3600
    },
    "judge": {
        "enabled": true,
        "batch": 200,
        "connTimeout": 1000,
        "callTimeout": 5000,
        "maxConns": 32,
        "maxIdle": 32,
        "replicas": 500,
        "cluster": {           
 "judge-00" : "127.0.0.1:6080"
        }
    },
    "graph": {
        "enabled": true,
        "batch": 200,
        "connTimeout": 1000,
        "callTimeout": 5000,
        "maxConns": 32,
        "maxIdle": 32,
        "replicas": 500,
        "cluster": {
            "graph-00" : "127.0.0.1:6070"
        }
    },
    "tsdb": {
        "enabled": false,
        "batch": 200,
        "connTimeout": 1000,
        "callTimeout": 5000,
        "maxConns": 32,
        "maxIdle": 32,
        "retry": 3,
        "address": "127.0.0.1:8088"
}
# 启动服务
./open-falcon start transfer

# 校验服务,这里假定服务开启了6060的http监听端口。检验结果为ok表明服务正常启动。
curl -s "127.0.0.1:6060/health"

# 停止服务
./open-falcon stop transfer

# 查看日志
./open-falcon monitor transfer

八、192.168.100.22安装graph

# cd /data/open-falcon
# vim graph/config/cfg.json
{
    "debug": false,
    "http": {
        "enabled": true,
        "listen": "0.0.0.0:6071"
    },
    "rpc": {
        "enabled": true,
        "listen": "0.0.0.0:6070"
    },
    "rrd": {
        "storage": "/data/datarrd"
    },
    "db": {
        "dsn": "root:test!1DC@tcp(127.0.0.1:13506)/graph?loc=Local&parseTime=true",
        "maxIdle": 4
    },
    "callTimeout": 5000,
    "ioWorkerNum": 64,
    "migrate": {
            "enabled": false,
            "concurrency": 2,
            "replicas": 500,
            "cluster": {
                    "graph-00" : "127.0.0.1:6070"
            }
    }
}
# 启动服务
./open-falcon start graph

# 停止服务
./open-falcon stop graph

# 查看日志
./open-falcon monitor graph

九、192.168.100.22安装judge

# cd /data/open-falcon
# vim judge/config/cfg.json
{
    "debug": true,
    "debugHost": "nil",
    "remain": 11,
    "http": {
        "enabled": true,
        "listen": "0.0.0.0:6081"
    },
    "rpc": {
        "enabled": true,
        "listen": "0.0.0.0:6080"
    },
    "hbs": {
        "servers": ["192.168.100.21:6030"],
        "timeout": 300,
        "interval": 60
    },
    "alarm": {
        "enabled": true,
        "minInterval": 300,
        "queuePattern": "event:p%v",
        "redis": {
            "dsn": "127.0.0.1:16579",
            "maxIdle": 5,
            "connTimeout": 5000,
            "readTimeout": 5000,
            "writeTimeout": 5000
        }
    }
}
# 启动
./open-falcon start judge

# 停止
./open-falcon stop judge

# 查看日志
./open-falcon monitor judge

十、192.168.100.21安装dashboard
9.1 安装依赖包

cd /data/open-falcon
git clone https://github.com/open-falcon/dashboard.git
yum install -y python-virtualenv python-devel openldap-devel mysql-devel
yum groupinstall "Development Tools" –y
cd /data/open-falcon/dashboard/
更改pip源
mkdir ~/.pip
echo "[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple" > ~/.pip/pip.conf
新建虚拟环境
virtualenv ./env
安装python依赖
./env/bin/pip install -r pip_requirements.txt

9.2 修改配置

# vim rrd/config.py
# API_ADDR 表示后端api组件的地址
API_ADDR = os.environ.get("API_ADDR","http://127.0.0.1:8080/api/v1")
# 修改数据库IP地址、端口号和密码
# portal database
# TODO: read from api instead of db
PORTAL_DB_HOST = os.environ.get("PORTAL_DB_HOST","192.168.100.22")
PORTAL_DB_PORT = int(os.environ.get("PORTAL_DB_PORT",13506))
PORTAL_DB_USER = os.environ.get("PORTAL_DB_USER","root")
PORTAL_DB_PASS = os.environ.get("PORTAL_DB_PASS","test!1DC")
PORTAL_DB_NAME = os.environ.get("PORTAL_DB_NAME","falcon_portal")

# alarm database
# TODO: read from api instead of db
ALARM_DB_HOST = os.environ.get("ALARM_DB_HOST","192.168.100.22")
ALARM_DB_PORT = int(os.environ.get("ALARM_DB_PORT",13506))
ALARM_DB_USER = os.environ.get("ALARM_DB_USER","root")
ALARM_DB_PASS = os.environ.get("ALARM_DB_PASS","test!DC")
ALARM_DB_NAME = os.environ.get("ALARM_DB_NAME","alarms")

9.3 在生产环境启动dashboard

# /data/open-falcon/dashboard
# bash control start
falcon-dashboard started..., pid=58298
停止dashboard运行  
# bash control stop
查看日志 
# bash control tail

9.4 相关说明

dashbord没有默认创建任何账号包括管理账号,需要通过页面进行注册账号。
想拥有管理全局的超级管理员账号,需要手动注册用户名为root的账号(第一个帐号名称为root的用户会被自动设置为超级管理员)。
超级管理员可以给普通用户分配权限管理。
注册账号能够被任何打开dashboard页面的人注册,所以当给相关的人注册完账号后,需要去关闭注册账号功能。只需要去修改api组件的配置文件cfg.json,将signup_disable配置项修改为true,重启api即可。当需要给人开账号的时候,再将配置选项改回去,用完再关掉即可。

十一、192.168.100.21安装API

# cd /data/open-falcon
# vim api/config/cfg.json
{
        "log_level": "debug",
        "db": {
                "falcon_portal": "root:test!1DC@tcp(192.168.100.22:13506)/falcon_portal?charset=utf8&parseTime=True&loc=Local",
                "graph": "root:test!1DC@tcp(192.168.100.22:13506)/graph?charset=utf8&parseTime=True&loc=Local",
                "uic": "root:test!1DC@tcp(192.168.100.22:13506)/uic?charset=utf8&parseTime=True&loc=Local",
                "dashboard": "root:test!1DC@tcp(192.168.100.22:13506)/dashboard?charset=utf8&parseTime=True&loc=Local",
                "alarms": "root:test!1DC@tcp(192.168.100.22:13506)/alarms?charset=utf8&parseTime=True&loc=Local",
                "db_bug": true
        },
        "graphs": {
                "cluster": {
                        "graph-00": "192.168.100.22:6070"
                },
                "max_conns": 100,
                "max_idle": 100,
                "conn_timeout": 1000,
                "call_timeout": 5000,
                "numberOfReplicas": 500
        },
        "metric_list_file": "./api/data/metric",
        "web_port": "0.0.0.0:8080",
        "access_control": true,
        "signup_disable": false,
        "salt": "",
        "skip_auth": false,
        "default_token": "default-token-used-in-server-side",
        "gen_doc": false,
        "gen_doc_path": "doc/module.html"
}
# 启动服务
./open-falcon start api

# 停止服务
./open-falcon stop api

# 查看日志
./open-falcon monitor api

十二、192.168.100.21安装hbs

# cd /data/open-falcon
# vim hbs/config/cfg.json
{
    "debug": true,
    "database": "root:test!1DC@tcp(192.168.100.22:13506)/falcon_portal?loc=Local&parseTime=true",
    "hosts": "",
    "maxConns": 20,
    "maxIdle": 15,
    "listen": ":6030",
    "trustable": [""],
    "http": {
        "enabled": true,
        "listen": "0.0.0.0:6031"
    }
}
# 启动
./open-falcon start hbs

# 停止
./open-falcon stop hbs

# 查看日志
./open-falcon monitor hbs

十三、192.168.100.21安装alarm

# cd /data/open-falcon
# vim alarm/config/cfg.json
{
    "log_level": "debug",
    "http": {
        "enabled": true,
        "listen": "0.0.0.0:9912"
    },
    "redis": {
        "addr": "192.168.100.22:6379",
        "maxIdle": 5,
        "highQueues": [
            "event:p0",
            "event:p1",
            "event:p2"
        ],
        "lowQueues": [
            "event:p3",
            "event:p4",
            "event:p5",
            "event:p6"
        ],
        "userIMQueue": "/queue/user/im",
        "userSmsQueue": "/queue/user/sms",
        "userMailQueue": "/queue/user/mail"
    },
"api": {
        "im": "http://127.0.0.1:10086/wechat",
        "sms": "http://127.0.0.1:10086/sms",
        "mail": "http://127.0.0.1:10086/mail",
        "dashboard": "http://127.0.0.1:8081",
        "plus_api":"http://127.0.0.1:8080",
        "plus_api_token": "default-token-used-in-server-side"
    },
    "falcon_portal": {
        "addr": "root:test!1DC@tcp(192.168.100.22:13506)/alarms?charset=utf8&loc=Asia%2FChongqing",
        "idle": 10,
        "max": 100
    },
    "worker": {
        "im": 10,
        "sms": 10,
        "mail": 50
    },
    "housekeeper": {
        "event_retention_days": 7,
        "event_delete_batch": 100
    }
}
# 启动
./open-falcon start alarm

# 停止
./open-falcon stop alarm

# 查看日志
./open-falcon monitor alarm

十四、192.168.100.21安装nodata

# cd /data/open-falcon
# vim nodata/config/cfg.json
{
    "debug": true,
    "http": {
        "enabled": true,
        "listen": "0.0.0.0:6090"
    },
    "plus_api":{
        "connectTimeout": 500,
        "requestTimeout": 2000,
        "addr": "http://127.0.0.1:8080",
        "token": "default-token-used-in-server-side"
    },
    "config": {
        "enabled": true,
        "dsn": "root:test!1DC@tcp(192.168.100.22:13506)/falcon_portal?loc=Local&parseTime=true&wait_timeout=604800",
        "maxIdle": 4
    },
    "collector":{
        "enabled": true,
        "batch": 200,
        "concurrent": 10
    },
    "sender":{
        "enabled": true,
        "connectTimeout": 500,
        "requestTimeout": 2000,
        "transferAddr": "192.168.100.22:6060",
        "batch": 500
    }
}
启动服务
./open-falcon start nodata

# 停止服务
./open-falcon stop nodata

# 检查日志
./open-falcon monitor nodata

十五、192.168.100.21安装aggregator

# cd /data/open-falcon
# vim aggregator/config/cfg.json
{
    "debug": true,
    "http": {
        "enabled": true,
        "listen": "0.0.0.0:6055"
    },
    "database": {
        "addr": "root:test!1DC@tcp(192.168.100.22:13506)/falcon_portal?loc=Local&parseTime=true",
        "idle": 10,
        "ids": [1, -1],
        "interval": 55
    },
    "api": {
        "connect_timeout": 500,
        "request_timeout": 2000,
        "plus_api": "http://127.0.0.1:8080",
        "plus_api_token": "default-token-used-in-server-side",
        "push_api": "http://127.0.0.1:1988/v1/push"
    }
}
# 启动服务
./open-falcon start aggregator

# 检查log
./open-falcon monitor aggregator

# 停止服务
./open-falcon stop aggregator

十六、dashboard访问

http://192.168.100.21:8081     
先通过“sign up”注册管理员账号 root  test!1DC

十七、agent调整
重新编译打包agent安装包,调整服务名称和配置文件后,打包为test-monitor.tar.gz

# export GOPATH=/home
# ls /home
# mkdir -p $GOPATH/src/github.com/open-falcon
# cd $GOPATH/src/github.com/open-falcon
# git clone https://github.com/open-falcon/agent.git
# cd agent
# go get ./...
# ./control build
# ./control pack

# ls /iflymonitor/test-monitor
cfg.json  control  gitversion  test-monitor  public
# cat /iflymonitor/test-monitor/cfg.json
{
    "debug": false,
    "hostname": "192.168.100.21",
    "ip": "",
    "plugin": {
        "enabled": true,
        "dir": "./plugin",
        "git": "http://192.168.100.21:3000/root/plugin.git",
        "logs": "./logs"
    },
    "heartbeat": {
        "enabled": true,
        "addr": "192.168.100.21:6030",
        "interval": 60,
        "timeout": 1000
    },
    "transfer": {
        "enabled": true,
        "addrs": [
            "192.168.100.22:8433"
        ],
        "interval": 60,
        "timeout": 1000
    },
    "http": {
        "enabled": true,
        "listen": ":20050",
        "backdoor": false
    },
    "collector": {
        "ifacePrefix": ["eth", "em", "p13p", "p16p", "eno", "bond", "enp"],
        "mountPoint": []
    },
    "default_tags": {
    },
    "ignore": {
        "df.bytes.free": true,
        "df.inodes.total": true,
        "df.inodes.free": true,
        "df.inodes.used": true
    }
}
# cat /iflymonitor/test-monitor/control
#!/bin/bash

WORKSPACE=$(cd $(dirname $0)/; pwd)
cd $WORKSPACE

mkdir -p var

module=monitor
app=test-$module
conf=cfg.json
pidfile=var/app.pid
logfile=var/app.log

function check_pid() {
    if [ -f $pidfile ];then
        pid=`cat $pidfile`
        if [ -n $pid ]; then
            running=`ps -p $pid|grep -v "PID TTY" |wc -l`
            return $running
        fi
    fi
    return 0
}

function start() {
    check_pid
    running=$?
    if [ $running -gt 0 ];then
        echo -n "$app now is running already, pid="
        cat $pidfile
        return 1
    fi

    if ! [ -f $conf ];then
        echo "Config file $conf doesn't exist, creating one."
        cp cfg.example.json $conf
    fi
    nohup ./$app -c $conf &> $logfile &
    sleep 1
    running=`ps -p $! | grep -v "PID TTY" | wc -l`
    if [ $running -gt 0 ];then
        echo $! > $pidfile
        echo "$app started..., pid=$!"
    else
        echo "$app failed to start."
        return 1
    fi
}

function stop() {
    pid=`cat $pidfile`
    kill $pid
    rm -f $pidfile
    echo "$app stoped..."
}

function restart() {
    stop
    sleep 1
    start
}

function status() {
    check_pid
    running=$?
    if [ $running -gt 0 ];then
        echo started
    else
        echo stoped
    fi
}

function tailf() {
    tail -f $logfile
}

function build() {
    go build
    if [ $? -ne 0 ]; then
        exit $?
    fi
    mv $module $app
    ./$app -v
}

function pack() {
    build
    git log -1 --pretty=%h > gitversion
    version=`./$app -v`
    file_list="public control cfg.example.json $app"
    echo "...tar $app-$version.tar.gz <= $file_list"
    tar zcf $app-$version.tar.gz gitversion $file_list
}

function packbin() {
    build
    git log -1 --pretty=%h > gitversion
    version=`./$app -v`
    tar zcvf $app-bin-$version.tar.gz $app gitversion
}

function help() {
    echo "$0 build|pack|start|stop|restart|status|tail"
}

if [ "$1" == "" ]; then
    help
elif [ "$1" == "stop" ];then
    stop
elif [ "$1" == "start" ];then
    start
elif [ "$1" == "restart" ];then
    restart
elif [ "$1" == "status" ];then
    status
elif [ "$1" == "tail" ];then
    tailf
elif [ "$1" == "build" ];then
    build
elif [ "$1" == "pack" ];then
    pack
elif [ "$1" == "packbin" ];then
    packbin
else
    help
fi
/iflymonitor/test-monitor/control start 启动进程
/iflymonitor/test-monitor/control stop 停止进程
/iflymonitor/test-monitor/control restart 重启进程
/iflymonitor/test-monitor/control status 查看进程状态
/iflymonitor/test-monitor/control tail 用tail -f的方式查看var/app.log
通过web访问http://IP:20050可查看客户端监控具体数据
插件功能脚本开启:
# curl http://客户端IP:20050/plugin/update

十八、Gogs搭建(192.168.100.21)
先在数据库192.168.100.22新建数据库gogs

# yum install go git –y
# cd /data/
# wget https://dl.gogs.io/0.11.53/gogs_0.11.53_linux_amd64.zip
# unzip gogs_0.11.53_linux_amd64.zip
# rm –rf gogs_0.11.53_linux_amd64.zip
# cd /data/gogs
# nohup ./gogs web &
在浏览器开启http://192.168.100.21:3000/install
 
 
 
安装完成后生成配置文件:
# cat custom/conf/app.ini 
APP_NAME = Gogs
RUN_USER = root
RUN_MODE = prod

[database]
DB_TYPE  = mysql
HOST     = 192.168.100.22:13506
NAME     = gogs
USER     = root
PASSWD   = test!1DC
SSL_MODE = disable
PATH     = data/gogs.db

[repository]
ROOT = /data/gogs-repositories

[server]
DOMAIN           = monitor1
HTTP_PORT        = 3000
ROOT_URL         = http://192.168.100.21:3000/
DISABLE_SSH      = false
SSH_PORT         = 22
START_SSH_SERVER = false
OFFLINE_MODE     = false

[mailer]
ENABLED = false

[service]
REGISTER_EMAIL_CONFIRM = false
ENABLE_NOTIFY_MAIL     = false
DISABLE_REGISTRATION   = false
ENABLE_CAPTCHA         = true
REQUIRE_SIGNIN_VIEW    = false

[picture]
DISABLE_GRAVATAR        = false
ENABLE_FEDERATED_AVATAR = false

[session]
PROVIDER = file

[log]
MODE      = file
LEVEL     = Info
ROOT_PATH = /data/gogs/log

[security]
INSTALL_LOCK = true
SECRET_KEY   = iNepwzguAvC8LXB

设置开机自启:
# cp scripts/systemd/gogs.service /usr/lib/systemd/system/
# chmod +x /usr/lib/systemd/system/gogs.service 
# vim /usr/lib/systemd/system/gogs.service
[Unit]
Description=Gogs
After=syslog.target
After=network.target
After=mariadb.service mysqld.service postgresql.service memcached.service redis.service

[Service]
# Modify these two values and uncomment them if you have
# repos with lots of files and get an HTTP error 500 because
# of that
###
#LimitMEMLOCK=infinity
#LimitNOFILE=65535
Type=simple
#User=git
#Group=git
WorkingDirectory=/data/gogs
ExecStart=/data/gogs/gogs web
Restart=always
Environment=USER=root HOME=/data/gogs/

[Install]
WantedBy=multi-user.target

# systemctl enable gogs
Created symlink from /etc/systemd/system/multi-user.target.wants/gogs.service to /usr/lib/systemd/system/gogs.service.
# systemctl stop gogs
# systemctl start gogs
# systemctl status gogs

Gogs访问方式:http://192.168.100.21:3000
git仓库:

git config --global user.email "[email protected]"
git config --global user.root “root”

客户端相关的git仓库建设:
通过root用户登录上去之后,新建test-monitor仓库,然后将agent文件push上去;

# ls
cfg.json  control  gitversion  test-monitor  public
# rm -rf .git
# git init
Initialized empty Git repository in /test-monitor/.git/
# git add cfg.json 
# git add control 
# git  add test-monitor 
# git add public
# git commit -m "test"
# git remote add origin http://192.168.100.21:3000/root/test-monitor.git
# git push -u origin master
Counting objects: 44, done.
Compressing objects: 100% (43/43), done.
Username for 'http://192.168.100.21:3000': root
Password for 'http://[email protected]:3000': 
Writing objects: 100% (44/44), 4.17 MiB | 140.00 KiB/s, done.
Total 44 (delta 1), reused 0 (delta 0)
To http://192.168.100.21:3000/root/test-monitor.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.
后期下载客户端直接通过git clone命令下载即可:
git clone http://192.168.100.21:3000/root/test-monitor.git
[root@node1 tmp]# ls
test-monitor
[root@node1 tmp]# cd test-monitor/
[root@node1 test-monitor]# ls
cfg.json  control  test-monitor  public

十九、192.168.100.21安装task

https://github.com/open-falcon/task
https://github.com/open-falcon/task/releases/download/v0.0.10/falcon-task-0.0.10.tar.gz
# export GOPATH=/home
# ls /home
# mkdir -p $GOPATH/src/github.com/open-falcon
# cd $GOPATH/src/github.com/open-falcon
# git clone https://github.com/open-falcon/task.git
# cd task
# go get ./...
# ./control build
# ./control pack
# tar -zxf falcon-task-0.0.10.tar.gz -C /data/task/
# cd /data/task
# mv cfg.example.json cfg.json
# vim cfg.json
{
    "debug": false,
    "http": {
        "enable": true,
        "listen": "0.0.0.0:8002"
    },
    "index": {
        "enable": false,
        "dsn": "root:test!1DC@tcp(192.168.100.22:13506)/graph?loc=Local&parseTime=true",
        "maxIdle": 4,
        "autoDelete": false,
        "cluster":{
            "test.hostname01:6071" : "0 0 0 ? * 0-5",
            "test.hostname02:6071" : "0 30 0 ? * 0-5"
        }
    },
    "collector" : {
        "enable": true,
        "destUrl" : "http://192.168.100.21:20050/v1/push",
        "srcUrlFmt" : "http://%s/statistics/all",
        "cluster" : [
            "transfer,192.168.100.22:6060",
            "graph,192.168.100.22:6071",
            "task,127.0.0.1:8001"
        ]
    }
}

二十、外地IDC转发节点
主要开启transfer、hbs、agent服务

18.1 上传open-falcon压缩包至/data/open-falcon
# cd /data/open-falcon
# tar -zxf openfalcon-aops-v0.1.tar.gz
配置transfer
# cp /data/open-falcon/transfer/config/cfg.json{,.bak}
# vim /data/open-falcon/transfer/config/cfg.json
{
    "debug": true,
    "minStep": 30,
    "http": {
        "enabled": true,
        "listen": "0.0.0.0:6060"
    },
    "rpc": {
        "enabled": true,
        "listen": "0.0.0.0:8433"
    },
    "socket": {
        "enabled": false,
        "listen": "0.0.0.0:4444",
        "timeout": 3600
    },
    "judge": {
        "enabled": true,
        "batch": 200,
        "connTimeout": 1000,
        "callTimeout": 5000,
        "maxConns": 32,
        "maxIdle": 32,
        "replicas": 500,
        "cluster": {
            "judge-00" : "192.168.100.22:6080"
        }
    },
    "graph": {
        "enabled": true,
        "batch": 200,
        "connTimeout": 1000,
        "callTimeout": 5000,
        "maxConns": 32,
        "maxIdle": 32,
        "replicas": 500,
        "cluster": {
            "graph-00" : "192.168.100.22:6070"
        }
    },
    "tsdb": {
        "enabled": false,
        "batch": 200,
        "connTimeout": 1000,
        "callTimeout": 5000,
        "maxConns": 32,
        "maxIdle": 32,
        "retry": 3,
        "address": "127.0.0.1:8088"
}
}
配置hbs:
# cp /data/open-falcon/hbs/config/cfg.json{,.bak}
# vim /data/open-falcon/hbs/config/cfg.json
{
    "debug": true,
    "database": "root:test!1DC@tcp(192.168.100.22:13506)/falcon_portal?loc=Local&parseTime=true",
    "hosts": "",
    "maxConns": 20,
    "maxIdle": 15,
    "listen": ":6030",
    "trustable": [""],
    "http": {
        "enabled": true,
        "listen": "0.0.0.0:6031"
    }
}
# cd /data/open-falcon/
# ./open-falcon start hbs
# ./open-falcon start transfer
# ./open-falcon check
        falcon-graph       DOWN               - 
          falcon-hbs         UP          205696 
        falcon-judge       DOWN               - 
     falcon-transfer         UP          205718 
       falcon-nodata       DOWN               - 
   falcon-aggregator       DOWN               - 
        falcon-agent         UP          205738 
      falcon-gateway       DOWN               - 
          falcon-api       DOWN               - 
        falcon-alarm       DOWN               - 
# firewall-cmd --permanent --zone=public --add-port=20050/tcp
# firewall-cmd --permanent --zone=public --add-port=8433/tcp
# firewall-cmd --permanent --zone=public --add-port=6030/tcp
# firewall-cmd –reload
# firewall-cmd --list-all

你可能感兴趣的:(监控,服务)