zoukankan      html  css  js  c++  java
  • devops--day3

    昨日内容回顾

    git push origin --delete name

    git log --pretty=format:"%h:%s:%an"

    git rebase 变基 将提交记录合并成一条直线

    git fetch 只拉取不合并

    git merge 合并

    .gitignore

    git tag 查看标签

    git tag -a name -m "" 创建标签

    git tag -a name -m "" hash值 给之前的创建一个标签

    git tag -d name 删除

    git push origin --tags 将本地的标签都推送到远程

    git show name 查看详情

    git push origin :refs/tags/name

    git checkout name 切换标签

    git checkout filename 将指定文件会退到最近一次提交的地方

    给别人贡献代码

    • 合作人
    • 新建一个组织
    • fork+new pull request

    正则

    openpyxl

    from openpyxl import Workbook
    wb=Workbook()
    wb1=wb.create_sheet("name",index)
    wb.active
    wb1.title=""
    wb1["A3"]=
    wb1.cell(row=3,column=3,vlaue="")
    wb1.append([])
    wb.save("1.xlsx")
    
    from openpyxl import load_workbook
    #data_only 获取函数的值 read_only 只读
    wb=load_workbook(filename,data_only=True,read_only=True)
    wb.sheetnames
    wb1=wb["name"]
    wb1["A3"].value
    wb1.cell(row=3,column=4).value
    wb1.rows
    wb1.columns 不能用read_only
    wb1.max_row
    wb1.max_column
    

    ansible

    用来批量在远程主机上执行命令或者脚本的一个工具

    python 2.7

    saltstack python

    puppet ruby https ssl认证

    pip install

    下载源码

    python setup.py build

    python setup.py install

    编译安装

    • configure
    • make
    • make install

    1.epel源(第三方的rpm包)

    编译安装

    yum 安装 rpm

    https://opsx.alibaba.com/mirror 阿里镜像网站

    163

    sohu

    ali

    腾讯

    清华

    北大

    中科院

    docke ce 社区版本 开源

    docker ee 商业版本 oracle redhat

    128 是管理者 控制节点

    129 130 131 是被控节点

    安装ansible

    #安装wget
    yum install -y wget
    #下载epel源
    wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
    #安装ansible
    yum install -y ansible
    

    命令格式

    ansible --help
    Usage: ansible <host-pattern> [options]
     -a MODULE_ARGS #模块参数 ,一个命令就是一个模块
     -C, --check 不会真正的执行,但是会白跑一次,干跑
     -f FORKS 指定进程数,高并发
     --list-hosts 列出匹配到的主机列表
     -m MODULE_NAME, 指定模块
     --syntax-check 语法检查
     -k, --ask-pass  输入密码
    

    ping 走的是ICMP 协议(作业)

    /etc/ansible/ansible.cfg #配置文件
    /etc/ansible/hosts
    /etc/ansible/roles #
    
    hosts
    # This is the default ansible 'hosts' file.
    #
    # It should live in /etc/ansible/hosts
    #
    #   - Comments begin with the '#' character #号用来注释
    #   - Blank lines are ignored 空行可以被忽略
    #   - Groups of hosts are delimited by [header] elements
    #   - You can enter hostnames or ip addresses 可以输入主机名或者ip地址
    #   - A hostname/ip can be a member of multiple groups 一个ip或者主机可以被分在多个组
    #10.0.0.129
    #10.0.0.130
    #10.0.0.131
    [web]
    10.0.0.129
    10.0.0.130
    [db]
    10.0.0.130
    10.0.0.131
    [cache]
    10.0.0.131
    #www[001:006].example.com www001 - www006 
    

    ping

    ansible 10.0.0.129 -m ping -k
    ansible 10.0.0.130 -m ping 
    ansible 10.0.0.131 -m ping
    ansible 10.0.0.130,10.0.0.129 -m ping
    ansible all -m ping
    ansible web -m ping
    ansible web,db -m ping
    ansible "web:&db" -m ping
    ansible 'web:!db' -m ping
    

    秘钥

    ssh-keygen #生成秘钥 一直回车 秘钥对 公钥 私钥
    ssh-copy-id root@ip #将本地的key复制到远程机器
    vi /etc/ssh/sshd_config 
    修改UserDNS no 
    sed  -i "s@#UseDNS yes@UseDNS no@" /etc/ssh/sshd_config 
    systemctl restart sshd 重启sshd
    

    交集 有相同的

    并集 合并的集合

    差集 相差的集合

    host-pattern 写法

    • 单个的ip地址

    • 多个的ip地址 用,隔开

    • 所有的ip地址 all

    • 单个的组

    • 多个的组

      • 交集
        • 'web:&db'
      • 并集
        • web,db
        • 'web:db'
      • 差集 表示在前面,但是不在后面的
        • 'web:!db'

      ansible-doc

      Usage: ansible-doc [-l|-F|-s] [options] [-t <plugin type> ] [plugin]
      -j 以json的方式返回所有的模块信息
      -l 列出所有的模块
      -s 简短的方式来展示模块信息
      [root@bogon ~]# ansible-doc -l|wc -l
      2834
      ansible-doc ping 查看详细信息
      

      A10 F5

      aws 亚马逊云

      azure 微软云

      command

      ansible web -a "pwd"  执行命令
      ansible web -a "ls"
      ansible web -a "chdir=/tmp pwd" 先切换目录在执行命令,一般用在编译
      ansible web -a "creates=/tmp pwd"  命令不会被执行,因为/tmp是存在的
      ansible web -a "creates=/tmp2 pwd" 命令会被执行,因为/tmp2目录是不存在的
      ansible web -a "removes=/tmp2 pwd" 命令不会被执行 ,因为/tmp2目录不存在
      ansible web -a "removes=/tmp pwd" 命令会被执行,因为/tmp存在
      ansible web -a "creates=/data mkdir /data" /data目录会被创建,因为/data不存在
      
      

      补充

      查看用户是否创建成功

      id alex
      tail -1 /etc/passwd
      tail -1 /etc/shadow
      su alex
      
      
      

      设置密码

      echo "1" |passwd --stdin alex
      
      

      shell

      ansible web -m shell -a "chdir=/tmp pwd"
      ansible 10.0.0.129 -m shell -a "bash a.sh" 执行脚本 文件可以没有执行权限
      ansible 10.0.0.129 -m shell -a "/root/a.sh" 执行脚本 文件必须要有执行权限
      ansible 10.0.0.129 -m shell -a "python a.py"
      ansible 10.0.0.129 -m shell -a "/root/a.py"
      如果说脚本里面指定了解释器,那么就用执行的解释器来解释,如果没有指定解释器的话,则用bash 
      shabang 
      
      

      补充

      [root@localhost ~]# cat a.sh 
      #!/bin/bash
      echo "shell"
      [root@localhost ~]# bash a.sh
      shell
      [root@localhost ~]# chmod +x a.sh 
      [root@localhost ~]# ./a.sh 
      shell
      [root@localhost ~]# python a.py 
      停车坐爱枫林晚,霜叶红于二月花
      [root@localhost ~]# ./a.py
      -bash: ./a.py: Permission denied
      [root@localhost ~]# chmod +x a.py 
      [root@localhost ~]# ./a.py
      停车坐爱枫林晚,霜叶红于二月花
      [root@localhost ~]# cat a.py
      #!/usr/bin/python
      #coding:utf-8
      print("停车坐爱枫林晚,霜叶红于二月花")
      
      
      

      script

      文件必须得有执行权限
      ansible web -m script -a "/root/a.sh"
      ansible web -m script -a "a.sh"
      ansible web -m script -a "chdir=/tmp a.sh" 先切换目录在执行脚本
      ansible web -m script -a "creates=/root/a.sh a.sh" 判断的是远程主机上是否存在文件,如果存在就跳过
      ansible web -m script -a "removes=/root/a.sh a.sh" 判断远程主机上是否存在,如果存在的话就执行
      
      

    今日内容总结

    git 使用ssh的方式上传或者下载文件

    pycharm里面的git客户端

    ansible

    • 安装 epel源

    • host-pattern格式

      • 单个ip
      • 多个ip地址,用,分割
      • all 所有的ip地址
      • 单个组
      • 多个组
        • 交集
          • 'web:&db'
        • 并集
          • web,db
          • 'web:db'
        • 差集 前面存在,但是后面没有
          • 'web:!db'

      ping

      ansible 是基于ssh的

      command 执行远程主机上的命令,不支持特殊字符 $ < > | & !

      • chdir 切换目录,编译的时候
      • creates 判断是否存在,如果存在,就不执行
      • removes 判断是否存在,如果存在,就执行

      shell 执行远程主机上的命令或者脚本

      • chdir 切换目录,编译的时候
      • creates 判断是否存在,如果存在,就不执行
      • removes 判断是否存在,如果存在,就执行

      script 执行本地的脚本(管理机上) 脚本必须要有执行的权限

      • chdir 切换目录,编译的时候
      • creates 判断远程是否存在,如果存在,就不执行
      • removes 判断远程是否存在,如果存在,就执行

    作业

    icmp

    把crm分页 找出来

    复习linux

    用户

    用户组

    yum

    pip

    crontab

    systemctl

    service

    vim

  • 相关阅读:
    智能电视可以安装软件就可以摆脱很多限制,而且可以和PC共享影音资源这个很靠谱。
    【转载】福昕PDF电子文档处理套件 企业版 注册码 注册方法
    OS X系列文章 AirPlay+Apple TV影音方案研究[转]
    SHARP 316L打印机64位驱动问题
    我和电脑的二三事
    北信源DeviceRegister.exe的卸载方法 【转】
    上篇随笔的补充。
    ApplicationCommands用于表示应用程序程序员经常遇到的常见命令,类似于ctrl+c
    WPF中类似使用tab键功能,可以向上向下定位
    c#通过datatable导出excel和word
  • 原文地址:https://www.cnblogs.com/Doner/p/11187025.html
Copyright © 2011-2022 走看看