• 日常使用的shell脚本


    1、shell实现无密码登陆

    host=$1
    expect << EOF
            spawn ssh-copy-id $host
            expect "password:"
            send "123456
    "
    expect eof
    EOF

    2、一个节点分类的shell脚本

    network="eth0"
    host1=`uname -n`
    base=`uname -n|cut -c 1-3`
    id1=`uname -n|cut -c 4-6`
    if ((10#$id1 %2 == 1));then
            ((id2=10#$id1+1))
    else
            ((id2=10#$id1-1))
    fi
    if ((10#$id1 < 9 || 10#$id1 == 10));then
            host2=${base}00${id2}
    elif ((10#$id1 < 99 || 10#$id1 == 100));then
            host2=${base}0${id2}
    else
            host2=${base}${id2}
    fi
    rm -fr /tmp/targets
    mkdir -p /tmp/targets

    #ha.cf

    cp templates/ha.cf /tmp/targets/ha.cf
    echo "ucast $network $host2" >> /tmp/targets/ha.cf
    echo "ping 20.0.255.254" >> /tmp/targets/ha.cf
    echo "auto_failback on" >> /tmp/targets/ha.cf
    echo "node $host1" >> /tmp/targets/ha.cf
    echo "node $host2" >> /tmp/targets/ha.cf

    #haresources

    cp templates/haresources /tmp/targets/haresources
    echo "$host1 Lustre::$host1-targets" >> /tmp/targets/haresources
    echo "$host2 Lustre::$host2-targets" >> /tmp/targets/haresources
    #authkeys
    cp templates/authkeys /tmp/targets/authkeys
    cp -fr /tmp/targets/ha.cf /etc/ha.d/
    cp -fr /tmp/targets/haresources /etc/ha.d/haresources
    cp -fr /tmp/targets/authkeys /etc/ha.d/authkeys


    3、yum源的配置方法,yum源的目标文件为/etc/yum.repos.d/yum.repo

    [Server]
    name=RHEL 6.6
    baseurl=ftp://10.0.0.2/mnt/rhel6.6/Server
    enable=1
    gpgcheck=0
    gpgkey=ftp://10.0.0.2/mnt/rhel6.6/RPM-GPG-KEY-redhat-release
    [HA]
    name=RHEL 6.6 HA
    baseurl=ftp://10.0.0.2/mnt/rhel6.6/HighAvailability
    enable=1
    gpgcheck=0
    gpgkey=ftp://10.0.0.2/mnt/rhel6.6/RPM-GPG-KEY-redhat-release

    4、tiotest测试盘阵性能的脚本(nohup 后台执行)

    5、使用tiotest测试盘阵性能的简单脚本

    #cd /mnt/1;nohup tiotest -f 20000 -b 1048576 -t 8 >/tmp/d1.`hostname`.out 2>&1 & 
    #cd /mnt/2;nohup tiotest -f 20000 -b 1048576 -t 8 >/tmp/d2.`hostname`.out 2>&1 & 
    #cd /mnt/3;nohup tiotest -f 20000 -b 1048576 -t 8 >/tmp/d3.`hostname`.out 2>&1 &
    cd /mnt/4;nohup tiotest -f 20000 -b 1048576 -t 8 >>/tmp/d4.`hostname`.out 2>&1 &
    cd /mnt/5;nohup tiotest -f 20000 -b 1048576 -t 8 >>/tmp/d5.`hostname`.out 2>&1 &
    cd /mnt/6;nohup tiotest -f 20000 -b 1048576 -t 8 >>/tmp/d6.`hostname`.out 2>&1 &
    ~                                                                                


    6、重定向符号的使用

       1> 指标准信息输出路径
       2> 指错误信息输出路径
       2>&1 将标准信息输出路径指定为错误信息输出路径(也就是都输出在一起)

     
    7、添加环境变量
      

    #!/bin/sh
       export SW_CLUSTER_PATH=/usr/sw-cluster
       export MPI_ROOT=$SW_CLUSTER_PATH/mpi2
       export SLURM_ROOT=$SW_CLUSTER_PATH/slurm-14.11.3
       source $SW_CLUSTER_PATH/intel/composer_xe_2013_sp1.3.174/bin/compilervars.sh intel64
       source $SW_CLUSTER_PATH/intel/composer_xe_2013_sp1.4.211//bin/compilervars.sh intel64
       export PATH=$PATH:$SLURM_ROOT/bin:$MPI_ROOT/bin
       export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SLURM_ROOT/lib:$MPI_ROOT/lib
       export PATH=$PATH:/usr/sw-mpp/bin:/usr/sw-cluster/slurm-14.11.3/bin: 

    8、使用tiotest的简单脚本
      

    base=`hostname|cut -c 5-6`
       ((idx=10#$base*3-3))
       if [ x$1 = x ];then
            echo "too few argument"
            exit 1
       fi
       mkdir -p result/$1
       cp /tmp/*.out result/$1/
       for((i=$idx;i<$idx+3;i++));do rm -fr OST$i; done
       for((i=$idx;i<$idx+3;i++));do
            mkdir OST$i
            lfs setstripe -i $i -c 1 OST$i
            if [ $? -ne 0 ];then
                    exit 1
            fi
            cd OST$i
            nohup tiotest -b 1048576 -f 20000 -t 8  > /tmp/OST$i.out 2>&1 &
            cd ..
       done
     
    9、使用tiotest的简单测试脚本
       
       base=`hostname|cut -c 5-6`
         ((idx=10#$base*3-3))
       while true
       do
       for((i=$idx;i<$idx+3;i++));do rm -fr OST$i; done
       for((i=$idx;i<$idx+3;i++));do
            mkdir OST$i
            lfs setstripe -i $i -c 1 OST$i
            cd OST$i
            nohup tiotest -b 1048576 -f 20000 -t 8 -k1 -k2 -k3 > /tmp/OST$i.out 2>&1 &
            done
            sleep 600
            cd ..
       done
       done


    10、挂载nfs网络文件系统
       

        mkdir /usr/sw-cluster -p
        mount -t nfs nfs_nas:/vol/vol_nas001/sw-cluster /usr/sw-cluster
        mkdir /usr/sw-mpp -p
        mount -t nfs nfs_nas:/vol/vol_nas001/sw-mpp-app /usr/sw-mpp


    11、 一个排序的小指令
        
       

     du -sh * |sort -nr


        显示出所有文件的排序和大小                                                          

  • 相关阅读:
    日志记录
    Ajax
    servlet3.0新特性
    文件上传和下载
    过滤器
    listener
    JavaWeb案例:登陆和注册
    jsp
    cookie和session
    HttpRequest,HttpResponse,乱码,转发和重定向
  • 原文地址:https://www.cnblogs.com/wangtao1993/p/5999705.html
Copyright © 2020-2023  润新知