OceanBase 監控工具 OBAgent

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"作者簡介:海芊,一個對技術充滿熱情的文檔工程師。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"背景","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"運維 OceanBase 涉及到很多相關的變量和參數。實際生產中,如果只靠單一的黑屏工具查看這些參數的話,不僅會流程繁瑣,而且查看結果也不夠直觀,這就降低了我們的工作效率。此外,如果想查詢一些表達式,也不是很方便。基於這種背景,OceanBase 監控工具 OBAgent 應運而生。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"OBAgent 是一個監控採集框架。OBAgent 支持推、拉兩種數據採集模式,可以滿足不同的應用場景。OBAgent 默認支持的插件包括主機數據採集、OceanBase 數據庫指標的採集、監控數據標籤處理和 Prometheus 協議的 HTTP 服務。要使 OBAgent 支持其他數據源的採集,或者自定義數據的處理流程,您只需要開發對應的插件即可。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"OBAgent 是一個開源的項目,感興趣的小夥伴可以去 GitHub 看看項目代碼。更多關於 OBAgent 的信息,參考 ","attrs":{}},{"type":"link","attrs":{"href":"https://github.com/oceanbase/obagent/tree/master/docs","title":"","type":null},"content":[{"type":"text","text":"OBAgent ","attrs":{}}]},{"type":"text","text":"文檔。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"如何使用","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"介紹完 OBAgent 的功能,接下來我們聊聊如何使用它。要使用 OBAgent,我們首先要把這個進程啓動起來。然後再使用 Prometheus 接入,雖然 Prometheus 是個可選的步驟,但是使用起來還是很方便的,這裏我們也介紹一下。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"部署 OBAgent 有兩種方式,一種是手動部署,一種是使用 OBD 部署。手動部署 OBAgent 需要配置 KV、monagent 和 Prometheus (可選,根據你的實際需求決定)。更多信息,參考 ","attrs":{}},{"type":"link","attrs":{"href":"https://github.com/oceanbase/obagent/tree/master/docs/config-reference","title":"","type":null},"content":[{"type":"text","text":"配置文件文檔","attrs":{}}]},{"type":"text","text":"。相比之下,使用 OceanBase 開源軟件的安裝部署工具 OBD 部署就要簡單很多。只要一個 OBAgent 配置文件就能把服務啓起來。並且,OBD 還會根據你的實際情況自動生成一份 Prometheus 的配置文件,還會把 Prometheus 的規則寫好。你可以使用默認的規則,也可以根據需要對規則做出調整。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"部署 OBAgent","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"接下來我們使用 OBD,一起部署 OBAgent 服務。OBAgent 可以跟 OceanBase 集羣同時啓動,也可以先啓動一個 ObceanBase 集羣,再啓動 OBAgent。我在啓動 OBAgent 之前已經有了一個 ObceanBase 集羣,因此我單獨啓動 OBAgent 就可以了。我的集羣信息如下:","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/8f/8f4224440d329914c4468368c0ce864e.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"使用 OBD 啓動 OBAgent 的示例配置文件參考 ","attrs":{}},{"type":"link","attrs":{"href":"https://github.com/oceanbase/obdeploy/blob/master/example/obagent/obagent-only-example.yaml","title":"","type":null},"content":[{"type":"text","text":"這裏","attrs":{}}]},{"type":"text","text":",部署文檔參考","attrs":{}},{"type":"link","attrs":{"href":"https://github.com/oceanbase/obagent/blob/master/docs/install-and-deploy/deploy-obagent-with-obd.md","title":"","type":null},"content":[{"type":"text","text":" 這裏","attrs":{}}]},{"type":"text","text":"。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"OBAgent 的以下配置字段必須要跟 OceanBase 一樣:","attrs":{}}]},{"type":"codeblock","attrs":{"lang":"text"},"content":[{"type":"text","text":"obagent:\n global:\n # Username for HTTP authentication. The default value is admin.\n http_basic_auth_user: admin\n # Password for HTTP authentication. The default value is root.\n http_basic_auth_password: root\n # Username for debug service. The default value is admin.\n pprof_basic_auth_user: admin\n # Password for debug service. The default value is root.\n pprof_basic_auth_password: root\n \n # 以下配置必須與 OceanBase 數據庫一致\n # Monitor username for OceanBase Database. The user must have read access to OceanBase Database as a system tenant. The default value is root.\n monitor_user: root\n # Monitor password for OceanBase Database. The default value is empty. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. The value is the same as the root_password in oceanbase-ce.\n monitor_password: \n # The SQL port for observer. The default value is 2881. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. The value is the same as the mysql_port in oceanbase-ce.\n sql_port: 2881\n # The RPC port for observer. The default value is 2882. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. The value is the same as the rpc_port in oceanbase-ce.\n rpc_port: 2882\n # Cluster name for OceanBase Database. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. The value is the same as the appname in oceanbase-ce.\n cluster_name: obcluster\n # Cluster ID for OceanBase Database. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. The value is the same as the cluster_id in oceanbase-ce.\n cluster_id: 1\n # Zone name for your observer. The default value is zone1. When a depends exists, OBD gets this value from the oceanbase-ce of the depends. The value is the same as the zone name in oceanbase-ce.\n zone_name: zone1\n # Monitor status for OceanBase Database. Active is to enable. Inactive is to disable. The default value is active. When you deploy an cluster automatically, OBD decides whether to enable this parameter based on depends.","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"然後使用以下命令啓動 OBAgent:","attrs":{}}]},{"type":"codeblock","attrs":{"lang":"text"},"content":[{"type":"text","text":"obd cluster deploy only-obagent -c only-obagent.yaml\nobd cluster start only-obagent","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"使用以下命令確認進程是否啓動成功:","attrs":{}}]},{"type":"codeblock","attrs":{"lang":"text"},"content":[{"type":"text","text":"ps -ef | grep monagent\nadmin 3415 3373 0 19:57 pts/0 00:00:00 grep --color=auto monagent\nadmin 28112 1 15 18:55 ? 00:09:51 /home/admin/obagent/bin/monagent -c conf/monagent.yaml","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"啓動成功之後就可以查看相關的指標了:","attrs":{}}]},{"type":"codeblock","attrs":{"lang":"text"},"content":[{"type":"text","text":"# 查看主機指標\ncurl --user admin:root http://172.30.199.47:8088/metrics/node/host\n# 再查看ob基本指標\ncurl --user admin:root http://172.30.199.47:8088/metrics/ob/basic\n# 也可以查看指定指標\ncurl --user admin:root http://172.30.199.47:8088/metrics/ob/basic | grep ob_cache_size_bytes","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"其中,主機指標的返回結果如下圖:","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/18/18fdce8e9b3beaf8d82898ede140be65.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"部署 Prometheus(可選)","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"接下來我們再試試 Prometheus,大家自行下載,相信都會。使用 OBD 部署 OBAgent 會自動生成一份 Prometheus 配置文件,我們要把目標機器上的配置文件複製到中控機器。","attrs":{}}]},{"type":"codeblock","attrs":{"lang":"text"},"content":[{"type":"text","text":"# 配置文件路徑\n$obagent_working_directory/conf/prometheus_config/ ","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"來到 Prometheus 的安裝目錄,現在啓動它:","attrs":{}}]},{"type":"codeblock","attrs":{"lang":"text"},"content":[{"type":"text","text":"cd prometheus-2.30.3.linux-amd64\n./prometheus --config.file=../prometheus_config/prometheus.yaml","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"打開瀏覽器,輸入以下網址","attrs":{}}]},{"type":"codeblock","attrs":{"lang":"text"},"content":[{"type":"text","text":"http://your_ip:9090/","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"就可以用 Prometheus 查看 OceanBase 的指標了。alerts 告警,用來報告異常情況:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/48/4817672e6631da9e4c84168e78a61797.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"接下是 Status,可以看到 Rules 下面的配置規則,當指標超出規則時就會告警。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/eb/eb7c1bb59831fedfa578fd7fa43b78a8.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"現在我們嘗試查詢一個表達式,以當前活躍會話數爲例,可以看到具體時間的活躍會話數:","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/3e/3e4548063573070c40aad34b389cc9b6.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"其他的功能請大家自行探索。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"參與更多技術交流,請至 OceanBase 社區版","attrs":{}},{"type":"link","attrs":{"href":"https://open.oceanbase.com/answer","title":"","type":null},"content":[{"type":"text","text":"【問答區】","attrs":{}}]},{"type":"text","text":"。","attrs":{}}]}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章