zoukankan      html  css  js  c++  java
  • centos7 安装 python3 、docker、 docker-compose 脚本

    需要先yum -y install wget
    centos7 一键安装python3
    vi install_py3.py
    python install_py3.py
    #coding=utf-8
    import subprocess
    import os,sys
    def exe_cmd(cmd):
        p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
        while True:
            next_line = p.stdout.readline()
            return_line = next_line.decode("utf-8", "ignore")
            if return_line == '' and p.poll() != None:
                break
            print(return_line)
        stdout, stderr = p.communicate()
        if p.returncode != 0:
            return False
        return True
    
    def main():
        print ("python 3.7.2 一键安装开始!")
        backinfo = exe_cmd('ping -c 1 -w 1 www.baidu.com')
        if backinfo == False:
            print ("网络检测失败程序退出,请重新检测网络环境!")
            sys.exit()
        print ("网络连接正常!")
        yum_jc = exe_cmd('yum list')
        if yum_jc == False:
            print ("yum 不可用,请先手动配置yum安装!")
            sys.exit()
        print ('yum安装检测可用!')
    
        exe_cmd("yum install gcc -y")
        exe_cmd("yum install openssl-devel bizp2-devel expat-devel gdbm-devel readline-devel sqlite-devel libffi-devel -y")
        exe_cmd("wget http://npm.taobao.org/mirrors/python/3.7.2/Python-3.7.2.tgz")
        exe_cmd("tar -zxvf Python-3.7.2.tgz")
        exe_cmd("mv Python-3.7.2 /usr/local/")
        exe_cmd("rm -rf Python-3.7.2.tgz")
        os.chdir('/usr/local/Python-3.7.2')
        exe_cmd("./configure")
        exe_cmd("make")
        exe_cmd("make install")
        print ("程序执行完成!输入python3 查看效果。")
    
    if __name__ == '__main__':
        main()
    安装docker shell脚本:
    #!/bin/bash
    
    echo "Installing docker..."
    
    sudo yum remove -y docker 
                      docker-client 
                      docker-client-latest 
                      docker-common 
                      docker-latest 
                      docker-latest-logrotate 
                      docker-logrotate 
                      docker-engine && 
    
    sudo yum install -y yum-utils 
      device-mapper-persistent-data 
      lvm2 && 
    
    sudo yum-config-manager 
        --add-repo 
        https://download.docker.com/linux/centos/docker-ce.repo && 
    
    sudo yum install -y docker-ce docker-ce-cli containerd.io && 
    
    sudo systemctl enable docker && 
    
    if [ ! -d "/etc/docker" ]; then
    mkdir /etc/docker
    fi
    
    //该处是生成docker日志清理的配置文件。
    cat > /etc/docker/daemon.json << EOF
    {
      "registry-mirrors": ["https://XXXXXXXXXXX.mirror.aliyuncs.com"], //该处需要修改你阿里云加速器的地址,指定直接取消注释填写即可
      "log-driver":"json-file",
      "log-opts": {"max-size":"500m", "max-file":"3"}
    }
    EOF
    
    sudo systemctl start docker
    
    echo "Docker has been installed!"
    安装docker-compose
    #!/bin/bash
    yum -y install epel-release &&  
    yum -y install python-pip &&
    pip
    install --upgrade pip &&
    yum -y install python-devel python-subprocess32 &&
    find / -name *subpro*.egg-info &&
    find / -name *subpro*.egg-info |xargs rm -rf &&
    pip
    install docker-compose &&
    docker
    -compose version &&
    echo "docker-compose install successful"
  • 相关阅读:
    Windows系统自带工具的 cmd 命令
    阿里巴巴集团2016校园招聘-Python工程师笔试题(附加题+部分答案)
    小米3刷机说明
    第3章 常用运算符
    第1章Java入门体验
    jQuery表单验证案例
    jQuery超链接提示,提示跟随鼠标动
    [转载]我的Java后端书架 (2016年暖冬4.0版)
    PHP代码重用与函数编写
    PHP数组操作
  • 原文地址:https://www.cnblogs.com/fqnb001/p/12484050.html
Copyright © 2011-2022 走看看