美文网首页
linux--open-falcon--改用docker安装(2

linux--open-falcon--改用docker安装(2

作者: w_dll | 来源:发表于2020-06-23 18:50 被阅读0次

    改用docker部署,简单方便,并且风险小,后期想要使用的话也更加简单;
    测试了很多次,最后分为三个部分的镜像部署,mysql端,后端,前端;
    只需要下载以下文件,解压后,一次分别进入f-mysql、f-back 、f-front 三个目录,执行目录下的init.sh脚本即可;环境为安装了docker的centos7服务器;

    下载以下文件
    链接:https://pan.baidu.com/s/1UiRT_9h6m30tw_i7DL82Fg
    提取码:9a43
    传到服务器上,解压
    tar xvf open-falcon.tar

    1 mysql端


    执行init.sh脚本即可;脚本内容如下:

    #!/bin/bash
    
    docker pull mysql:5.7
    
    mkdir data logs conf
    
    docker run --name falcon-mysql \
    -v $PWD/conf:/etc/mysql/conf.d \
    -v $PWD/data:/var/lib/mysql \
    -v $PWD/logs:/var/log \
    -e MYSQL_ROOT_PASSWORD="admin123" -d mysql:5.7
    
    while :
    do
        this_str=`docker exec -it falcon-mysql mysql -h127.0.0.1 -uroot -padmin123 -e "grant all privileges on *.* to 'root'@'%' identified by 'admin123';"`
        if [[ $this_str =~ "2003" ]];then
            echo "waiting......."
        else
            echo $this_str
            echo "success"
            break
        fi
    sleep 2
    done
    
    cp -r ./db_schema ./logs
    sleep 2
    for li in `ls ./db_schema`;
    do
      docker exec -it falcon-mysql mysql -uroot -padmin123 -e "source /var/log/db_schema/$li;"
    done
    
    

    2 后端

    需要构建镜像;执行init.sh脚本即可;

    • init.sh
    #!/bin/bash
    work_path=$(dirname $0)
    cd $work_path
    
    rm -rf data logs rrddata
    mkdir data logs rrddata
    
    read -p 'input version:' app_version
    docker build -t openfalcon-back:$app_version .
    
    cd config
    bash set-mail.sh
    
    cd $work_path
    docker run -itd --name falcon-back \
            --link=falcon-mysql:db.falcon \
             -p 8433:8433 \
             -p 6030:6030 \
             -p 5050:5050 \
             -p 8080:8080 \
             -p 6060:6060 \
             -p 5090:5090 \
             -v $PWD/data:/home/work/open-falcon/graph/data \
             -v $PWD/logs:/home/work/open-falcon/logs \
             -v $PWD/rrddata:/home/work/open-falcon/data \
             -v $PWD/config/cfg.json:/home/work/open-falcon/mail-provider/cfg.json \
             openfalcon-back:$app_version
    
    
    • Dockerfile
    FROM    ubuntu:trusty
    
    ADD     scripts /scripts
    
    RUN     sh /scripts/env_prepare.sh
    RUN     sh /scripts/mail.sh
    RUN     sh /scripts/env_clean.sh 
    
    EXPOSE  8433 6030 5050 8080 6060 5090 4000
    ENTRYPOINT ["sh","/home/work/open-falcon/entrypoint.sh"]
    

    3 前端


    执行init.sh脚本即可

    #!/bin/bash
    docker pull openfalcon/falcon-dashboard:v0.2.1
    mkdir data
    cd dashboard
    #read -p 'input version:' app_version
    #docker build -t openfalocon-front:$app_version .
    cd ../
    docker run -itd --name falcon-front \
            -p 8081:8081 \
            --link=falcon-back:back.falcon \
            --link=falcon-mysql:db.falcon \
            -e API_ADDR=http://back.falcon:8080/api/v1 \
            -e PORTAL_DB_HOST=db.falcon \
            -e PORTAL_DB_PORT=3306 \
            -e PORTAL_DB_USER=root \
            -e PORTAL_DB_PASS=admin123 \
            -e PORTAL_DB_NAME=falcon_portal \
            -e ALARM_DB_HOST=db.falcon \
            -e ALARM_DB_PORT=3306 \
            -e ALARM_DB_USER=root \
            -e ALARM_DB_PASS=admin123 \
            -e ALARM_DB_NAME=alarms \
            -w /open-falcon/dashboard \
            openfalcon/falcon-dashboard:v0.2.1 \
           './control startfg'
    

    5 测试
    配置
    templates


    邮件报警正常


    相关文章

      网友评论

          本文标题:linux--open-falcon--改用docker安装(2

          本文链接:https://www.haomeiwen.com/subject/rszhfktx.html