zoukankan      html  css  js  c++  java
  • saltops 安装及相关环境安装

    本次布署测试环境 阿里云 Centos 7.3

    1、安装nginx,这里采用yum 安装方式

    A、yum install nginx

    B、创建开机启动

    systemctl enable nginx.service

    C、启动nginx

    systemctl start nginx.service

    D、默认NGINX网站目录为/usr/share/nginx/html,配置文件为/etc/nginx/nginx.conf

    2、安装mysql数据库,由于centos7 默认yum没有mysql库,本次安装的是mariadb,大小59 M

    A、yum install mariadb-server mariadb 

    B、创建开机启动

    systemctl enable mariadb

    C、启动mariadb

    systemctl start mariadb

    mariadb数据库的相关命令是:

    systemctl start mariadb  #启动MariaDB

    systemctl stop mariadb  #停止MariaDB

    systemctl restart mariadb  #重启MariaDB

    systemctl enable mariadb  #设置开机启动

    D、mysql配置文件为/etc/my.cnf

    最后加上编码配置

    [mysql]
    default-character-set =utf8

    E、远程连接配置

    把在所有数据库的所有表的所有权限赋值给位于所有IP地址的root用户。

    mysql> grant all privileges on *.* to root@'%'identified by 'password';

    如果是新用户而不是root,则要先新建用户

    mysql>create user 'username'@'%' identified by 'password';  

    此时就可以进行远程连接了。

    3、python3 安装

    A、先安装一些我遇到的依赖问题(如果有依赖问题按提示安装):切记一定要安装 不然会导致 某些模块无法加载

    yum install xz gcc zlib zlib-devel  openssl-devel sqlite-devel

    B、下载官网安装包 wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz

    解压文件

    xz -d Python-3.6.1.tar.xz

    tar -xvf Python-3.6.1.tar

    C、进行python安装

    进入文件目录

    cd Python-3.6.1

    开始安装编译

    ./configure --prefix=/usr/python3.6
    make
    make install
     

    D、让centos7 系统默认使用python3.6

    cd /usr/bin/
    mv python python.bak
    mv pip pip.bak
    ln -/usr/python3.6/bin/python3 /usr/bin/python
    ln -/usr/python3.6/bin/pip3 /usr/bin/pip
    [root@python bin]# python
    Python 3.6.1 (default, May 25 201720:20:35)
    [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
    Type "help""copyright""credits" or "license" for more information.
    >>>
     
     

    E、因为yum使用的是python2,替换python3之后可能导致无法正常工作,继续使用这个python2.7.5因为yum使用python2,因此替换为python3后可能无法正常工作,继续使用这个python2.7.5

    因此修改yum配置文件(vim /usr/bin/yum)。 

    把文件头部的#!/usr/bin/python改成#!/usr/bin/python2.7保存退出即可

    如果出现以下错误:

    File "/usr/libexec/urlgrabber-ext-down", line 28
        except OSError, e:
                      ^
    SyntaxError: invalid syntax
     

    解决办法是修改

    vim /usr/libexec/urlgrabber-ext-down

    将/usr/bin/python改为/usr/bin/python2.7

    4、saltops 获取及安装

    yum install git  #如果系统已安装此忽略

    chmod 777 /opt

    cd /opt/ git clone http://git.oschina.net/wuwenhao/saltops.git saltops

    A、请确认系统默认python 为python3 否则请 将python更改为python3

    安装saltops依赖

    cd /opt/saltops/

    sudo pip install -r ./requiement.txt

    Successfully installed Babel-2.3.4 Django-1.11.4 Flask-0.12 Jinja2-2.9.4 Markdown-2.6.7 MarkupSafe-0.23 PyInstaller-3.2 PyMySQL-0.7.11 PyYAML-3.12 Werkzeug-0.11.15 alabaster-0.7.9 amqp-1.4.9 anyjson-0.3.3 appdirs-1.4.3 arrow-0.10.0 backports-abc-0.5 better-exceptions-0.1.7 billiard-3.3.0.23 celery-3.1.25 certifi-2016.9.26 click-6.7 coverage-4.4.1 diff-match-patch-20121119 django-admin-tools-0.8.0 django-braces-1.11.0 django-celery-3.2.1 django-clever-selects-0.7.1 django-crontab-0.7.1 django-debug-toolbar-1.6 django-export-csv-0.1.2 django-filter-1.0.1 django-import-export-0.5.1 django-jet-1.0.4 django-mptt-0.8.7 django-nested-inline-0.3.6 django-post-office-2.0.8 django-queryset-csv-1.0.0 django-searchable-select-1.4.3.post1 django-smart-selects-1.5.2 django-suit-0.2.24 django-suit-dashboard-1.0.3 django-widget-tweaks-1.4.1 django-yamlfield-1.0.3 djangorestframework-3.5.3 docutils-0.13.1 futures-3.0.5 gevent-1.2.2 greenlet-0.4.12 gunicorn-19.7.1 imagesize-0.7.1 itsdangerous-0.24 jsonfield-1.0.3 kombu-3.0.37 libsaas-0.4 msgpack-python-0.4.8 packaging-16.8 psutil-5.1.0 pyparsing-2.2.0 python-dateutil-2.6.0 pytz-2017.2 pyzmq-16.0.2 requests-2.13.0 six-1.10.0 sqlparse-0.2.2 tablib-0.11.4 unicodecsv-0.14.1 xlrd-1.0.0

    B、 安装saltstack,因阿里云自带源,此省处添加源。。

    yum install salt-master

    yum install salt-minion

    yum install salt-api

    C、配置 saltstack

    配置文件在 /etc/salt/下

    修改 salt-master与salt-minion  配置文件如下

    file_roots:
      base:
       - /srv/salt/

    修改salt-minion 配置文件

    master: 127.0.0.1   指定 salt-master主机

    D、启动salt-master

    当启动 minion端时报错 “ImportError: No module named salt.scripts

    由于系统默认python为 python3 请修改 /usr/bin/salt-master  /usr/bin/salt-minion  /usr/bin/salt-api  /usr/bin/salt-* 文件头为 #!/usr/bin/python2

    然后依次将salt-master salt-minion  salt-api 加入系统启动项目并启动

    systemctl enable salt-master

    systemctl enable salt-minion

    systemctl enable salt-api

    在 /etc/salt/master 配置文件最后加上

    rest_cherrypy:

      port: 8001

      debug: True

      ssl_crt: /etc/pki/tls/certs/localhost.crt

      ssl_key: /etc/pki/tls/certs/localhost.key

      disable_ssl: True

    external_auth:

      pam:

        你的用户名:

          - .*

          - '@wheel'

          - '@runner'

    E、创建用户给salt-api使用

    创建用户,saltapi认证使用

     
    1. useradd -M -s /sbin/nologin saltops    
    2. echo 'saltops' | passwd saltops --stdin   

    在 /usr/bin目录下执行

    ./salt-key -L

    ./salt-key -a 127.0.0.1

    [root@iZ2ze6pzqmrqo3jwg680waZ bin]# salt-key list
    Accepted Keys:
    2
    Denied Keys:
    Unaccepted Keys:
    Rejected Keys:

     创建自签名证书

    salt-call tls.create_self_signed_cert 

    提示已经存在时,可以删除/etc/pki/tls/certs/localhost.crt  /etc/pki/tls/certs/localhost.key重新生成

    F进行测试 

    curl -k http://127.0.0.1:8001/login -H "Accept: application/x-yaml" -d username='saltops' -d password='saltops' -d eauth='pam'

    #用上面那条命令拿到的token来执行下面这条命令

    curl -k http://127.0.0.1:8001 -H "Accept: application/x-yaml" -H "X-Auth-Token: b69c3cb8882bbacb19ab7b09a964dd7e2a17e6a5" -d client='local' -d tgt='*' -d fun='test.ping'

    return:
    - '2': true

    5 启动saltops  #默认用的sqlite3,可以换成自己喜欢的DB

     python manage.py makemigrations && python manage.py migrate

    python manage.py celery worker --loglevel=info

    python manage.py celery beat

    python manage.py runserver 0.0.0.0:8000

    至止salt-ops简单测试完成

    下一步将用wsgi+nginx 布署

  • 相关阅读:
    android5.1 修改音量键绑定多媒体声音
    如何使用Android Studio开发/调试Android源码
    git远程从入门到放弃
    java.lang.IllegalStateException: Restarter has not been initialized
    SpringBoot,Vue前后端分离开发首秀
    SpringBoot结合swagger2快速生成简单的接口文档
    SpringBoot整合SpringData JPA入门到入坟
    SpringBoot结合Swagger2自动生成api文档
    uni-app初体验及打包成apk
    Jave Web阿里云短信服务发送验证码
  • 原文地址:https://www.cnblogs.com/IPYQ/p/7453722.html
Copyright © 2011-2022 走看看