English | 中文
-
Supports management of Alibaba Cloud RDS, including:
- Instance information query
- RDS Issue analysis
- Purchase and modify RDS instance
-
Query data for self-built databases, assisting with data queries, statistics and analysis.
-
Install
uv:- Install
uvvia Astral - Install
uvvia GitHub README - Download
uvfrom GitHub Release
- Install
-
Install Python:
- Use the following command to install Python:
uv python install 3.12
-
Apply for a LLM api key:
- Compatible with OpenAI client, support Qwen and Deepseek.
-
Prepare an Alibaba Cloud account AK/SK:
- Ensure your account having the access permission with Alibaba Cloud RDS service (Policy Name: AliyunRDSFullAccess).
Install dependency modules using uv:
export UV_DEFAULT_INDEX="https://mirrors.aliyun.com/pypi/simple" # optional
uv sync --inexact-
Prepare Configuration File
- Default path:
/usr/local/mydba/config_app.ini - Configure parameters in the
model,app, andragsections:
[common] debug = False config_database = sqlite:///usr/local/mydba/sqlite_app.db [log] dir = /usr/local/mydba/logs name = mydba file_level = INFO [model] api_key = sk-xxx ; LLM api key base_url = https://api.deepseek.com ; LLM api base url (example is the model address of Deepseek) model = deepseek-chat ; LLM model name (example is the model name of Deepseek) max_tokens = 1000 temperature = 1.0 [app] refresh_interval = 60 max_steps = 100 security_key = xxxxxxxxxxxxxxxx ; Key for encryption, 16-byte length, for internal data protection [rag] api_key = sk-xxx ; LLM api key base_url = https://dashscope.aliyuncs.com/compatible-mode/v1 ; LLM api base url (example is the model address of Qwen) embedding = text-embedding-v2 ; Embedding model name (Qwen supports embedding api calls) data_dir = /usr/local/mydba/vector_store
- Default path:
-
Create Log Directory
- The log directory can be found in the configuration: [log].dir
- Default path: /usr/local/mydba/logs
mkdir /usr/local/mydba/logs
-
Initialize Agent
- Execute the following command to initialize the Agent. Ensure you have correctly configured the
config_app.inifile and replacexxxxxxwith your Alibaba Cloud account AK/SK.
uv --directory /path/to/mydba \ run init_config.py \ init-project \ # Initialize project --config_file /usr/local/mydba/config_app.ini \ # Configuration file path --reset \ # Clear existing configuration (optional) --rds_access_id xxxxxx \ # Replace with your Alicloud account ID --rds_access_key xxxxxx # Replace with your Alicloud account secret - Execute the following command to initialize the Agent. Ensure you have correctly configured the
-
Add Self-Built Database
- Execute the following command to add a self-built database. Ensure you have correctly configured the
config_app.inifile and replace--db_infoparameters with actual database connection details.
uv --directory /path/to/mydba \ run init_config.py \ add-db \ # Add self-built database --config_file /usr/local/mydba/config_app.ini \ # Path to the configuration file --db_info 'mysql####127.0.0.1##3306##root##123456##utf8mb4##mybase' # Database connection info, pay attention to the escape of special characters - Execute the following command to add a self-built database. Ensure you have correctly configured the
-
Initialize RAG Tool
- Execute the following command to initialize the RAG tool. Ensure you have correctly configured the
config_app.inifile and added the self-built database.
uv --directory /path/to/mydba/mydba/mcp/rag \ # RAG working directory ./mydba/mcp/rag run rag_init.py \ # Run RAG initialization script init-config \ # Initialize configuration --config_file /usr/local/mydba/config_app.ini # Path to the configuration file
- Execute the following command to initialize the RAG tool. Ensure you have correctly configured the
-
Execute the start command:
mydba(install agent via MyBase console, this command will register in the OS)mydba
-
Or use the startup script:
mydba.sh(built-in startup script, use directly if default installation path is unchanged)sh /path/to/mydba/shell/mydba.sh
-
Or manually execute the following commands:
# Set environment variables (optional, default: /usr/local/mydba/config_app.ini) export MYDBA_CONFIG_FILE=/path/to/mydba/config_app.ini # Start RAG Server nohup uv --directory /path/to/mydba/mydba/mcp/rag run rag_server.py >> /path/to/mydba/logs/rag.log 2>&1 & # Start MyDBA uv --directory /path/to/mydba run main.py
- Welcome joining the DingTalk group for feedback, refer to the README.md of RDS MCP for details.