如何从OpenFalcon v0.1 平滑升级到 FalconPlus v0.2?

新增数据库表

  1. cd $GOPATH/src/github.com/open-falcon/falcon-plus/scripts/mysql/db_schema/
  2. mysql -h 127.0.0.1 -u root -p < 5_alarms-db-schema.sql

NOTE:

  1. falcon-plus 如何编译,请参考 falcon-plus readme ;
  2. 或者直接下载官方编译好的二进制包

现在正式开始升级之旅:)

1. 升级agent

用falcon-plus agent 二进制文件替换掉v0.1版本 agent 的二进制,同时注意修改agent的配置文件:

  1. diff --git v0.1/agent/cfg.example.json v0.2/agent/cfg.example.json
  2. --- v0.1
  3. +++ v0.2
  4. "backdoor": false
  5. },
  6. "collector": {
  7. - "ifacePrefix": ["eth", "em"]
  8. + "ifacePrefix": ["eth", "em"],
  9. + "mountPoint": []
  10. + },
  11. + "default_tags": {
  12. },
  13. "ignore": {
  14. "cpu.busy": true,

2. 升级transfer

用falcon-plus transfer 二进制文件替换掉v0.1版本 transfer 的二进制即可,配置文件无需变化。

3. 升级graph

用falcon-plus graph 二进制文件替换掉v0.1版本 graph 的二进制即可,配置文件无需变化。

4. 用api模块来代替query模块

  1. 停止query的运行;
  2. make pack得到的 tar.gz 包中解压得到 api 及其配置文件,检查配置文件如下,然后启动api组件即可。
  1. {
  2. "log_level": "debug",
  3. "db": {
  4. "faclon_portal": "root:@tcp(127.0.0.1:3306)/falcon_portal?charset=utf8&parseTime=True&loc=Local",
  5. "graph": "root:@tcp(127.0.0.1:3306)/graph?charset=utf8&parseTime=True&loc=Local",
  6. "uic": "root:@tcp(127.0.0.1:3306)/uic?charset=utf8&parseTime=True&loc=Local",
  7. "dashboard": "root:@tcp(127.0.0.1:3306)/dashboard?charset=utf8&parseTime=True&loc=Local",
  8. "alarms": "root:@tcp(127.0.0.1:3306)/alarms?charset=utf8&parseTime=True&loc=Local",
  9. "db_bug": true
  10. },
  11. "graphs": {
  12. "cluster": {
  13. "graph-00": "127.0.0.1:6070"
  14. },
  15. "max_conns": 100,
  16. "max_idle": 100,
  17. "conn_timeout": 1000,
  18. "call_timeout": 5000,
  19. "numberOfReplicas": 500
  20. },
  21. "metric_list_file": "./api/data/metric",
  22. "web_port": ":8080",
  23. "access_control": true,
  24. "salt": "",
  25. "skip_auth": false,
  26. "signup_disable": false,
  27. "default_token": "default-token-used-in-server-side",
  28. "gen_doc": false,
  29. "gen_doc_path": "doc/module.html"
  30. }

其中db部分为数据库连接信息相关,按需修改即可;graphs部分为后端的graph列表信息,可以和v0.1版本的query cfg.json部分内容保持一致即可。

5. 升级hbs

用falcon-plus hbs 二进制文件替换掉v0.1版本 hbs 的二进制即可,配置文件无需变化。

6. 升级judge

用falcon-plus judge 二进制文件替换掉v0.1版本 judge 的二进制即可,配置文件无需变化。

7. 升级alarm

用falcon-plus alarm 二进制文件替换掉v0.1版本 alarm 的二进制,同时注意修改alarm 的配置文件:

  1. diff --git v0.1/alarm/cfg.example.json v0.2/alarm/cfg.example.json
  2. --- v0.1/alarm/cfg.example.json
  3. +++ v0.2/alarm/cfg.example.json
  4. @@ -1,36 +1,47 @@
  5. {
  6. - "debug": true,
  7. - "uicToken": "",
  8. + "log_level": "debug",
  9. "http": {
  10. "enabled": true,
  11. "listen": "0.0.0.0:9912"
  12. },
  13. - "queue": {
  14. - "sms": "/sms",
  15. - "mail": "/mail"
  16. - },
  17. "redis": {
  18. "addr": "127.0.0.1:6379",
  19. "maxIdle": 5,
  20. @@@@@@@@@@
  21. + "userIMQueue": "/queue/user/im",
  22. "userSmsQueue": "/queue/user/sms",
  23. "userMailQueue": "/queue/user/mail"
  24. },
  25. - "database": "root:@tcp(127.0.0.1:3306)/alarm?loc=Local&parseTime=true",
  26. - "maxIdle": 100,
  27. "api": {
  28. - "portal": "http://falcon.example.com",
  29. - "uic": "http://uic.example.com",
  30. - "links": "http://link.example.com"
  31. + "im": "http://127.0.0.1:10086/wechat",
  32. + "sms": "http://127.0.0.1:10086/sms",
  33. + "mail": "http://127.0.0.1:10086/mail",
  34. + "dashboard": "http://127.0.0.1:8081",
  35. + "plus_api":"http://127.0.0.1:8080",
  36. + "plus_api_token": "default-token-used-in-server-side"
  37. + },
  38. + "falcon_portal": {
  39. + "addr": "root:@tcp(127.0.0.1:3306)/alarms?charset=utf8&loc=Asia%2FChongqing",
  40. + "idle": 10,
  41. + "max": 100
  42. + },
  43. + "worker": {
  44. + "im": 10,
  45. + "sms": 10,
  46. + "mail": 50
  47. + },
  48. + "housekeeper": {
  49. + "event_retention_days": 7,
  50. + "event_delete_batch": 100
  51. }
  52. }

NOTE: v0.2版本中,去除了sender模块,将sender模块的功能,合并到了alarm组件中,降低了用户的配置和维护成本; 同时增加了对微信的发送支持。

8. 升级aggregator

用falcon-plus aggregator 二进制文件替换掉v0.1版本 aggregator 的二进制,同时注意修改aggregator 的配置文件:

  1. diff --git v0.1/aggregator/cfg.example.json v0.2/aggregator/cfg.example.json
  2. --- v0.1/aggregator/cfg.example.json
  3. +++ v0.2/aggregator/cfg.example.json
  4. @@@@@@@@@@@
  5. "interval": 55
  6. },
  7. "api": {
  8. - "hostnames": "http://127.0.0.1:5050/api/group/%s/hosts.json",
  9. - "push": "http://127.0.0.1:6060/api/push",
  10. - "graphLast": "http://127.0.0.1:9966/graph/last"
  11. + "connect_timeout": 500,
  12. + "request_timeout": 2000,
  13. + "plus_api": "http://127.0.0.1:8080",
  14. + "plus_api_token": "default-token-used-in-server-side",
  15. + "push_api": "http://127.0.0.1:1988/v1/push"
  16. }
  17. }

