Shell scripts for daily use

Source: Internet
Author: User
Tags gpg

1, shell implementation without password login

host=$1<<ssh-copy-ID"Password: "  "123456\r"expect eofeof

2. A node-categorized shell script

network="eth0"host1=`uname-N ' base=`uname-n|Cut-C1-3' Id1=`uname-n|Cut-C4-6`if((Ten# $id 12==1)); Then((Id2=Ten# $id 1+1))Else((Id2=Ten# $id 1-1))fiif((Ten# $id 1 <9||Ten# $id 1 = =Ten)); ThenHost2=${base}xx${id2}elif((Ten# $id 1 < About||Ten# $id 1 = = -)); ThenHost2=${base}0${id2}ElseHost2=${base}${id2}fi

RM -fr/tmp/targetsmkdir -p/tmp/targets

#ha. CF

CPtemplates/ha.cf/tmp/targets/ha.cfEcho "ucast $network $host 2">>/tmp/targets/ha.cfEcho "Ping 20.0.255.254">>/tmp/targets/ha.cfEcho "Auto_failback on">>/tmp/targets/ha.cfEcho "node $host 1">>/tmp/targets/ha.cfEcho "Node $host 2">>/TMP/TARGETS/HA.CF

#haresources

CPtemplates/haresources/tmp/targets/haresourcesEcho "$host 1 Lustre:: $host 1-targets">>/tmp/targets/haresourcesEcho "$host 2 Lustre:: $host 2-targets">>/tmp/targets/Haresources#authkeysCPtemplates/authkeys/tmp/targets/AuthkeysCP-fr/tmp/targets/ha.cf/etc/ha.d/CP-fr/tmp/targets/haresources/etc/ha.d/haresourcesCP-fr/tmp/targets/authkeys/etc/ha.d/authkeys


3, Yum Source configuration method, yum source target file is/etc/yum.repos.d/yum.repo

[Server]name=rhel6.6BaseURL=FTP://10.0.0.2/mnt/rhel6.6/serverenable=1Gpgcheck=0Gpgkey=FTP://10.0.0.2/mnt/rhel6.6/rpm-gpg-key-redhat-release[Ha]name=rhel6.6Habaseurl=FTP://10.0.0.2/mnt/rhel6.6/highavailabilityenable=1Gpgcheck=0Gpgkey=FTP://10.0.0.2/mnt/rhel6.6/rpm-gpg-key-redhat-release

4, tiotest Test disk array Performance script (nohup background execution)

5. Simple script to test the performance of the disk array using Tiotest

#cd/mnt/1; Nohup tiotest-f20000-B1048576-T8>/tmp/d1. 'hostname'. Out2>&1&#cd/mnt/2; Nohup tiotest-f20000-B1048576-T8>/tmp/d2. 'hostname'. Out2>&1&#cd/mnt/3; Nohup tiotest-f20000-B1048576-T8>/tmp/d3. 'hostname'. Out2>&1&CD/mnt/4; Nohup tiotest-f20000-B1048576-T8>>/tmp/d4. 'hostname'. Out2>&1&CD/mnt/5; Nohup tiotest-f20000-B1048576-T8>>/tmp/d5. 'hostname'. Out2>&1&CD/mnt/6; Nohup tiotest-f20000-B1048576-T8>>/tmp/d6. 'hostname'. Out2>&1&~


6. Use of redirection symbols

1> refers to the standard information output path
2> refers to the error message output path
2>&1 Specify the standard information output path as the error message output path (that is, all output together)


7. Add Environment variables

#!/bin/SHExport Sw_cluster_path=/usr/sw-Cluster export Mpi_root= $SW _cluster_path/MPI2 Export Slurm_root= $SW _cluster_path/slurm-14.11.3Source $SW _cluster_path/intel/composer_xe_2013_sp1.3.174/bin/compilervars.SHIntel64 source $SW _cluster_path/intel/composer_xe_2013_sp1.4.211//bin/compilervars.sh Intel64Export 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. Simple script using Tiotest

Base= 'hostname|Cut-C5-6' (IDX=Ten# $base *3-3))   if[x$1= x]; Then        Echo "too few argument"Exit1   fi   mkdir-P result/$1   CP/tmp/*. Out result/$1/   for ((i= $idx;i< $idx +3;i++));d o rm-fr ost$i; done   for ((i= $idx;i< $idx +3;i++);d o        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 &  &nb sp;     CD.    done 9, simple test script using tiotest       base= ' hostname|cut-c 5-6 '       ((idx=10# $base *3-3)    true   do   for ((i= $idx;i< $idx +3;i++));d o rm-fr ost$i; done   for ((i= $idx;i< $idx +3;i++);d o        mkdir ost$i        LFS setstripe-i $i-C 1 ost$i    & nbsp;   CD ost$i        nohup tiotest-b 1048576-f 20000-t 8-k1-k2-k3 &G T /tmp/ost$i.out 2>&1 &        done         Sleep 600        CD.    done   Done


10. Mount NFS Network File system

    mkdir /usr/sw-cluster-Mount -T NFS  nfs_nas:/vol/vol_nas001/sw-cluster/usr/sw- mkdir /usr/sw-mpp-Mount -T NFS Nfs_nas:/vol/vol_nas001/sw-mpp-app/usr/sw-mpp


11, a sort of small instructions

du -sh * | Sort -nr


Show the sort and size of all files

Shell scripts for daily use

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.