PgoOps运维平台部署文档
2022/5/2 6:12:57
本文主要是介绍PgoOps运维平台部署文档,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
简介
官网: http://www.pgoops.com
gitee: https://gitee.com/pgoops
github: https://github.com/yanshicheng/pgoops
准备工作
准备工作如果已经安装好了环境可以越过。
编译安装 Python3.10
项目基于 python 3.10+ ,确保 python 和 pip 正确配置
下载软件包
root@cloud-001:~# wget https://www.python.org/ftp/python/3.10.3/Python-3.10.3.tar.xz --no-check-certificate
解压软件包
root@cloud-001:~# tar xf Python-3.10.3.tar.xz root@cloud-001:~# cd Python-3.10.3/
编译安装
root@cloud-001:~/Python-3.10.3# apt-get install zlib1g-dev libbz2-dev libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev tk-dev libgdbm-dev libdb-dev libpcap-dev xz-utils libexpat1-dev liblzma-dev libffi-dev libc6-dev liblzma-dev root@cloud-001:~/Python-3.10.3# ./configure --prefix=/usr/local/python3.10 --enable-shared --enable-optimizations --with-ssl root@cloud-001:~/Python-3.10.3# make -j 8 root@cloud-001:~/Python-3.10.3# make install root@cloud-001:~/Python-3.10.3# echo "/usr/local/python3.10/lib/" >> /etc/ld.so.conf root@cloud-001:~/Python-3.10.3# ldconfig
设置环境变量
root@cloud-001:~/Python-3.10.3# cat > /etc/profile.d/python3.10.sh <<EOF export PYTHONPATH=/usr/local/python3.10 export PATH=${PYTHONPATH}/bin:${PATH} EOF root@cloud-001:~/Python-3.10.3# source /etc/profile # 检查 root@cloud-001:~# pip3 -V pip 22.0.4 from /usr/local/python3.10/lib/python3.10/site-packages/pip (python 3.10) root@cloud-001:~# python3 -V Python 3.10.3 # pip 全局加速 root@cloud-001:~# pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
安装 NodeJs
基于二进制格式安装部署
下载及解压
root@cloud-001:~# wget https://nodejs.org/dist/v16.15.0/node-v16.15.0-linux-x64.tar.xz --no-check-certificate root@cloud-001:~# tar xf node-v16.15.0-linux-x64.tar.xz -C /usr/local/ root@cloud-001:~# ln -s /usr/local/node-v16.15.0-linux-x64/ /usr/local/node
设置环境变量
# 设置全局变量 cat > /etc/profile.d/nodejs.sh <<EOF export NODEPATH=/usr/local/node export PATH=${NODEPATH}/bin:${PATH} EOF # 加载全局变量 root@cloud-001:~/Python-3.10.3# source /etc/profile # 检查 root@cloud-001:~# node -v v16.15.0 root@cloud-001:~# npm -v 8.5.5 # 全局变量 root@cloud-001:~# npm config set registry https://registry.npm.taobao.org
安装 mariadb
root@cloud-001:~# sudo apt install mariadb-server # 初始化回车输入密码。一路Y root@cloud-001:~# sudo mysql_secure_installation # 禁用 bind-address root@cloud-001:~# vi /etc/mysql/mariadb.conf.d/50-server.cnf #bind-address = 127.0.0.1 root@cloud-001:~# systemctl restart mariadb.service root@cloud-001:~# systemctl enable mariadb@.service root@cloud-001:~# mysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 35 Server version: 10.3.34-MariaDB-0ubuntu0.20.04.1-log Ubuntu 20.04 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. # 设置密码 MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456';
安装 redis
root@cloud-001:~# sudo apt-get install redis-server -y # 添加密码 root@cloud-001:~# vim /etc/redis/redis.conf requirepass 123456 # 开启自动启动 root@cloud-001:~# systemctl enable redis-server.service --now root@cloud-001:~# systemctl status redis-server.service
安装 nginx
root@cloud-001:~# apt install nginx root@cloud-001:~# systemctl enable nginx --now root@cloud-001:~# systemctl status nginx
项目部署 - 后端
项目地址(github):
项目地址(gitee):
部署虚拟环境
确保是 python3.10+ 环境
# 安装虚拟环境管理工具 root@cloud-001:~# pip3 install poetry root@cloud-001:~# poetry config virtualenvs.in-project true # 安装ansible ,任何安装方法都可,全局可用即可。 root@cloud-001:~# pip3 install ansible
克隆项目
root@cloud-001:~# mkdir /data/ops root@cloud-001:~# cd /data/ops root@cloud-001:/data/ops# git clone https://gitee.com/pgoops/pgoops.git Cloning into 'pgoops'... remote: Enumerating objects: 5751, done. remote: Counting objects: 100% (5751/5751), done. remote: Compressing objects: 100% (3762/3762), done. remote: Total 5751 (delta 1812), reused 5746 (delta 1810), pack-reused 0 Receiving objects: 100% (5751/5751), 3.45 MiB | 938.00 KiB/s, done. Resolving deltas: 100% (1812/1812), done.
安装依赖包
root@cloud-001:/data/ops# cd pgoops/ root@cloud-001:/data/ops/pgoops# poetry install Updating dependencies Resolving dependencies... (124.2s) Writing lock file ....
创建数据库
# 创建数据库 CREATE DATABASE pgoops DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; # 创建用户 create user 'pgoops'@'%' identified by '123456'; # 授权 grant all privileges on pgoops.* to pgoops@'%' identified by '123456'; # 刷新权限 flush privileges; # 操作记录 root@cloud-001:~# mysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 124 Server version: 10.3.34-MariaDB-0ubuntu0.20.04.1-log Ubuntu 20.04 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> CREATE DATABASE pgoops DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; Query OK, 1 row affected (0.002 sec) MariaDB [(none)]> create user 'pgoops'@'%' identified by '123456'; Query OK, 0 rows affected (0.000 sec) MariaDB [(none)]> grant all privileges on pgoops.* to pgoops@'%' identified by '123456'; Query OK, 0 rows affected (0.000 sec) MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.000 sec) MariaDB [(none)]> exit Bye
创建&修改配置文件
项目中提供了一个标准配置文件模板,按照实际情况进行修改即可。
修改 Mysql 链接地址,redis 链接地址,以及 运行模式。
需改拷贝模板生成配置文件,路径: .../pgoops/config/pgoops.ini
root@cloud-001:/data/ops/pgoops# cp config/pgoops.ini.temp config/pgoops.ini root@cloud-001:/data/ops/pgoops# vim config/pgoops.ini [DEFAULT] mode = prod debug = false [db.mysql.prod] host = 127.0.0.1 port = 3306 name = pgoops user = pgoops password = 123456 options = {"charset": "utf8mb4"} [db.redis.prod] host = 127.0.0.1 port = 6379 password = 123456
初始化 & 运行后端
切记在项目目录下进行操作。
# 按照提示执行此脚本 服务即可起来 root@cloud-001:/data/ops/pgoops# ./inti_pgoops.sh root@cloud-001:/data/ops/pgoops# ss -lnt State Recv-Q Send-Q Local Address:Port Peer Address:Port Process ...... LISTEN 0 4096 127.0.0.1:953 0.0.0.0:* LISTEN 0 50 0.0.0.0:8000 0.0.0.0:* LISTEN 0 300 0.0.0.0:3306 0.0.0.0:* LISTEN 0 511 127.0.0.1:6379 0.0.0.0:* ......
交互式修改用户密码
在项目根目录执行.venv/bin/python3 manage.py shell
进入shell环境
也可以在WEB界面中通过超级管理员账号进行登陆。
# 引入 用户模型 from django.contrib.auth import get_user_model # 查找用户 如果修改 pgoops 则替换 (name='super') super_ops = get_user_model().objects.filter(name='super').first() # 测试引入是否成功,打印即成功 super_ops.name 'super' # 修改密码 super_ops.set_password('123456') # 保存 super_ops.save()
项目部署 - 前端
项目地址(github):
项目地址(gitee):
克隆前端项目
root@cloud-001:/data/ops# git clone https://gitee.com/pgoops/pgoops_web.git Cloning into 'pgoops_web'... remote: Enumerating objects: 431, done. remote: Counting objects: 100% (431/431), done. remote: Compressing objects: 100% (352/352), done. remote: Total 431 (delta 43), reused 431 (delta 43), pack-reused 0 Receiving objects: 100% (431/431), 1.22 MiB | 611.00 KiB/s, done. Resolving deltas: 100% (43/43), done.
项目依赖安装及打包
root@cloud-001:/data/ops# cd pgoops_web/ # 安装依赖包 root@cloud-001:/data/ops/pgoops_web# npm i (⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂⠂) ⠙ idealTree:pgoops_web: sill idealTree buildDeps # 打包项目 root@cloud-001:/data/ops/pgoops_web# npm run build > pgoops_web_www.pgoops.com@1.0.0 build > vue-cli-service build ⠏ Building for production...
Nginx 虚拟主机配置
文件中的路径及地址根据实际情况修改。
root@cloud-001:/usr/local/nginx/conf.d# cat www.pgoops.conf server { listen 80; server_name 0.0.0.0 www.pgoops.com; error_log /var/log/nginx/www_pgoops_error.log info; access_log /var/log/nginx/www_pgoops_access.log; # underscores_in_headers on; location /api { proxy_pass http://127.0.0.1:8000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; if ($request_method = OPTIONS ) { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET,POST,PUT,PATCH,OPTIONS,DELETE"; add_header Access-Control-Allow-Headers "Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,If-None-Match,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With"; add_header Access-Control-Allow-Credentials "true"; } } location /admin { proxy_pass http://127.0.0.1:8000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /static/ { alias /data/ops/pgoops/static/; } location /media/ { alias /data/ops/pgoops/upload/; } location / { root /data/ops/pgoops_web/dist; index index.html index.htm; try_files $uri $uri/ /index.html =404; add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods "GET,POST,PUT,PATCH,OPTIONS,DELETE"; add_header Access-Control-Allow-Headers "Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,If-None-Match,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With"; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }
访问测试
确保服务运行正常
root@cloud-001:~# systemctl is-active pgoops-celery-server.service active root@cloud-001:~# systemctl is-active pgoops-celery-beat.service active root@cloud-001:~# systemctl is-active pgoops-server.service active root@cloud-001:~# systemctl is-active nginx active
>>>> 前端 地址: http://ip_addr/" >>>> 管理 地址: http://ip_addr/admin/" >>>> 超级管理员用户: pgoops 密码: 123456" >>>> 普通管理员用户: super 密码: 123456" >>>> 普通 用户: edit 密码: 123456" >>>> 官网 地址: http://www.pgoops.com"
这篇关于PgoOps运维平台部署文档的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-24MongoDB资料:新手入门完全指南
- 2024-12-20go-zero 框架的 RPC 服务 启动start和停止 底层是怎么实现的?-icode9专业技术文章分享
- 2024-12-19Go-Zero 框架的 RPC 服务启动和停止的基本机制和过程是怎么实现的?-icode9专业技术文章分享
- 2024-12-18怎么在golang中使用gRPC测试mock数据?-icode9专业技术文章分享
- 2024-12-15掌握PageRank算法核心!你离Google优化高手只差一步!
- 2024-12-15GORM 中的标签 gorm:"index"是什么?-icode9专业技术文章分享
- 2024-12-11怎么在 Go 语言中获取 Open vSwitch (OVS) 的桥接信息(Bridge)?-icode9专业技术文章分享
- 2024-12-11怎么用Go 语言的库来与 Open vSwitch 进行交互?-icode9专业技术文章分享
- 2024-12-11怎么在 go-zero 项目中发送阿里云短信?-icode9专业技术文章分享
- 2024-12-11怎么使用阿里云 Go SDK (alibaba-cloud-sdk-go) 发送短信?-icode9专业技术文章分享