open-falcon安装使用监控树莓派
2018-02-06 00:00
573 查看
简介
open-falcon是一款用golang和python写的监控系统,由小米启动这个项目。官方网址
http://open-falcon.org/
文档
https://book.open-falcon.org/zh_0_2/
今天我要安装的是0.2版本,监控的是树莓派。系统是阿里云ecs centos7.4
安装准备
安装redisyum install redis
启动redis服务
systemctl start redis
让redis开机自启
systemctl enable redis
安装mariadb
yum install mariadb-server
启动mariadb服务
systemctl start mariadb
让mariadb开机启动
systemctl enable mariadb
初始化mariadb密码
[root@izuf6hyujh57q98bebkndoz ~]# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!
我解释下上面每步都是做什么的
Enter current password for root (enter for none):
当你第一次运行时直接回车就好,就是问你原来的root密码是什么,因为第一次运行,所以直接回车就好
Set root password? [Y/n] y
问你是不是设置root密码
Remove anonymous users? [Y/n] y
问你是不是移除匿名用户
Disallow root login remotely? [Y/n] y
禁止root远程登录
Remove test database and access to it? [Y/n] y
移除test数据库
Reload privilege tables now? [Y/n] y
重新加载权限表
最后运行
mysql -uroot -p登入mariadb验证下
导入open-falcon数据表
安装git
yum install git
下载falcon-plus里面有open-falcon的数据库导入就好
git clone https://github.com/open-falcon/falcon-plus.git[/code] 进入下面这个目录,然后执行下面命令cd /root/falcon-plus/scripts/mysql/db_schemamysql -h 127.0.0.1 -u root -p < 1_uic-db-schema.sqlmysql -h 127.0.0.1 -u root -p < 2_portal-db-schema.sqlmysql -h 127.0.0.1 -u root -p < 3_dashboard-db-schema.sqlmysql -h 127.0.0.1 -u root -p < 4_graph-db-schema.sqlmysql -h 127.0.0.1 -u root -p < 5_alarms-db-schema.sql
之后你会发现数据库中多出了下面这些数据库+--------------------+ | Database | +--------------------+ | information_schema | | alarms | | dashboard | | falcon_portal | | graph | | mysql | | performance_schema | | uic | +--------------------+
下载open-falcon的安装包
如果你是其他平台的比如arm或是32位系统的要自己编译下,我就直接使用二进制包安装好了wget https://github.com/open-falcon/falcon-plus/releases/download/v0.2.1/open-falcon-v0.2.1.tar.gz[/code] 因为网速较慢所以建议本地挂代理下载之后上传到服务器上启动后端
因为是编译好的包,所以我们就不需要各种复杂的设置了,直接启动就好了
我把所有文件放在home文件夹中work下mkdir -p /home/work/open-falcontar -zxvf open-falcon-v0.2.1.tar.gz -C /home/work/open-falcon/
修改配置文件,其实就是修改所有组件的cfg.json的mariadb密码,我的意思是如果这个组件用到mariadb的话
首先修改aggregator的vim /home/work/open-falcon/aggregator/config/cfg.json
改为"database": { "addr": "root:Yuncan1803@tcp(127.0.0.1:3306)/falcon_portal?loc=Local&parseTime=true", "idle": 10, "ids": [1, -1], "interval": 55 },
注意第二行Yuncan1803是密码,root是用户名其他的都一样
接着修改graph的vim graph/config/cfg.json"db": { "dsn": "root:Yuncan1803@tcp(127.0.0.1:3306)/graph?loc=Local&parseTime=true", "maxIdle": 4 },
修改hbs的vim hbs/config/cfg.json{ "debug": true, "database": "root:Yuncan1803@tcp(127.0.0.1:3306)/falcon_portal?loc=Local&parseTime=true", "hosts": "", "maxConns": 20, "maxIdle": 15, "listen": ":6030", "trustable": [""], "http": { "enabled": true, "listen": "0.0.0.0:6031" } }
修改nodata的vim nodata/config/cfg.json"config": { "enabled": true, "dsn": "root:Yuncan1803@tcp(127.0.0.1:3306)/falcon_portal?loc=Local&parseTime=true&wait_timeout=604800", "maxIdle": 4 },
修改api的vim api/config/cfg.json"db": { "falcon_portal": "root:Yuncan1803@tcp(127.0.0.1:3306)/falcon_portal?charset=utf8&parseTime=True&loc=Local", "graph": "root:Yuncan1803@tcp(127.0.0.1:3306)/graph?charset=utf8&parseTime=True&loc=Local", "uic": "root:Yuncan1803@tcp(127.0.0.1:3306)/uic?charset=utf8&parseTime=True&loc=Local", "dashboard": "root:Yuncan1803@tcp(127.0.0.1:3306)/dashboard?charset=utf8&parseTime=True&loc=Local", "alarms": "root:Yuncan1803@tcp(127.0.0.1:3306)/alarms?charset=utf8&parseTime=True&loc=Local", "db_bug": true },
修改alarm的vim alarm/config/cfg.json"falcon_portal": { "addr": "root:Yuncan1803@tcp(127.0.0.1:3306)/alarms?charset=utf8&loc=Asia%2FChongqing", "idle": 10, "max": 100 },
最好,终于他妈最后了,启动后端./open-falcon start
你可以用下面的命令检查所有组件的状态./open-falcon check[root@izuf6hyujh57q98bebkndoz open-falcon]# ./open-falcon check falcon-graph UP 27849 falcon-hbs UP 27858 falcon-judge UP 27868 falcon-transfer UP 27876 falcon-nodata UP 27883 falcon-aggregator UP 27891 falcon-agent UP 27901 falcon-gateway UP 27908 falcon-api UP 27915 falcon-alarm UP 27929
更多命令的用法./open-falcon [start|stop|restart|check|monitor|reload] module
比如./open-falcon start agent
这样就启动了agent./open-falcon check这个是检查组件状态的
所有组件的日志都在组件目录下logs目录中安装前端
首先把代码clone下来cd /home/work/open-falcongit clone https://github.com/open-falcon/dashboard.git[/code] 安装依赖包yum install -y python-virtualenvyum install -y python-develyum install -y openldap-develyum install -y mysql-develyum groupinstall "Development tools"
新建虚拟环境cd dashboardvirtualenv ./env
安装python依赖./env/bin/pip install -r pip_requirements.txt
修改配置vim rrd/config.pyPORTAL_DB_PASS = os.environ.get("PORTAL_DB_PASS","Yuncan1803")ALARM_DB_PASS = os.environ.get("ALARM_DB_PASS","Yuncan1803")
在生产环境启动[root@izuf6hyujh57q98bebkndoz dashboard]# bash control start falcon-dashboard started..., pid=8190
下面是一些其他操作
开发者模式启动./env/bin/python wsgi.py
停止bash control stop
查看日志bash control tail账号管理
首先我们用ip:8081访问open-falcon,接着要知道的是falcon默认没有任何用户,新建的第一个root用户就是管理员,为了安全你可以修改api组件的配置文件vim api/config/cfg.json
中的"signup_disable": false,
设置为true就可以禁止注册了树莓派上安装
这个肯定是要编译的了,所以先下载golang安装
因为实在树莓派下,所以golang要编译安装,但是现在最新版本的golang都是用go编译的,所以因为我们系统中没有go,只能先安装1.4版本的c语言版本go,之后安装最新版本的go
首先下载wget https://dl.google.com/go/go1.4.3.src.tar.gz[/code] 解压tar -zxvf go1.4.3.src.tar.gz
编译cd go/src./make.bash
因为是树莓派所以编译肯定花点时间
移动go到/root/go1.4mv go /root/go1.4
/root/go1.4是默认$GOROOT_BOOTSTRAP的值
接着下载最新版本的gowget https://dl.google.com/go/go1.9.3.src.tar.gz[/code] 解压tar -zxvf go1.9.3.src.tar.gz
编译cd go/src./make.bash
编译好后接着移动到/usr/local/目录下mv go /usr/local
设置环境变量vim ~/.zshrcexport GOROOT=/usr/local/go export GOPATH=/root/go export PATH=$PATH:GOROOT/bin
使环境变量生效source ~/.zshrc
接着编译安装open-falcon的agent
新建一个目录下载源码mkdir -p $GOPATH/src/github.com/open-falconcd $GOPATH/src/github.com/open-falcon
下载源码git clone https://github.com/open-falcon/falcon-plus.git[/code] 进入agent源码目录cd falcon-plus/modules/agent
下载依赖go get
编译./control build
接着把agent这个文件夹放入/usr/loca/目录mv agent /usr/local
启动agent生成配置文件cd /usr/local/agent./control start
编辑配置文件{ "debug": true, "hostname": "raspberry", "ip": "", "plugin": { "enabled": false, "dir": "./plugin", "git": "https://github.com/open-falcon/plugin.git", "logs": "./logs" }, "heartbeat": { "enabled": true, "addr": "ip:6030", "interval": 60, "timeout": 1000 }, "transfer": { "enabled": true, "addrs": [ "ip:8433" ], "interval": 60, "timeout": 1000 }, "http": { "enabled": true, "listen": ":1988", "backdoor": false }, "collector": { "ifacePrefix": ["eth", "em"], "mountPoint": [] }, "default_tags": { }, "ignore": { "cpu.busy": true, "df.bytes.free": true, "df.bytes.total": true, "df.bytes.used": true, "df.bytes.used.percent": true, "df.inodes.total": true, "df.inodes.free": true, "df.inodes.used": true, "df.inodes.used.percent": true, "mem.memtotal": true, "mem.memused": true, "mem.memused.percent": true, "mem.memfree": true, "mem.swaptotal": true, "mem.swapused": true, "mem.swapfree": true } }
重启./control restart
和zabbix比起来这个配置真的少了很多,除了HOSTNAME以外就是ip要改,而且挺简单的,dashboard上也不用设置,等会就会有数据出来
欢迎关注Bboysoul的博客www.bboysoul.com
Have Fun
相关文章推荐
- 小米开源监控系统Open-Falcon安装使用笔记
- openfalcon 使用 swcollector 监控交换机等网络设备 配合着
- Open-Falcon第四步安装Graph(小米开源互联网企业级监控系统)
- 小米开源监控open-falcon安装
- centos下open-falcon监控系统的安装配置
- 4_小米监控Open-Falcon 前端安装
- open-falcon小米监控安装部署
- Open-Falcon第七步安装报警模块(小米开源互联网企业级监控系统)
- open-falcon小米监控安装部署
- Open-Falcon第二步安装绘图组件Transfer(小米开源互联网企业级监控系统)
- 5_小米监控Open-Falcon 安装-Agent
- 使用open-falcon监控Nginx
- 3_小米监控Open-Falcon 后端服务安装并启动
- Open-Falcon第六步安装Dashboard(小米开源互联网企业级监控系统)
- Open-Falcon install script(Open-Falcon监控一键安装脚本)
- 7_小米监控Open-Falcon安装绘图数据的组件- Graph
- open-falcon开源监控使用
- Open-Falcon安装使用笔记
- Open-Falcon第五步安装Query(小米开源互联网企业级监控系统)
- Open-Falcon第三步安装Agent (小米开源互联网企业级监控系统)