NOTE: aggregator 直接和falcon-plus 的api组件进行交互,即plus_api所配置的地址。

9. 升级nodata

用falcon-plus nodata 二进制文件替换掉v0.1版本 nodata 的二进制,同时注意修改nodata 的配置文件:

  1. diff --git v0.1/nodata/cfg.example.json v0.2/nodata/cfg.example.json
  2. --- a/../nodata/cfg.example.json
  3. +++ b/modules/nodata/cfg.example.json
  4. @@ -4,10 +4,11 @@
  5. "enabled": true,
  6. "listen": "0.0.0.0:6090"
  7. },
  8. - "query":{
  9. - "connectTimeout": 5000,
  10. - "requestTimeout": 30000,
  11. - "queryAddr": "127.0.0.1:9966"
  12. + "plus_api":{
  13. + "connectTimeout": 500,
  14. + "requestTimeout": 2000,
  15. + "addr": "http://127.0.0.1:8080",
  16. + "token": "default-token-used-in-server-side"
  17. },
  18. "config": {
  19. "enabled": true,
  20. @@ -21,13 +22,9 @@
  21. },
  22. "sender":{
  23. "enabled": true,
  24. - "connectTimeout": 5000,
  25. - "requestTimeout": 30000,
  26. + "connectTimeout": 500,
  27. + "requestTimeout": 2000,
  28. "transferAddr": "127.0.0.1:6060",
  29. - "batch": 500,
  30. - "block": {
  31. - "enabled": false,
  32. - "threshold": 32
  33. - }
  34. + "batch": 500
  35. }
  36. }

NOTE: nodata不再访问query组件了, 而是直接和falcon-plus 的api组件进行交互,即plus_api所配置的信息。

10. 升级gateway

用falcon-plus gateway 二进制文件替换掉v0.1版本 gateway 的二进制即可,配置文件无需变化。

