Java 開發、全自研的開源監控組件來了,讓 openGauss 更香

{"type":"doc","content":[{"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":"2011 年,馬克·安德森(網景公司創始人、硅谷著名風險投資人)留下一句經典名言——軟件正在吞噬世界。這句看似聳人聽聞的論斷,現今早已爲人習以爲常。"},{"type":"text","marks":[{"type":"strong"}],"text":"過去 10 年,在互聯網浪潮下,IT 技術飛速發展,軟件、開源、雲計算、雲原生掀起一波又一波的高潮,創新技術不斷湧現。"}]},{"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":"今天,以 kubernetes 爲代表的雲原生技術正在吞噬世界。隨着 Kubernetes 成爲容器編排領域的事實標準,Prometheus 也擊敗了度量領域以 Zabbix 爲代表的衆多前輩,成爲雲原生時代容器監控的事實標準。"}]},{"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 使用 Pull 的方式去搜集被監控對象的監控指標數據,然後,再把這些數據保存在一個 TSDB (時間序列數據庫)中,以便後續可以按照時間進行檢索。但是,由於大多數監控無法直接提供監控接口,所以 exporter 誕生。exporter 是一個採集監控數據並通過 Prometheus 監控規範對外提供數據的組件。"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"業務之痛"}]},{"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 提供的官方 exporter,也有第三方 exporter。正是 exporter 讓華夏銀行基礎技術研究團隊眼前一亮,因爲他們缺乏一款針對 openGauss 數據庫的監控組件。"}]},{"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":"據華夏銀行基礎技術研究團隊負責人胡捷介紹,華夏銀行從去年開始在銀行內推廣應用 openGauss 數據庫,效果不錯。"}]},{"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":"衆所周知,銀行金融服務的性能和穩定性至關重要,其中,交易數據庫服務的可用性、可靠性、穩定性又是核心環節。"},{"type":"text","marks":[{"type":"strong"}],"text":"openGauss 具備優異的性能,滿足海量交易處理、快速穩定響應的要求;結合單元化部署模式,可以實現高效靈活的橫向擴展和業務支撐。"}]},{"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":"胡捷說:“openGauss 是一款成長型開源數據庫。一方面,它比較新,深度融合華爲在數據庫領域多年的經驗,有很多優勢,比如高性能、高可用、高安全、易運維。另一方面,它還有進一步成長的空間,依託 openGauss 開源社區,大家可以一起來完善產品,推動它向前發展。”"}]},{"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 爲核心的完備監控體系必不可少。但是,他們卻沒有一款合適的監控組件從 openGauss 數據庫獲取監控信息並傳送給 Prometheus。"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"走上自研之路"}]},{"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":"如何獲得這個監控組件成爲擺在胡捷團隊面前的重大問題。"}]},{"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":"由於市面上找不到合適的產品,所以"},{"type":"text","marks":[{"type":"strong"}],"text":"自研"},{"type":"text","text":"成爲華夏銀行基礎技術研究團隊的唯一出路。"}]},{"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":"此時,外界也傳來一個好消息。2021 信創“大比武”鯤鵬基礎軟件開發賽道啓動,它由信息技術應用創新工作委員會指導,華爲主辦,重慶鯤鵬創新中心、北京鯤鵬聯合創新中心、openEuler 開源社區、openGauss 開源社區及 openLooKeng 開源社區共同承辦。"}]},{"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":"胡捷團隊打算做的事與大賽主題非常契合,所以積極報名參加了大賽。"}]},{"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":"據悉,本次大賽分設三個賽道:openEuler 賽道、openGauss 賽道和 openLooKeng 賽道。胡捷團隊選擇了 openGauss 賽道,他說:“選擇這個賽道可以把比賽跟我們的實際應用結合起來,一方面,參加比賽,檢驗我們產品方案的技術水平,並瞭解業界的技術進展;另一方面,豐富我們自己的產品應用。可以說,這是一個雙贏的選擇。”"}]},{"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":"在 openGauss 賽道,他們的賽題是“提供 Prometheus exporter 用於採集和監控 openGauss 服務的指標及數據”。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https:\/\/static001.geekbang.org\/infoq\/7f\/7f324fd91ab815e0e0dc229afaf86647.jpeg","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":"center","origin":null},"content":[{"type":"text","text":"華夏銀行基礎技術研究團隊"}]},{"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":"從 7 月 14 日啓動報名到 8 月 31 日作品提交截止,時間不足兩個月。在瞭解賽題後,他們迅速行動,明確了項目團隊成員和個人職責。具體說來,胡捷任項目經理,陳曦爲需求分析,設計實現由陳偉擔任,王輝負責用戶測試,系統運維則落在田亮身上。時間緊、壓力大、節奏快,這爲整個團隊帶來極大挑戰。"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"站在巨人的肩膀上"}]},{"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":"項目伊始,團隊基於希臘神話給項目取名 Hermes。據瞭解,Hermes 是古希臘神話中的商人、旅者、小偷和畜牧之神,也是衆神的使者。之所以取這個名字,寓意它快速、準確地從 openGauss 數據庫獲取監控信息並傳送給 Prometheus。"}]},{"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","marks":[{"type":"strong"}],"text":"作爲“使者”,Hermes 一方面對接 Prometheus,另一方面,連接 openGauss 數據庫。"}]},{"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":"據悉,openGauss 數據庫把所有監控信息都收集起來,存放在自己的數據表中。“我們使用時就可以非常方便地直接引用這些數據”。"}]},{"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":"之後,就需要作爲採集器的 Hermes 登場。"}]},{"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":"Hermes 從 openGauss 數據庫相應的表、視圖和函數中直接採集監控指標,包括 SQL 執行計數、基本運行信息、鎖、會話、同步、活躍鏈接數、快照、複製、檢查點、衝突、寫進程等。"}]},{"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":"獲取到這些監控指標後,Hermes 將獲取到的數據包封裝爲 Prometheus 所需要的格式。最後,把監控信息傳送給 Prometheus。"}]},{"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":"陳偉說:“我們的工作相當於站在一個巨人的肩膀上,把這個數據拿出來,經過合理的整合,然後再發送給後端使用。如此,節省了我們做採集數據的巨大工作量。因爲數據採集最重要的一個地方和最耗工序的一個地方就是如何收集數據,而現在 openGauss 數據庫把監控數據整理好了,我們只需要提取出來,補齊拼圖的最後一塊即可。”"}]},{"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":"這個過程中,他深切體會到:openGauss 是關係型數據庫的代表,深度融合了華爲在數據庫領域多年的內核經驗,在架構、事務、存儲引擎、優化器及 ARM 架構上進行了適配與優化,能夠滿足銀行業企業級場景需求。同時,其語法與傳統 Oracle、MySQL 數據庫兼容度較高,非常易於開展數據庫國產化改造工作。"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"開源監控組件 Hermes"}]},{"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":"據陳偉介紹,他們在產品設計上,"},{"type":"text","marks":[{"type":"strong"}],"text":"狠下功夫,做到代碼精簡"},{"type":"text","text":"。在充分分析採集需求的基礎上,進行共性歸納和抽取,然後在模型設計時,進行抽象,讓公共代碼沉澱在基類或接口上。這樣,對每一個具體採集需求來說,代碼量大大減少。"}]},{"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":"作爲項目設計實現者,陳偉說:“不管怎樣實現這個組件,核心一定要滿足"},{"type":"text","marks":[{"type":"strong"}],"text":"低耦合、高擴展、可維護、易使用四個特性。"},{"type":"text","text":"”"}]},{"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":"據他介紹,設計產品時,他把 Hermes 作爲一個 Prometheus 的 exporter 來進行設計。在實現基本數據採集能力的基礎上,再讓它主動把數據推送到 Push Gateway,從而更好地適應業務網絡隔離場景下的監控數據抓取。這樣,完成了 Prometheus 體系的監控數據採集能力。"}]},{"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":"然後,把 Hermes 視爲一個獨立服務,提供一整套的 Restful API 接口 ,可以直接對接其他需要監控數據的應用,這樣拓展其應用場景,不再侷限於 Prometheus。"}]},{"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":"“Hermes 所有采集配置、推送配置等控制參數,均可以在運行時動態修改、實時生效,這樣極大提升其靈活性和易用性。”他補充道。"}]},{"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":"並且,Hermes 採用 java 語言開發而不是 Prometheus 體系常用的 go 語言,這就打消了很多客戶不願混用多語言的顧慮。"}]},{"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":"當然,這個產品開發過程並非一帆風順。"}]},{"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 及其 exporter、Push Gateway 等組件的學習和應用。雖然 Prometheus 已經非常成熟,並有着廣泛的應用,但是對陳偉他們來說卻是全新的。所以,他們需要從 0 到 1 完整的瞭解 Prometheus 監控體系和各個組件。比如,在向 Prometheus 和 Push Gateway 發送數據時,發送的數據中是否應當包含時間戳是要特別處理的。"}]},{"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":"此外,團隊遇到的另一個主要問題是如何平衡工作和參賽項目。由於項目組成員的日常工作非常繁忙,因此大家都是利用不多的業餘時間推進參賽項目。"}]},{"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":"經過兩個月緊鑼密鼓的開發,Hermes 趕在作品提交前最終完成。"}]},{"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":"據悉,"},{"type":"text","marks":[{"type":"strong"}],"text":"它是華夏銀行基礎技術研究團隊完全自主研發、採用 Java 開發、全面採集 openGauss 數據庫監控指標的一個開源項目。"}]},{"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":"靠這款產品,陳偉所在團隊從初賽中突圍,進入決賽,再從決賽中脫穎而出,最終進入信創“大比武”總決賽。"}]},{"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":"在總決賽中,Hermes 憑藉完全自主研發,充分利用 openGauss 數據庫已有的監控指標,以及易拓展、易使用、易維護的優勢,得到了評委的一致好評,最終獲得金獎。"}]},{"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":"陳偉表示,這次大賽給他們提供了一個展示的舞臺。華夏銀行一直致力於信息技術創新工作,成功應用鯤鵬、openEuler、openGauss 等諸多優秀的國產化的創新技術產品,爲用戶提供優質的金融產品和服務。"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"融入 openGauss 生態,壯大社區"}]},{"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":"作爲一個剛剛起步的產品,Hermes 還有很多可以提升的地方。比如,現在的很多功能雖然都已經實現,但是在操作上卻只能通過 RESTful API 來進行交互,未來可以提供一個簡單易用的管理控制檯。"}]},{"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":"接下來,Hermes 會開源並貢獻到 openGauss 開源社區。藉助社區的力量,陳偉團隊將 Hermes 打造爲一個更優秀的產品。"}]},{"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":"如此,一方面,可以爲 openGauss 生態增添一款有價值的開源工具,讓其監控體系變得更完備;另一方面,有了更多好工具的加持和生態的完善,openGauss 更容易得到企業採用。"}]},{"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":"更重要的是,Hermes 的加入,能進一步壯大社區力量,吸引更多人蔘與社區、貢獻社區。這樣,openGauss 社區就可以更好地持續構建創新能力。"}]},{"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":"在陳偉團隊看來,本次大賽就是一種很好的方式,爲社區帶來熱度,通過持續的刺激帶來持續的創新。”Hermes 加入社區後,相當於爲 openGauss 社區生態加了一把力。通過產品本身的持續迭代、各種活動不斷地提升社區熱度,不斷有企業、個人加入進來,不斷帶來新血液”。"}]},{"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":"陳偉說:“未來,只要 openGauss 不斷豐富自己的應用場景,不斷迭代,持續修復 bug 以及增加新特性,對企業和開發者的黏性將持續提升,那麼參與者越來越多,openGauss 社區勢必帶來持續的創新和技術發展。”"}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"寫在最後"}]},{"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":"如果說操作系統是基礎軟件的根,那麼數據庫則是基礎軟件皇冠上的明珠。2020 年 6 月 30 日 openGauss 數據庫正式開源,據瞭解,已經有超 70 家企業夥伴加入社區,開發貢獻者超過 2000人,有 12 傢伙伴基於 openGauss 發佈了商業發行版,其中海量數據、雲和恩墨、神舟通用等夥伴產品已經在金融、政府、電力、製造等行業核心業務系統部署,並進入加速大規模應用階段。短暫的一年多發展,可以說 openGauss 不僅成爲了這個行業的新興力量,而且正在大跨步前進。"}]},{"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":"此外,隨着企業數字化轉型邁入深水區,企業對核心數據庫的升級迫在眉睫,並開始尋找更開放、技術更領先的開源數據庫。而 openGauss 爲代表的開源數據庫相比傳統數據庫,顯然成爲企業更好的選擇。這不僅有利於企業掌握自主創新主動權,而且能助力企業打造未來競爭新優勢。"}]}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章