# euler-copilot-tune **Repository Path**: xuhou/euler-copilot-tune ## Basic Information - **Project Name**: euler-copilot-tune - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-09-02 - **Last Updated**: 2025-09-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # EulerCopilot Tune安装使用指南 ## 项目简介 EulerCopilot Tune通过采集系统、微架构、应用等维度的指标数据,结合大模型和定制化的prompt工程,针对不同应用的可调参数给出可靠的参数推荐,同时根据推荐的参数运行benchmark,与baseline做对比并计算出推荐参数对应用性能的提升值。 ## 软件架构 软件架构说明 ## 安装教程 ### 1、下载rpm包 地址:https://eulermaker.compass-ci.openeuler.openatom.cn/package/download?osProject=houxu:openEuler-24.03-LTS-SP2:epol&packageName=euler-copilot-tune ### 2、安装rpm包 ~~~bash #由于rpm安装过程需要使用pip下载资源,为了加快安装速度,推荐设置镜像源 pip config set global.index-url https://repo.huaweicloud.com/repository/pypi/simple/ 清华大学TUNA镜像源: https://pypi.tuna.tsinghua.edu.cn/simple 阿里云镜像源: http://mirrors.aliyun.com/pypi/simple/ 中国科学技术大学镜像源: https://mirrors.ustc.edu.cn/pypi/simple/ 华为云镜像源: https://repo.huaweicloud.com/repository/pypi/simple/ 腾讯云镜像源:https://mirrors.cloud.tencent.com/pypi/simple/ #开始安装 x86: dnf install euler-copilot-tune-1.0-1.oe2403sp2.x86_64.rpm arm: dnf install euler-copilot-tune-1.0-1.oe2403sp2.aarch64.rpm 备注:不要在python虚拟环境中执行,在系统环境下安装pip包 #安装过程中会在Running scriptlet: euler-copilot-tune-1.0-1.x86_64 处停留较长时间,此处是在pip安装对应依赖包 #可以通过如下命令查看详细日志 tail -f /pip_install.log #如果按照完成后出现pip包安装失败情况,请单独执行如下命令进行安装 pip install fastapi numpy openai paramiko pydantic pyyaml scikit-learn tqdm uvicorn requests langchain langchain-openai email-validator httpx tabulate gssapi pandas faiss-cpu pyfiglet mcp ~~~ ### 3、修改配置文件 详细信息请查阅 https://gitee.com/openeuler/A-Tune/blob/euler-copilot-tune/README.md ##### 准备env yaml,放入/etc/euler-copilot-tune/config/.env.yaml中,具体格式如下: ```YAML LLM_KEY: "YOUR_LLM_KEY" LLM_URL: "YOUR_LLM_URL" LLM_MODEL_NAME: "YOUR_LLM_MODEL_NAME" LLM_MAX_TOKENS: REMOTE_EMBEDDING_ENDPOINT: "YOUR_EMBEDDING_MODEL_URL" REMOTE_EMBEDDING_MODEL_NAME: "YOUR_MODEL_NAME" servers: - ip: "" #应用所在ip host_user: "" #登录机器的usr id password: "" #登录机器的密码 port: #应用所在ip的具体port app: "mysql" #当前支持mysql、nginx、pgsql、spark target_process_name: "mysqld" #调优应用的name business_context: "高并发数据库服务,CPU负载主要集中在用户态处理" #调优应用的描述(用于策略生成) max_retries: 3 delay: 1.0 feature: - need_restart_application: False #修改参数之后是否需要重启应用使参数生效 need_recover_cluster: False #调优过程中是否需要恢复集群 microDep_collector: True #是否开启微架构指标踩采集 pressure_test_mode: True #是否通过压测模拟负载环境 tune_system_param: False #是否调整系统参数 tune_app_param: True #是否调整应用参数 strategy_optimization: False #是否需要策略推荐 benchmark_timeout: 3600 #benchmark执行超时限制 ``` ##### 完善app_config.yaml,放入/etc/euler-copilot-tune/config/app_config.yaml中(重点是补充set_param_template、get_param_template、benchmark脚本),具体内容如下: ```YAML mysql: user: "root" password: "123456" config_file: "/etc/my.cnf" port: 3306 set_param_template: 'grep -q "^$param_name\\s*=" "$config_file" && sed -i "s/^$param_name\\s*=.*/$param_name = $param_value/" "$config_file" || sed -i "/\\[mysqld\\]/a $param_name = $param_value" "$config_file"' get_param_template: 'grep -E "^$param_name\s*=" $config_file | cut -d= -f2- | xargs' stop_workload: "systemctl stop mysqld" start_workload: "systemctl start mysqld" benchmark: "$EXECUTE_MODE:local sh $SCRIPTS_DIR/mysql/parse_benchmark.sh $host_ip $port $user $password" performance_metric: "QPS" flink: set_param_template: 'sh /home/wsy/set_param.sh $param_name $param_value' get_param_template: 'sh /home/wsy/get_param.sh $param_name' benchmark: "sh /home/wsy/nexmark_test.sh" stop_workload: 'docker exec -i flink_jm_8c32g bash -c "source /etc/profile && /usr/local/flink-1.16.3/bin/stop-cluster.sh && /usr/local/nexmark/bin/shutdown_cluster.sh"' start_workload: 'docker exec -i flink_jm_8c32g bash -c "source /etc/profile && /usr/local/flink-1.16.3/bin/start-cluster.sh"' performance_metric: "THROUGHPUT" pgsql: user: "postgres" password: "postgres" config_file: "/data/data1/pgsql/postgresql.conf" port: 5432 set_param_template: 'grep -qE "^\s*$param_name\s*=" "$config_file" && sed -i "s/^[[:space:]]*$param_name[[:space:]]*=.*/$param_name = $param_value/" "$config_file" || echo "$param_name = $param_value" >> "$config_file"' get_param_template: 'grep -oP "^\s*$param_name\s*=\s*\K.*" "$config_file"' stop_workload: "su - postgres -c '/usr/local/pgsql/bin/pg_ctl stop -D /data/data1/pgsql/ -m fast'" start_workload: "su - postgres -c '/usr/local/pgsql/bin/pg_ctl start -D /data/data1/pgsql/ -l /var/log/postgresql/postgresql.log'" benchmark: "$EXECUTE_MODE:local sh $SCRIPTS_DIR/postgresql/parse_benchmark.sh $host_ip $port $user $password" performance_metric: "QPS" spark: set_param_template: 'sh /path/of/set_param.sh $param_name $param_value' get_param_template: 'sh /path/of/get_param.sh $param_name' benchmark: "sh /path/of/spark_benchmark.sh" performance_metric: "DURATION" nginx: port: 10000 config_file: "/usr/local/nginx/conf/nginx.conf" set_param_template: 'grep -q "^\\s*$param_name\\s\\+" "$config_file" && sed -i "s|^\\s*$param_name\\s\\+.*| $param_name $param_value;|" "$config_file" || sed -i "/http\\s*{/a\ $param_name $param_value;" "$config_file"' get_param_template: 'grep -E "^\\s*$param_name\\s+" $config_file | head -1 | sed -E "s/^\\s*$param_name\\s+(.*);/\\1/"' stop_workload: "/usr/local/nginx/sbin/nginx -s reload" start_workload: "/usr/local/nginx/sbin/nginx -s reload" benchmark: "$EXECUTE_MODE:local sh $SCRIPTS_DIR/nginx/parse_benchmark.sh $host_ip $port" performance_metric: "QPS" ceph: set_param_template: 'ceph config set osd "$param_name" "$param_value"' get_param_template: 'sh /path/of/get_params.sh' start_workload: "sh /path/of/restart_ceph.sh" benchmark: "$EXECUTE_MODE:local sh $SCRIPTS_DIR/ceph/parse_benchmark.sh" performance_metric: "BANDWIDTH" gaussdb: user: "" password: "" config_file: "/path/of/config_file" port: 5432 set_param_template: 'gs_guc set -Z datanode -N all -I all -c "${param_name}=${param_value}"' get_param_template: 'gs_guc check -Z datanode -N all -I all -c "${param_name}"' stop_workload: "cm_ctl stop -m i" start_workload: "cm_ctl start" recover_workload: "$EXECUTE_MODE:local sh /path/of/gaussdb_cluster_recover.sh" benchmark: "$EXECUTE_MODE:local sh/path/of/gaussdb_benchmark.sh" performance_metric: "DURATION" system: set_param_template: 'sysctl -w $param_name=$param_value' get_param_template: 'sysctl $param_name' redis: port: 6379 config_file: "/etc/redis.conf" set_param_template: "sed -i 's/^$param_name/$param_name $param_value/g' $config_file" get_param_template: "grep -P '$param_name' $config_file | awk '{print $2}" start_workload: "systemctl start redis" stop_workload: "systemctl stop redis" benchmark: "$EXECUTE_MODE:local sh $SCRIPTS_DIR/redis/parse_benchmark.sh $host_ip $port " performance_metric: "QPS" ``` 其中: set_param_template:根据调优结果修改应用参数,用于后续测试效果 get_param_template:获取应用参数 recover_workload: 恢复集群 benchmark:benchmark脚本 详细使用文档请参考:[README.md · openEuler/A-Tune - 码云 - 开源中国](https://gitee.com/openeuler/A-Tune/blob/euler-copilot-tune/README.md) ### 4、启动调优 #### 支持三种方式启动 ##### 方式一:开启调优 ~~~bash #命令行执行 euler-copilot-tune ~~~ ##### 方式二:开启openapi服务 ~~~bash #命令行执行 tune-openapi #或者 systemctl start tune-openapi #journalctl -xe -u tune-openapi --all -f 查看日志 ~~~ ##### 方式三:开启mcp服务 ~~~bash #命令行执行 tune-mcpserver #或者 systemctl start tune-mcpserver #journalctl -xe -u tune-mcpserver --all -f 查看日志 ~~~