# AIOPS-backend **Repository Path**: cstcloud-cnic/aiops ## Basic Information - **Project Name**: AIOPS-backend - **Description**: aiops后端服务apiserver - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: https://aiops.cstcloud.cn - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2023-02-20 - **Last Updated**: 2025-12-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 关于AIOps 智能运管 ## 环境搭建(CentOS9) ### 1 安装python和Git 请自行安装python3.9和Git。 使用Git拉取代码: ``` git clone https://gitee.com/cstcloud-cnic/aiops.git ``` ### 2 安装python运行环境 如果安装python依赖包mysqlclient失败,系统环境可能需要安装相关依赖包,请确保已安装mysql(mariadb)数据库。 ``` # fedora install MariaDB, mysqlclient所需依赖库 sudo dnf -y install mariadb-server mariadb yum install python3-devel mysql-devel # mysqlclient依赖 # CentOS9 安装MariaDB, mysqlclient所需依赖库 sudo dnf -y install mariadb-server mariadb dnf install mariadb-connector-c-devel # mysqlclient依赖 ``` #### (1) 使用python虚拟环境(推荐) 使用pip命令安装pipenv。 ``` pip3 install pipenv ``` 在代码工程根目录下,即文件Pipfile同目录下运行命令: ``` pipenv install ``` #### (2) 使用系统python环境 在代码工程根目录下,即文件requirements.txt同目录下运行命令: ```pip3 install -r requirements.txt``` ### 3 安全敏感信息配置文件 安全信息配置demo文件security_demo.py修改文件名为security.py,根据自己情况完成配置。 ### 4 数据库配置 请自行安装mysql数据库,根据自己的情况修改security.py文件中数据库的配置项。 ``` DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', # 数据库引擎 'NAME': 'xxx', # 数据的库名 'HOST': '127.0.0.1', # 主机 'PORT': '3306', # 数据库使用的端口 'USER': 'xxx', # 数据库用户名 'PASSWORD': 'xxx', # 密码 'OPTIONS': { 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'", 'charset': 'utf8mb4' } }, } ``` ### 5 运行服务 如果使用python虚拟环境,先激活python虚拟环境 ``` pipenv shell ``` 数据库迁移,在项目根目录下运行如下命令完成数据库迁移。 ``` python3 manage.py migrate ``` 运行web服务 ``` python3 manage.py runserver 0:80 ``` 如果一切正常,打开浏览器输入url(主机IP, 如:127.0.0.1)即可查看站点;