From a470b41cbb15ff8f3862981585a23b26d05ce0f5 Mon Sep 17 00:00:00 2001 From: CnpPt <1015830185@qq.com> Date: Thu, 3 Mar 2022 04:33:34 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0docker=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=EF=BC=8C=E5=85=BC=E5=AE=B9=E4=B8=BB=E6=B5=81?= =?UTF-8?q?Linux=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker_maser_salve/docker_maser_salve.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/docker_maser_salve/docker_maser_salve.py b/docker_maser_salve/docker_maser_salve.py index f37d995..d92f8a1 100644 --- a/docker_maser_salve/docker_maser_salve.py +++ b/docker_maser_salve/docker_maser_salve.py @@ -50,17 +50,8 @@ def install_docker(): if int(cmd) == 0: print("docker 未安装,准备开始安装") time.sleep(10) - base("sudo yum install -y yum-utils device-mapper-persistent-data lvm2") - base("sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo") - base("sudo yum makecache fast") - base("sudo yum install -y docker-ce-19.03.5 docker-ce-cli-19.03.5 containerd.io") - if(not os.path.exists("/etc/docker")): - base("mkdir -p /etc/docker") - with open("/etc/docker/daemon.json", "w") as f: - f.write('{\n "registry-mirrors": ["https://9f4w4icn.mirror.aliyuncs.com"] \n}') - base("sudo systemctl daemon-reload") - base("sudo systemctl start docker") - base("sudo systemctl enable docker") + base("sudo curl -fsSL https://get.docker.com | bash -s -- --mirror Aliyun") + base("sudo systemctl enable --now docker") print("docker安装完成") base("sudo docker version") else: -- Gitee From 4e9bf3bd8b59a549df4b256856be4de0c007a4ab Mon Sep 17 00:00:00 2001 From: CnpPt <1015830185@qq.com> Date: Thu, 3 Mar 2022 04:47:18 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E5=AE=89=E8=A3=85=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 12 ++---------- docker_maser_salve/docker_maser_salve.py | 11 ++--------- requirements.txt | 4 ++++ 3 files changed, 8 insertions(+), 19 deletions(-) create mode 100644 requirements.txt diff --git a/README.md b/README.md index 721e44a..e56a5b8 100644 --- a/README.md +++ b/README.md @@ -11,16 +11,8 @@ #### 安装教程 ##### docker方式 -1. 安装python环境 -2. 安装软件包依赖 - -``` -pip3 install cryptography -i https://pypi.douban.com/simple/ -pip3 install rich -i https://pypi.douban.com/simple/ -pip3 install pymysql -i https://pypi.douban.com/simple/ -pip3 install subprocess -i https://pypi.douban.com/simple/ -``` -3. python3 docker_maser_salve.py +1. 安装python3环境及pip +2. python3 docker_maser_salve.py #### K8S方式 按照顺序apply执行即可 diff --git a/docker_maser_salve/docker_maser_salve.py b/docker_maser_salve/docker_maser_salve.py index d92f8a1..a5c1dd7 100644 --- a/docker_maser_salve/docker_maser_salve.py +++ b/docker_maser_salve/docker_maser_salve.py @@ -6,16 +6,9 @@ import argparse import time from pymysql import * from rich import print +from pip._internal import main - -""" -pip3 install cryptography -i https://pypi.douban.com/simple/ -pip3 install rich -i https://pypi.douban.com/simple/ -pip3 install pymysql -i https://pypi.douban.com/simple/ -pip3 install subprocess -i https://pypi.douban.com/simple/ - -""" - +main.main(['install', '-r', 'requirements.txt', '-i', 'https://pypi.douban.com/simple/']) #数据持久化根目录,需先在主机上创建 dbpath = "/data" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a1508a3 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +cryptography +rich +pymysql +subprocess \ No newline at end of file -- Gitee