11. 开启全新的统一前端模块

  1. diff --git a/rrd/config.py b/rrd/config.py
  2. index e9e500d..d57b1c7 100755
  3. --- a/rrd/config.py
  4. +++ b/rrd/config.py
  5. @@ -1,34 +1,50 @@
  6. #-*-coding:utf8-*-
  7. import os
  8. +LOG_LEVEL = os.environ.get("LOG_LEVEL",'DEBUG')
  9. +SECRET_KEY = os.environ.get("SECRET_KEY","secret-key")
  10. +PERMANENT_SESSION_LIFETIME = os.environ.get("PERMANENT_SESSION_LIFETIME",3600 * 24 * 30)
  11. +SITE_COOKIE = os.environ.get("SITE_COOKIE","open-falcon-ck")
  12. -#-- dashboard db config --
  13. -DASHBOARD_DB_HOST = "127.0.0.1"
  14. -DASHBOARD_DB_PORT = 3306
  15. -DASHBOARD_DB_USER = "root"
  16. -DASHBOARD_DB_PASSWD = ""
  17. -DASHBOARD_DB_NAME = "dashboard"
  18. +# Falcon+ API
  19. +API_ADDR = os.environ.get("API_ADDR","http://127.0.0.1:8080/api/v1")
  20. -#-- graph db config --
  21. -GRAPH_DB_HOST = "127.0.0.1"
  22. -GRAPH_DB_PORT = 3306
  23. -GRAPH_DB_USER = "root"
  24. -GRAPH_DB_PASSWD = ""
  25. -GRAPH_DB_NAME = "graph"
  26. +# portal database
  27. +# TODO: read from api instead of db
  28. +PORTAL_DB_HOST = os.environ.get("PORTAL_DB_HOST","127.0.0.1")
  29. +PORTAL_DB_PORT = int(os.environ.get("PORTAL_DB_PORT",3306))
  30. +PORTAL_DB_USER = os.environ.get("PORTAL_DB_USER","root")
  31. +PORTAL_DB_PASS = os.environ.get("PORTAL_DB_PASS","")
  32. +PORTAL_DB_NAME = os.environ.get("PORTAL_DB_NAME","falcon_portal")
  33. -#-- app config --
  34. -DEBUG = True
  35. -SECRET_KEY = "secret-key"
  36. -SESSION_COOKIE_NAME = "open-falcon"
  37. -PERMANENT_SESSION_LIFETIME = 3600 * 24 * 30
  38. -SITE_COOKIE = "open-falcon-ck"
  39. +# alarm database
  40. +# TODO: read from api instead of db
  41. +ALARM_DB_HOST = os.environ.get("ALARM_DB_HOST","127.0.0.1")
  42. +ALARM_DB_PORT = int(os.environ.get("ALARM_DB_PORT",3306))
  43. +ALARM_DB_USER = os.environ.get("ALARM_DB_USER","root")
  44. +ALARM_DB_PASS = os.environ.get("ALARM_DB_PASS","")
  45. +ALARM_DB_NAME = os.environ.get("ALARM_DB_NAME","alarms")
  46. -#-- query config --
  47. -QUERY_ADDR = "http://127.0.0.1:9966"
  48. +# ldap config
  49. +LDAP_ENABLED = os.environ.get("LDAP_ENABLED",False)
  50. +LDAP_SERVER = os.environ.get("LDAP_SERVER","ldap.forumsys.com:389")
  51. +LDAP_BASE_DN = os.environ.get("LDAP_BASE_DN","dc=example,dc=com")
  52. +LDAP_BINDDN_FMT = os.environ.get("LDAP_BINDDN_FMT","uid=%s,dc=example,dc=com")
  53. +LDAP_SEARCH_FMT = os.environ.get("LDAP_SEARCH_FMT","uid=%s")
  54. +LDAP_ATTRS = ["cn","mail","telephoneNumber"]
  55. +LDAP_TLS_START_TLS = False
  56. +LDAP_TLS_CACERTDIR = ""
  57. +LDAP_TLS_CACERTFILE = "/etc/openldap/certs/ca.crt"
  58. +LDAP_TLS_CERTFILE = ""
  59. +LDAP_TLS_KEYFILE = ""
  60. +LDAP_TLS_REQUIRE_CERT = True
  61. +LDAP_TLS_CIPHER_SUITE = ""
  62. -BASE_DIR = "/home/work/open-falcon/dashboard/"
  63. -LOG_PATH = os.path.join(BASE_DIR,"log/")
  64. +# portal site config
  65. +MAINTAINERS = ['root']
  66. +CONTACT = 'root@open-falcon.org'