• OMS自动化运维平台部署


    OMS自动化运维平台部署

    一、基础环境安装

    yum -y install mariadb mariadb-devel mariadb-server wget epel-release python-devel gcc c++ make openssl openssl-devel passwd libffi libffi-devel pyOpenSSL git
    yum -y install salt-master salt-minion salt-api nginx 
    wget https://bootstrap.pypa.io/get-pip.py
    python get-pip.py
    

    二、配置salt-api

    pip install pyOpenSSL==0.15.1  -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
    useradd -M -s /sbin/nologin saltapi && echo "password"|/usr/bin/passwd saltapi --stdin
    salt-call --local tls.create_self_signed_cert
    

    1.配置文件修改

    cat > /etc/salt/master <<EOF
    interface: 0.0.0.0
    
    external_auth:
      pam:
        saltapi:
          - .*
          - '@wheel'
          - '@runner'
          - '@jobs'
    
    rest_cherrypy:
      port: 8000
      ssl_crt: /etc/pki/tls/certs/localhost.crt
      ssl_key: /etc/pki/tls/certs/localhost.key
    
    file_recv: True
    
    include: /data/www/SOMS/saltconfig/*.conf
    EOF
    

    2.启动服务,测试salt-api

    systemctl start salt-master salt-api salt-minion
    curl -sSk https://localhost:8000/login -H 'Accept: application/x-yaml' -d username=saltapi -d password=password -d eauth=pam
    

    三、部署soms项目

    #克隆项目
    cd /data/www/
    git clone https://github.com/qitan/SOMS.git
    #安装依赖
    cd SOMS
    pip install -r requirements.txt
    #同步数据库
    python manage.py makemigrations
    python manage.py migrate
    #创建管理员
    python manage.py createsuperuser
    #配置文件修改
    vim soms/settings_local.py里的相关信息
    #runserver运行检查是否正常
    python manage.py runserver 0.0.0.0:8080
    

    四、被管理端minion配置

    #安装
    yum -y install salt-minion
    #将master ip添加到hosts
    vim /etc/hosts
    127.0.0.1 master
    sed -i 's/#master:.*/master: master/' /etc/salt/minion
    #设置minion标识,设置为ip地址
    echo "local ip" > /etc/salt/minion_id
    #启动
    systemctl restart salt-minion
    
    #master主机上执行认证
    salt-key -L
    salt-key -A -y  
    检查master主机是否能正常在minion上执行命令
    salt '*' test.ping
    

    五、uwsgi+nginx结合配置

    1.编写uwsgi配置

    cat > soms.ini <<EOF
    [uwsgi]
    chdir=/data/www/SOMS/
    module=soms.wsgi:application 
    master=True 
    pidfile=/data/www/SOMS/soms.pid 
    vacuum=True 
    max-requests=1000 
    daemonize=/data/www/SOMS/soms.log
    socket = 0.0.0.0:10000
    #http = 0.0.0.0:10000
    EOF
    

    2.安装uwsgi并运行

    pip install uwsgi -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
    uwsgi --http 0.0.0.0:10000 --module soms.wsgi
    

    3.安装nginx并编写nginx配置文件

    $ yum -y install nginx
    $ cat > /etc/nginx/conf.d/soms.test.com.conf <<EOF
    server
            {
            listen 80;
            server_name soms.test.com;
    
            access_log  /data/www/SOMS/soms.test.com.access.log main;
    
            location / {
                root /data/www/SOMS;
    
            ## uwsgi配置的端口
                uwsgi_pass 127.0.0.1:10000;
                include uwsgi_params;
                uwsgi_param UWSGI_CHDIR  /data/www/SOMS;
                uwsgi_param UWSGI_SCRIPT wsgi;
            }
            location ~ .*.(log|php|pl|py|sh|cgi)$ {
                    return 403;
            }
            location /static/ {
                    root /data/www/SOMS;
            access_log off;
            }
            location ~ .*.(gif|jpg|png|htm|html|css|js|flv|ico|swf)(.*) {
                    root /data/www/SOMS;
                    expires 30d;
            }
            location ~ .*.(js|css)?(.*)
            {
                    root /data/www/SOMS;
                    expires      12h;
            }
        }
    EOF
    #启动nginx
    systemctl restart nginx
    
  • 相关阅读:
    ASP.NET Core教程:ASP.NET Core使用AutoMapper
    C#:C#调用WebService
    EntityFrameworkCore教程:更新时间映射
    EntityFrameworkCore教程:表名映射
    EntityFrameworkCore教程:Data-Seeding(种子数据)
    EntityFrameworkCore教程:生成数据库表
    EntityFrameworkCore教程:单元测试
    OAF_文件系列5_实现OAF解析XML文件javax.xml.parsers(案例)
    OAF_文件系列4_实现OAF上传显示数据库动态图片Image(案例)
    OAF_文件系列3_实现OAF多行表中附件功能AttachmentImage(案例)
  • 原文地址:https://www.cnblogs.com/Mrhuangrui/p/8579461.html
Copyright © 2020-2023  润新知