KunlunDB叢集管理介面

KunlunDB發表於2022-04-07
KunlunDB在0.9版本之後,增加了運維監控平臺(Xpanel), 通過叢集管理(Cluster_mgr)的HTTP命令介面,可以實現對整個叢集環境進行管理和監控。


以下是詳細的命令介面介紹:

獲取cluster工作狀態,POST介面:
    curl -d "{\"job_type\":\"get_status\",\"job_id\":\"uuid999\"}" 


    由於建立叢集,和恢復一個新叢集,會生成新的叢集名稱,通過get_status這個命令獲取狀態時,如果返回result為succeed,那info就是新叢集的名稱。


    命令接收: 

      {"result":"accept"}


      成功返回:

        {"result":"done","info":"something done"}


        正在工作:

          {"result":"ongoing","info":"something ongoing"}


          失敗返回:

            {"result":"failed","info":"something error"}


            1. 建立機器, 非同步,需要查詢,不阻塞其他操作。


            • 返回result=done/failed, info:create machine succeed(或者錯誤資訊)。

            • 操作表記錄:info:create machine succeed(或者錯誤資訊)。

            • 路徑為根路徑,必須存在,total_mem單位是Mbyte。

              {"ver":"0.1","job_id":"uuid999","job_type":"create_machine","hostaddr":"127.0.0.1","rack_id":"1","datadir":"/home/kunlun;/nvme2","logdir":"/home/kunlun;/nvme3","wal_log_dir":"/home/kunlun","comp_datadir":"/nvme2","total_mem":"1024","total_cpu_cores":"8","user_name":"zhangsan"}


              2. 更新機器, 非同步,需要查詢,不阻塞其他操作。


              • 返回result=done/failed時, info:update machine succeed(或者錯誤資訊)。

              • 操作表記錄:info:update machine succeed(或者錯誤資訊)。

              • 路徑為根路徑,必須存在,total_mem單位是Mbyte。

                {"ver":"0.1","job_id":"uuid999","job_type":"update_machine","hostaddr":"127.0.0.1","rack_id":"1","datadir":"/home/kunlun;/nvme2","logdir":"/home/kunlun;/nvme3","wal_log_dir":"/home/kunlun","comp_datadir":"/nvme2","total_mem":"4096","total_cpu_cores":"8","user_name":"zhangsan"}


                3. 刪除機器, 非同步,需要查詢,不阻塞其他操作。


                • 返回result=done/failed時, info:delete machine succeed(或者錯誤資訊)。

                • 操作表記錄:info:delete machine succeed(或者錯誤資訊)。

                  {"ver":"0.1","job_id":"uuid999","job_type":"delete_machine","hostaddr":"127.0.0.1","user_name":"zhangsan"}


                  4. 建立叢集, 非同步,需要查詢。


                  • 返回result=done時, info:叢集名稱。

                  • 操作表記錄:info:create cluster succeed(或者錯誤資訊)。

                  • max_storage_size單位是G, innodb_size單位是G。

                  • innodb_size按要求先預設1G吧,範圍1-16G。

                  • user_name為網頁端使用,儲存到操作記錄裡面。

                  • machine為指定安裝機器,以machine0開始。

                    {"ver":"0.1","job_id":"uuid999","job_type":"create_cluster","ha_mode":"mgr","shards":"2","nodes":"1","comps":"1","max_storage_size":"20","max_connections":"6","cpu_cores":"8","innodb_size":"1","user_name":"zhangsan","machinelist":[{"hostaddr":"127.0.0.2"},{"hostaddr":"127.0.0.3"}]}


                    5. 刪除叢集, 非同步,需要查詢。


                    • 返回result=done時, info:叢集名稱。

                    • 操作表記錄:info:delete cluster succeed(或者錯誤資訊)。

                      {"ver":"0.1","job_id":"uuid999","job_type":"delete_cluster","cluster_name":"cluster001","user_name":"zhangsan"}


                      6. 在現有叢集上,新增分片,可以增加多個。


                      • 返回result=done時, info:shard2;shard3。

                      • 操作表記錄:info:add shards succeed(或者錯誤資訊)。

                      • 分片名稱排列,分隔符改為分號,因為之前建立機器的路徑也是分號,統一了比較好。

                        {"ver":"0.1","job_id":"uuid999","job_type":"add_shards","cluster_name":"cluster001","shards":"2","user_name":"zhangsan","machinelist":[{"hostaddr":"127.0.0.2"},{"hostaddr":"127.0.0.3"}]}


                        7. 在現有叢集上,刪除分片,只能一個一個刪


                        • 返回result=done時, info:刪除分片名。

                        • 操作表記錄:info:delete shard succeed(或者錯誤資訊)。

                          {"ver":"0.1","job_id":"uuid999","job_type":"delete_shard","cluster_name":"cluster001","shard_name":"shard1","user_name":"zhangsan"}


                          8. 在現有叢集上,新增計算節點,可以增加多個。


                          • 返回result=done時, info:comp2;comp3。

                          • 操作表記錄:info:add comps succeed(或者錯誤資訊)。

                            {"ver":"0.1","job_id":"uuid999","job_type":"add_comps","cluster_name":"cluster001","comps":"2","user_name":"zhangsan","machinelist":[{"hostaddr":"127.0.0.2"},{"hostaddr":"127.0.0.3"}]}


                            9. 在現有叢集上,刪除計算節點,只能一個一個刪。


                            • 返回result=done時, info:刪除計算節點名。

                            • 操作表記錄:info:delete shard succeed(或者錯誤資訊)。

                              {"ver":"0.1","job_id":"uuid999","job_type":"delete_comp","cluster_name":"cluster001","comp_name":"comp1","user_name":"zhangsan"}


                              10. 為叢集所有分片增加node, 非同步,需要查詢。


                              • 帶有shard_name欄位,只增加該分片,否則所有分片都增加。

                              • 返回result=done時, info:ip:port;ip:port,分隔符分號。

                              • 操作表記錄:info:add nodes succeed(或者錯誤資訊)。

                              • 該操作只能是MGR模式,先備份分片,建立出新NODE, 把備份恢復到新NODE, 將新NODE加入分片。

                                {"ver":"0.1","job_id":"uuid999","job_type":"add_nodes","cluster_name":"cluster001","shard_name":"shard1","nodes":"2","user_name":"zhangsan","machinelist":[{"hostaddr":"127.0.0.2"},{"hostaddr":"127.0.0.3"}]}


                                11. 某個分片刪除node, 非同步,需要查詢。


                                • 返回result=done時, info:ip:port,分隔符分號。

                                • 操作表記錄:info:delete node succeed(或者錯誤資訊)。

                                • 該操作只能是MGR模式,先備份分片,建立出新NODE, 把備份恢復到新NODE, 將新NODE加入分片。

                                  {"ver":"0.1","job_id":"uuid999","job_type":"delete_node","cluster_name":"cluster001","shard_name":"shard1","ip":"127.0.0.1","port":"57338","user_name":"zhangsan"}


                                  12. 備份叢集, 非同步,需要查詢。


                                  • 返回result=done時, info:備份的時間。

                                  • 操作表記錄:info:backup cluster succeed(或者錯誤資訊)。

                                    {"ver":"0.1","job_id":"uuid999","job_type":"backup_cluster","backup_cluster_name":"cluster001","user_name":"zhangsan"}


                                    13. 恢復叢集, 非同步,需要查詢,該命令關閉,不給客戶執行。


                                    • 返回result=done時, info:恢復叢集名稱。

                                    • 操作表記錄:info:restore cluster succeed(或者錯誤資訊)。

                                      {"ver":"0.1","job_id":"uuid999","job_type":"restore_cluster","timestamp":"2021-12-20 19:22:20","backup_cluster_name":"cluster003","restore_cluster_name":"cluster004","user_name":"zhangsan"}


                                      14. 恢復出新叢集, 非同步,需要查詢


                                      • 返回result=done時, info:新叢集名稱。

                                      • 操作表記錄:info:restore new cluster succeed(或者錯誤資訊)。

                                        {"ver":"0.1","job_id":"uuid999","job_type":"restore_new_cluster","timestamp":"2021-12-20 19:22:20","backup_cluster_name":"cluster003","user_name":"zhangsan","machinelist":[{"hostaddr":"127.0.0.2"},{"hostaddr":"127.0.0.3"}]}


                                        15. 獲取後設資料MGR模式,同步返回。

                                          {"ver":"0.1","job_id":"uuid999","job_type":"get_meta_mode"}


                                          16. 獲取後設資料節點列表,同步返回。

                                            {"ver":"0.1","job_id":"uuid999","job_type":"get_meta"}

                                            17. 獲取所有叢集列表,同步返回。
                                              {"ver":"0.1","job_id":"uuid999","job_type":"get_cluster"}


                                              18. 獲取叢集儲存節點列表,同步返回。

                                                {"ver":"0.1","job_id":"uuid999","job_type":"get_storage","cluster_name":"cluster003"}


                                                19. 獲取叢集計算節點列表,同步返回。

                                                  {"ver":"0.1","job_id":"uuid999","job_type":"get_computer","cluster_name":"cluster003"}


                                                  20. 獲取例項變數,同步返回。

                                                    {"ver":"0.1","job_id":"uuid999","job_type":"get_variable","variable":"innodb_buffer_pool_size","ip":"127.0.0.1","port":"57338"}


                                                    21. 設定例項變數,同步返回。

                                                      優先整型value_int, 找不到再找字串value_str{"ver":"0.1","job_id":"uuid999","job_type":"set_variable","variable":"innodb_buffer_pool_size","value_int":"134217728","value_str":"134217728","ip":"127.0.0.1","port":"57338"}


                                                      22. 控制例項,非同步,需要查詢。


                                                      • 包括停止(stop)/啟動(start)/重啟(restart)三個操作。

                                                        {"ver":"0.1","job_id":"uuid999","job_type":"control_instance","control":"stop","ip":"127.0.0.1","port":"57338","user_name":"zhangsan"}


                                                        23. 更新prometheus資料,非同步,需要查詢。


                                                        • 機器IP,從後設資料表讀取,PORT從配置檔案讀取。

                                                          {"ver":"0.1","job_id":"uuid999","job_type":"update_prometheus","user_name":"zhangsan"}


                                                          24.  prometheus連線到 PostgreSQL。

                                                            {"ver":"0.1","job_id":"uuid999","job_type":"postgres_exporter","ip":"127.0.0.1","port":"57030","user_name":"zhangsan"}


                                                            25. prometheus連線到MySQL。

                                                              {"ver":"0.1","job_id":"uuid999","job_type":"mysqld_exporter","ip":"127.0.0.1","port":"57330","user_name":"zhangsan"}



                                                              END


                                                              來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/70011764/viewspace-2885953/,如需轉載,請註明出處,否則將追究法律責任。

                                                              相關文章