001-open-falcon的单机版安装

别等时光非礼了梦想. 提交于 2019-12-13 16:51:13

【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>>

open-falcon

每台服务器,都有安装falcon-agent,falcon-agent是一个golang开发的daemon程序,用于自发现的采集单机的各种数据和指标

单机安装

redis

mkdir /home/redis && cd /home/redis
wget http://download.redis.io/releases/redis-4.0.9.tar.gz
tar -zxvf redis-4.0.9.tar.gz
mv redis-4.0.9 redis4.0.9 && cd redis4.0.9
mkdir logs
make && make install
cat >>/home/redis/redis4.0.9/redis.conf<<EOF
bind 0.0.0.0
daemonize yes
pidfile /var/run/redis_6379.pid
logfile "/home/redis/redis4.0.9/logs/redis.log"
EOF
redis-server /home/redis/redis4.0.9/redis.conf
#连接测试
redis-cli -h 127.0.0.1 -p 6379

mysql

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum update
yum install mysql-server
chown mysql:mysql -R /var/lib/mysql
mysqld --initialize
systemctl start mysqld
mysqladmin -u root password "new_password";
mysql -u root -p

导入数据

cd /tmp/ && git clone https://github.com/open-falcon/falcon-plus.git 
cd /tmp/falcon-plus/scripts/mysql/db_schema/
mysql -h 127.0.0.1 -u root -p < 1_uic-db-schema.sql
mysql -h 127.0.0.1 -u root -p < 2_portal-db-schema.sql
mysql -h 127.0.0.1 -u root -p < 3_dashboard-db-schema.sql
mysql -h 127.0.0.1 -u root -p < 4_graph-db-schema.sql
mysql -h 127.0.0.1 -u root -p < 5_alarms-db-schema.sql
rm -rf /tmp/falcon-plus/

提示:如果是从v0.1.0升级到当前版本v0.2.0,则

mysql -h 127.0.0.1 -u root -p < 5_alarms-db-schema.sql

Go版本安装

yum install golang 或者官网下编译好的 wget https://github.com/open-falcon/falcon-plus/releases/download/v0.2.0/open-falcon-v0.2.0.tar.gz

启动后端

export FALCON_HOME=/home/work
export WORKSPACE=$FALCON_HOME/open-falcon
mkdir -p $WORKSPACE
tar -xzvf open-falcon-v0.2.0.tar.gz -C $WORKSPACE

首先确认配置文件中数据库账号密码与实际相同,否则需要修改配置文件

cd $WORKSPACE
grep -Ilr 3306  ./ | xargs -n1 -- sed -i 's/root:/root:123456/g'

启动检查

./open-falcon start
# 检查所有模块的启动状况
./open-falcon check

更多命令行操作

# ./open-falcon [start|stop|restart|check|monitor|reload] module
./open-falcon start agent

[root@jenkins open-falcon]# ./open-falcon check
        falcon-graph         UP           91373 
          falcon-hbs         UP           91383 
        falcon-judge         UP           91393 
     falcon-transfer         UP           91400 
       falcon-nodata         UP           91407 
   falcon-aggregator         UP           91414 
        falcon-agent         UP           91423 
      falcon-gateway         UP           91432 
          falcon-api         UP           91439 
        falcon-alarm         UP           91452 

For debugging , You can check $WorkDir/$moduleName/log/logs/xxx.log

安装前端

cd $WORKSPACE
git clone https://github.com/open-falcon/dashboard.git
yum install -y python-virtualenv
yum install -y python-devel
yum install -y openldap-devel
yum install -y mysql-devel
yum groupinstall "Development tools"
#创建独立的虚拟环境
cd $WORKSPACE/dashboard/
virtualenv ./env
./env/bin/pip install -r pip_requirements.txt -i https://pypi.douban.com/simple
安装过程缺少包,则安装好
wget https://files.pythonhosted.org/packages/24/6b/dd9031c446e05600b740086274a9939799f26401b8b96e124ccf71e6a9b2/Flask-Babel-0.9.tar.gz
pip install 包名

提示:pip安装 yum install python-pip -y

修改配置

dashboard的配置文件为: 'rrd/config.py',请根据实际情况修改
vim rrd/config.py
## API_ADDR 表示后端api组件的地址
API_ADDR = "http://127.0.0.1:8080/api/v1" 

## 根据实际情况,修改PORTAL_DB_*, 默认用户名为root,默认密码为""
## 根据实际情况,修改ALARM_DB_*, 默认用户名为root,默认密码为""
# portal database
# TODO: read from api instead of db
PORTAL_DB_HOST = os.environ.get("PORTAL_DB_HOST","127.0.0.1")
PORTAL_DB_PORT = int(os.environ.get("PORTAL_DB_PORT",3306))
PORTAL_DB_USER = os.environ.get("PORTAL_DB_USER","root")
PORTAL_DB_PASS = os.environ.get("PORTAL_DB_PASS","123456")
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","127.0.0.1")
ALARM_DB_PORT = int(os.environ.get("ALARM_DB_PORT",3306))
ALARM_DB_USER = os.environ.get("ALARM_DB_USER","root")
ALARM_DB_PASS = os.environ.get("ALARM_DB_PASS","123456")
ALARM_DB_NAME = os.environ.get("ALARM_DB_NAME","alarms")

开发者模式启动

./env/bin/python wsgi.py
open http://127.0.0.1:8081 in your browser.


生产中启动

bash control start

查看日志 bash control tail

开通8081端口,如果开了本机防火墙

dashbord没有默认创建任何账号包括管理账号,需要你通过页面进行注册账号。 想拥有管理全局的超级管理员账号,需要手动注册用户名为root的账号(第一个帐号名称为root的用户会被自动设置为超级管理员)。 超级管理员可以给普通用户分配权限管理。

提示:注册账号能够被任何打开dashboard页面的人注册,所以当给相关的人注册完账号后,需要去关闭注册账号功能。只需要去修改api组件的配置文件cfg.json,将signup_disable配置项修改为true,重启api即可。当需要给人开账号的时候,再将配置选项改回去,用完再关掉即可。

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!