1. <dd id="erndk"></dd>
                1. PgoOps運維平臺部署文檔

                  互聯網 2022/5/2 6:12:57

                  簡介 官網: http://www.pgoops.com gitee: https://gitee.com/pgoops github: https://github.com/yanshicheng/pgoops 準備工作 ? 準備工作如果已經安裝好了環境可以越過。 編譯安裝 Python3.10 項目基于 python 3.10+ ,確保 python 和 pip 正確配置 下載軟件包 root@c…

                  簡介

                  官網: 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"
                  
                  隨時隨地學軟件編程-關注百度小程序和微信小程序
                  關于找一找教程網

                  本站文章僅代表作者觀點,不代表本站立場,所有文章非營利性免費分享。
                  本站提供了軟件編程、網站開發技術、服務器運維、人工智能等等IT技術文章,希望廣大程序員努力學習,讓我們用科技改變世界。
                  [PgoOps運維平臺部署文檔]http://www.yachtsalesaustralia.com/tech/detail-318647.html

                  贊(0)
                  關注微信小程序
                  程序員編程王-隨時隨地學編程

                  掃描二維碼或查找【程序員編程王】

                  可以隨時隨地學編程啦!

                  技術文章導航 更多>
                  国产在线拍揄自揄视频菠萝

                        1. <dd id="erndk"></dd>