Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*.lib
*.swp
*.fatbin
*.py
*.sh
bin/
y.go
*.output
Expand All @@ -18,10 +20,15 @@ tags
coverage.txt
out.txt
logs/
prometheus-local-data/
prometheus-data/
grafana-local-data/
grafana-data/
sdk_demo/
vendor/
gen_config
main
mo-tool
/mo-server
/mo-service
/mo-debug
Expand Down
325 changes: 320 additions & 5 deletions Makefile

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ make dev-edit-cn1 # Edit CN1 config
make dev-restart-cn1 # Restart only CN1 (fast!)
```

📖 **[Full Guide & All Commands →](etc/docker-multi-cn-local-disk/)**
📖 **[Complete Development Guide →](etc/DEV_README.md)** - Comprehensive guide covering standalone setup, multi-CN clusters, monitoring, metrics, configuration, and all `make dev-*` commands

### 🎯 Using mo_ctl Tool (Recommended for Production)

Expand Down
18 changes: 18 additions & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,24 @@ for row in results.rows:

MatrixOne 支持多种安装方式,选择最适合您需求的方式:

### 🐳 本地多 CN 开发环境

在本地运行完整的分布式集群,包含多个 CN 节点、负载均衡和便捷的配置管理。

```bash
# 快速开始
make dev-build && make dev-up

# 通过代理连接(负载均衡)
mysql -h 127.0.0.1 -P 6001 -u root -p111

# 配置特定服务(交互式编辑器)
make dev-edit-cn1 # 编辑 CN1 配置
make dev-restart-cn1 # 仅重启 CN1(快速!)
```

📖 **[完整开发指南 →](etc/DEV_README.md)** - 涵盖单机设置、多 CN 集群、监控、指标、配置和所有 `make dev-*` 命令的完整指南

### 🎯 使用 mo_ctl 工具(推荐)

官方 [mo_ctl](https://github.com/matrixorigin/mo_ctl_standalone) 工具提供一键部署和生命周期管理。自动处理安装、升级、备份和健康监控。
Expand Down
10 changes: 10 additions & 0 deletions clients/python/README_USER.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ A comprehensive, high-level Python SDK for MatrixOne that provides SQLAlchemy-li
- 📋 [Best Practices](https://matrixone.readthedocs.io/en/latest/best_practices.html)
- 📖 [API Reference](https://matrixone.readthedocs.io/en/latest/api/index.html)

**For Developers:**
- 🛠️ [MatrixOne Development Guide](../../etc/DEV_README.md) - Complete guide for setting up MatrixOne locally, multi-CN clusters, monitoring, and all `make dev-*` commands

---

## ✨ Features
Expand Down Expand Up @@ -137,6 +140,13 @@ class User(Base):

## Quick Start

> **💡 Need to set up MatrixOne server?**
> If you don't have MatrixOne running yet, check out the [MatrixOne Development Guide](../../etc/DEV_README.md) for instructions on:
> - Starting a standalone MatrixOne instance
> - Setting up a multi-CN cluster with Docker Compose
> - Enabling monitoring and metrics
> - All `make dev-*` commands

### Basic Usage

```python
Expand Down
116 changes: 116 additions & 0 deletions cmd/mo-dashboard/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// Copyright 2024 Matrix Origin
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package mo_dashboard

import (
"fmt"

"github.com/matrixorigin/matrixone/pkg/logutil"
"github.com/matrixorigin/matrixone/pkg/util/metric/v2/dashboard"
"github.com/spf13/cobra"
)

