• ansible工具相关常用命令


    uat(装在214上,在214上执行):

    cat  /etc/ansible/hosts

    已添加组:

    [hdp]

    172.30.64.214 ansible_ssh_user=root

    172.30.64.213 ansible_ssh_user=root

    172.30.64.216 ansible_ssh_user=root

    172.30.64.220 ansible_ssh_user=root

    测试:

    ansible  hdp  -m ping

    172.30.64.220 | success >> {

        "changed": false,

        "ping": "pong"

    }

    172.30.64.213 | success >> {

        "changed": false,

        "ping": "pong"

    }

    172.30.64.216 | success >> {

        "changed": false,

        "ping": "pong"

    }

    172.30.64.214 | success >> {

        "changed": false,

        "ping": "pong"

    }

    常用文件操作命令:

    拷贝文件(214上执行):

    ansible hdp -m copy -a "src=/etc/ansible/test.txt  dest=/tmp/"

    拷贝/tmp下面的test目录到hdp组所有节点的tmp目录下:

    ansible hdp -m copy -a "src=/tmp/test  dest=/tmp/"

    拷贝的同时也可以指定所属用户组:

    ansible hdp -m copy -a "src=/tmp/test  dest=/tmp owner=hdfs group=hadoop"

    删除文件:

    ansible hdp -m file -a "dest=/tmp/test.txt state=absent"

    更改文件权限:

    ansible hdp -m file -a "dest=/tmp/test.txt mode=777"

    更改文件所属的用户和组:

    ansible hdp -m file -a "dest=/tmp/test.txt owner=hdfs group=hadoop"

    创建目录:

    ansible hdp -m file -a "dest=/tmp/test  owner=hdfs group=hadoop state=directory"

    创建文件:

    ansible hdp -m file -a "dest=/tmp/test/1.txt  owner=hdfs group=hadoop state=touch"

    pat(装在36节点上):

    hosts文件里已配置几个组,其中25-34是个节点为在solr组里

    ansible storm -m shell -a 'grep 6226930000997489 /var/log/storm/notify-20151231-135801-12-1451541482*log'

    ansible datanode -m shell -a "netstat -tunlp |grep 8986" -u root

    ansible hdp -m shell -a " chmod 777 /root/tcp_monitor.sh " -u root

    ansible hdp -m shell -a " sh /root/tcp_monitor.sh " -u root

    ansible storm -m shell -a 'grep 3015 /var/log/storm/notify-20160331-235433*'


    ansible datanode -m shell -a "netstat -n|awk '/^tcp/{++S[$NF]} END {for (a in S) print a,S[a]}'" -u root


    ansible hdp -m copy -a "src=/root/tcp_monitor.sh dest=/root/tcp_monitor.sh owner=root group=root"
    ansible hdp -m shell -a " chmod 777 /root/tcp_monitor.sh " -u root

  • 相关阅读:
    oracle11g 卸载和安装(win7,32位)
    MySQL忘记密码解决办法
    GPIO硬件资源的申请,内核空间和用户空间的数据交换,ioctl(.....),设备文件的自动创建
    模块参数,系统调用,字符设备编程重要数据结构,设备号的申请与注册,关于cdev的API
    开发环境的搭建,符合导出,打印优先级阈值
    定时器中断
    Linux系统移植的重要文件
    linux 相关指令
    linux各文件夹含义和作用
    外部中断实验
  • 原文地址:https://www.cnblogs.com/riyueyuzhuzhu/p/5584783.html
Copyright © 2020-2023  润新知