1、shell实现无密码登陆

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

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

network="eth0"
host1=`uname -n`
base=`uname -n|cut -c -`
id1=`uname -n|cut -c -`
if ((#$id1 % == ));then
        ((id2=#$id1+))
else
        ((id2=#$id1-))
fi
if ((#$id1 < || #$id1 == ));then
        host2=${base}${id2}
elif ((#$id1 < || #$id1 == ));then
        host2=${base}${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=
gpgcheck=
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=
gpgcheck=
gpgkey=ftp://10.0.0.2/mnt/rhel6.6/RPM-GPG-KEY-redhat-release

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

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

#cd /mnt/;nohup tiotest -f  -b  -t  >/tmp/d1.`hostname`.out >& &
#cd /mnt/;nohup tiotest -f -b -t >/tmp/d2.`hostname`.out >& &
#cd /mnt/;nohup tiotest -f -b -t >/tmp/d3.`hostname`.out >& &
cd /mnt/;nohup tiotest -f -b -t >>/tmp/d4.`hostname`.out >& &
cd /mnt/;nohup tiotest -f -b -t >>/tmp/d5.`hostname`.out >& &
cd /mnt/;nohup tiotest -f -b -t >>/tmp/d6.`hostname`.out >& &
~                                                                               

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.
   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./bin:

8、使用tiotest的简单脚本

base=`hostname|cut -c -`
   ((idx=#$base*-))
   if [ x$ = x ];then
        echo "too few argument"
        exit
   fi
   mkdir -p result/$
   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

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

日常使用的shell脚本的更多相关文章

  1. Shell脚本字符串匹配及日常命令工具 - 用法总结(技巧指南)

    Shell提供了很多字符串和文件处理的命令,如awk.expr.grep.sed等命令,还有文件的排序.合并和分割等一系列的操作命令.下面重点总结下Shell字符串处理.文本处理以及各类命令及函数用法 ...

  2. 日常运维中的相关日志切割处理方法总结 [Logrotate、python、shell脚本实现 ]

    对于Linux系统安全来说,日志文件是极其重要的工具.不知为何,我发现很多运维同学的服务器上都运行着一些诸如每天切分Nginx日志之类的CRON脚本,大家似乎遗忘了Logrotate,争相发明自己的轮 ...

  3. 博主日常工作中使用的shell脚本分享

    前言: 今天给大家分享一篇在我工作中常用的一个shell脚本,里面有一些我们常用到的shell操作.该脚本用于本地电脑和服务器交互上,实现以下功能: 自动拉取自己个人电脑上的源码到服务器上yocto包 ...

  4. 学习 shell脚本之前的基础知识

    转载自:http://www.92csz.com/study/linux/12.htm  学习 shell脚本之前的基础知识 日常的linux系统管理工作中必不可少的就是shell脚本,如果不会写sh ...

  5. shell脚本调试之工具——bashdb

    bash是Unix/Linux操作系统最常用的shell之一,它非常灵活,和awk.c++配合起来异常强大 以下使用一个测试脚本来说明使用bash调试的方法 test.sh #!/bin/bash e ...

  6. Linux Shell脚本面试25问

    Q:1 Shell脚本是什么.它是必需的吗? 答:一个Shell脚本是一个文本文件,包含一个或多个命令.作为系统管理员,我们经常需要使用多个命令来完成一项任务,我们可以添加这些所有命令在一个文本文件( ...

  7. 阿里Linux Shell脚本面试25个经典问答

    转载: 阿里Linux Shell脚本面试25个经典问答 Q:1 Shell脚本是什么.它是必需的吗? 答:一个Shell脚本是一个文本文件,包含一个或多个命令.作为系统管理员,我们经常需要使用多个命 ...

  8. 系统管理中 bash shell 脚本常用方法总结

    在日常系统管理工作中,需要编写脚本来完成特定的功能,编写shell脚本是一个基本功了!在编写的过程中,掌握一些常用的技巧和语法就可以完成大部分功能了,也就是2/8原则 1. 单引号和双引号的区别 单引 ...

  9. 【转】Linux Shell脚本面试25问

    Q:1 Shell脚本是什么.它是必需的吗? 答:一个Shell脚本是一个文本文件,包含一个或多个命令.作为系统管理员,我们经常需要使用多个命令来完成一项任务,我们可以添加这些所有命令在一个文本文件( ...

随机推荐

  1. CSS基础知识真难啊-position-relative-absolute

    http://blog.csdn.net/libertea/article/details/11662661 -----------position:relative:生成相对定位的元素,相对于其正常 ...

  2. 加州大学伯克利分校Stat2.3x Inference 统计推断学习笔记: Section 3 One-sample and two-sample tests

    Stat2.3x Inference(统计推断)课程由加州大学伯克利分校(University of California, Berkeley)于2014年在edX平台讲授. PDF笔记下载(Acad ...

  3. Centos7更新firefox

    1.用你本地的旧版 firefox,访问http://www.firefox.com.cn,下载Linux版本的Firefox. 2.进入存放下载文件(Firefox-latest-x86_64.ta ...

  4. 常见linux命令释义(第二天)

    查看磁盘与目录的容量. df 与du df  是英语Disk Free的意思.磁盘空余. df -h  -h中h指的是一human(人类)的角度,即用GB,MB的格式显示.这个比较常用,还有其他的选项 ...

  5. hibernate----(Hql)查询

    package com.etc.test; import java.util.List;import java.util.Properties; import org.hibernate.Query; ...

  6. uC/OS-II邮箱(mbox)块

    /*************************************************************************************************** ...

  7. const 和 readonly 修饰符的用法

    1. 只有C#内置类型(int,double,long等)可以声明为const;结果.类和数组不能声明为const. 2. readonly 是在字段上使用的修饰符,直接以类名.字段访问. 3. co ...

  8. 删除ibus之后导致系统设置进不了

    sudo apt-get instal ubuntu-desktop 快捷键调出sogou拼音,默认为"ctrl+,"

  9. Java——新IO 通道

    import java.io.File; import java.io.FileOutputStream; import java.nio.ByteBuffer; import java.nio.ch ...

  10. JPG / TGA

    JPG http://www.openjpeg.org http://libjpeg.sourceforge.net TGA http://tgalib.sourceforge.net