func PrepareCommand() *cobra.Command {
var (
host string
port int
mode string
username string
password string
datasource string
)

cmd := &cobra.Command{
Use: "dashboard",
Short: "Create Grafana dashboards for MatrixOne",
Long: `Create Grafana dashboards for MatrixOne monitoring.

This command connects to a Grafana instance and creates all MatrixOne dashboards.
Supports different modes: local (standalone), cloud (docker compose cluster), k8s, and cloud-ctrl.`,
Example: ` # Create local dashboard (default: port 3001)
mo-tool dashboard

# Create dashboard for docker compose cluster (port 3000)
mo-tool dashboard --mode cloud --port 3000

# Create dashboard with custom host and credentials
mo-tool dashboard --host localhost --port 3001 --username admin --password mypass`,
RunE: func(cmd *cobra.Command, args []string) error {
grafanaURL := fmt.Sprintf("http://%s:%d", host, port)

var creator *dashboard.DashboardCreator

switch mode {
case "local":
creator = dashboard.NewLocalDashboardCreator(
grafanaURL,
username,
password,
"Matrixone-Standalone",
)
logutil.Infof("Creating local dashboard at %s (folder: Matrixone-Standalone)", grafanaURL)

case "cloud":
creator = dashboard.NewCloudDashboardCreator(
grafanaURL,
username,
password,
datasource,
"Matrixone",
)
logutil.Infof("Creating cloud dashboard at %s (datasource: %s, folder: Matrixone)", grafanaURL, datasource)

case "k8s":
creator = dashboard.NewK8SDashboardCreator(
grafanaURL,
username,
password,
datasource,
"Matrixone",
)
logutil.Infof("Creating K8S dashboard at %s (datasource: %s, folder: Matrixone)", grafanaURL, datasource)

case "cloud-ctrl":
creator = dashboard.NewCloudCtrlPlaneDashboardCreator(
grafanaURL,
username,
password,
datasource,
"Matrixone",
)
logutil.Infof("Creating cloud control-plane dashboard at %s (datasource: %s, folder: Matrixone)", grafanaURL, datasource)

default:
return fmt.Errorf("invalid mode '%s'. Valid modes: local, cloud, k8s, cloud-ctrl", mode)
}

if err := creator.Create(); err != nil {
return fmt.Errorf("failed to create dashboard: %w", err)
}

logutil.Infof("Dashboard created successfully!")
return nil
},
}

cmd.Flags().StringVar(&host, "host", "127.0.0.1", "Grafana host address")
cmd.Flags().IntVar(&port, "port", 3001, "Grafana port (default: 3001 for local, 3000 for docker compose)")
cmd.Flags().StringVar(&mode, "mode", "local", "Dashboard mode: local, cloud, k8s, cloud-ctrl (default: local)")
cmd.Flags().StringVar(&username, "username", "admin", "Grafana username (default: admin)")
cmd.Flags().StringVar(&password, "password", "admin", "Grafana password (default: admin)")
cmd.Flags().StringVar(&datasource, "datasource", "Prometheus", "Prometheus datasource name (for cloud/k8s modes, default: Prometheus)")

return cmd
}
2 changes: 1 addition & 1 deletion cmd/mo-service/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ func (c *Config) createFileService(

func (c *Config) getLogServiceConfig() logservice.Config {
cfg := c.LogService
logutil.Infof("hakeeper client cfg: %v", c.HAKeeperClient)
logutil.Info("logservice.get.config", zap.Any("hakeeper.client", c.HAKeeperClient))
cfg.HAKeeperClientConfig = c.HAKeeperClient
cfg.DataDir = filepath.Join(c.DataDir, "logservice-data", cfg.UUID)
var hostname string
Expand Down
12 changes: 6 additions & 6 deletions cmd/mo-service/launch.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func waitHAKeeperRunning(client logservice.CNHAKeeperClient) error {
if moerr.IsMoErrCode(err, moerr.ErrNoHAKeeper) ||
state.State != logpb.HAKeeperRunning {
// not ready
logutil.Info("hakeeper not ready, retry")
logutil.Info("retry.wait.hakeeper.running")
time.Sleep(time.Second)
continue
}
Expand All @@ -276,23 +276,23 @@ func waitAnyShardReady(client logservice.CNHAKeeperClient) error {
if err != nil {
if errors.Is(err, context.DeadlineExceeded) {
err = moerr.AttachCause(ctx, err)
logutil.Errorf("wait TN ready timeout: %s", err)
logutil.Error("wait.tn.ready.timeout", zap.Error(err))
return false, err
}
logutil.Errorf("failed to get cluster details %s", err)
logutil.Error("wait.tn.ready.failed", zap.Error(err))
return false, nil
}
for _, store := range details.TNStores {
if len(store.Shards) > 0 {
return true, nil
}
}
logutil.Info("shard not ready")
logutil.Info("wait.tn.ready.not.ready")
return false, nil
}(); err != nil {
return err
} else if ok {
logutil.Info("shard ready")
logutil.Info("wait.tn.ready.ready.completed")
return nil
}
time.Sleep(time.Second)
Expand All @@ -312,7 +312,7 @@ func waitClusterCondition(
return err
}
if err := client.Close(); err != nil {
logutil.Error("close hakeeper client failed", zap.Error(err))
logutil.Error("wait.cluster.condition.close.hakeeper.client.failed", zap.Error(err))
}
return nil
}
5 changes: 4 additions & 1 deletion cmd/mo-tool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
package main

import (
"os"

dashboard "github.com/matrixorigin/matrixone/cmd/mo-dashboard"
debug "github.com/matrixorigin/matrixone/cmd/mo-debug"
inspect "github.com/matrixorigin/matrixone/cmd/mo-inspect"
"github.com/spf13/cobra"
"os"
)

func main() {
Expand All @@ -30,6 +32,7 @@ func main() {

rootCmd.AddCommand(debug.PrepareCommand())
rootCmd.AddCommand(inspect.PrepareCommand())
rootCmd.AddCommand(dashboard.PrepareCommand())

if err := rootCmd.Execute(); err != nil {
os.Exit(1)
Expand Down
Loading
Loading