Solaris10與EMC-CX3-10c實現(xiàn)FC-SAN實施手冊V2_第1頁
Solaris10與EMC-CX3-10c實現(xiàn)FC-SAN實施手冊V2_第2頁
Solaris10與EMC-CX3-10c實現(xiàn)FC-SAN實施手冊V2_第3頁
Solaris10與EMC-CX3-10c實現(xiàn)FC-SAN實施手冊V2_第4頁
Solaris10與EMC-CX3-10c實現(xiàn)FC-SAN實施手冊V2_第5頁
已閱讀5頁,還剩37頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、 Solaris 10與EMC CX3-10c實現(xiàn)FC-SAN實施手冊現(xiàn)場背景:服務器3臺,2臺Sun Fire V490,1臺Sun Fire V250。存儲為DELL|EMC CX3-10c,配備8TB硬盤,一臺Brocade SW200E光纖交換機。目的:實現(xiàn)FC-SAN構(gòu)架。拓撲圖:實施步驟:先完成Dell|EMC CX3-10c初始化,配置兩個管理IP,分別為:XX.XX.XX.XX。建立服務器、光纖交換機、存儲之間的鏈路。初始化光纖交換機,配置管理地址:XX.XX.XX.XX在Navisphere Manager管理界面發(fā)現(xiàn)鏈路。在服務器端安裝Navisphere agent注冊,

2、安裝PowerPath多鏈路管理軟件。具體安裝操作如下:Navisphere agent的安裝與配置先將光盤mount上后,再執(zhí)行下面的命令:pkgadd -d NAVIAGNT.pkg會出現(xiàn)下述提示信息,按照提示信息選擇安裝即可。Select the packages that you want to install by doing one of thefollowing:? Enter 1 (to install the host agent)or? Enter 2 (to install CLI) or Enter All (to install both the host agent

3、and CLI)Enter y and y to begin the installation.The installation program looks for any agent configuration filesyou may already have on your system. If the program doesnot find any agent configuration files, then you have finishedinstalling the agent; go to step 10q. If the program does find anyexis

4、ting configuration files, it displays a message like the following:At Least 1 saved config file exists for NavisphereAgent.Please select 1 of the following:1Restore/etc/Navisphere/.Naviagent-config.000120:10592Restore/etc/Navisphere/.Naviagent-config.000121:14083 QuitSelect number 1 - 3.修改agent.conf

5、ig配置文件,主要方法如下:修改/etc/Navisphere/agent.configVi /etc/Navisphere/agent.config 修改內(nèi)容為:# Navisphere agent.config# # This file is used by Navisphere Agent to configure# site specific values.# All entries in this file have this form:# object value-list# Where object tells what sort of information is to# be

6、 configured, and value-list is a# whitespace-separated list of values to be configured.# Samples, which should be edited, appear below for all# permissible types of objects.# White space (tabs, space, line-feeds,# carriage-returns) and blank lines are ignored;# To continue a line onto the next line,

7、 use as the# last character of that line. The is dropped when# the next line is concatenated to the continued line.# Description specification# # The clarDescr object takes arbitrary text values# intended to describe the agent and its location.#clarDescr Navisphere Agent# The clarContact object take

8、s arbitrary text values# intended to describe who is responsible for the# configured agent, and how to reach them.#clarContact John Smith, 800-555-1212# Device specification.# # The format of device objects for CLARiiON devices# is:# devicedevice-specname description# where the device-specification

9、is the device name to# open to access the CLARiiON device. It can be a# SCSI-2 file name. If this is auto, all attached# arrays with bound LUNs will be automatically# configured. (Currently, dummy arguments are required# for name and description, when using# auto-configuration.) This can NOT be defa

10、ulted.# The name is the per CLARiiON name that can be used to# identify each CLARiiON to the manager application.# The name is REQUIRED and cannot contain spaces (even# if surrounded by quotes). This can NOT be defaulted.# The description is a quoted string that contains a# brief description of the

11、CLARiiON chassis being# managed. It defaults to if not specified, and to# the device name for auto-configuration.# SAMPLES:# device c0t0d0 NAVISPHERE-1 NAVISPHERE-1# automatically detect manageable devicesdevice auto auto# User Specification.# # The format of user objects is# user localUserId# OR# u

12、ser userIdhostname在此處添加存儲系統(tǒng)SPA和SPB管理地址即可user HYPERLINK mailto:systemXX.XX.XX.XX systemXX.XX.XX.XX user systemXX.XX.XX.XX# These build a list of users who are allowed to perform# WRITE operations to the CLARiiON devices managed by# this agent. By default, as specified below, only root# on this machin

13、e has WRITE access. Others can be# granted access by including their login name and host# which they can access from. A null list prevents# anyone, including admin, from having write access. In# order to get write access, this file would have to be# modified and the Agent stopped and restarted to# r

14、e-read the configuration file, or an appropriate# remote configuration file would have to be sent to the# agent from an already-priviledged user.user root # only on this machine#user sbluepicasso # individual user sblue on# host picasso#user lgreenhannibal # individual user lgreen on# host hannibal#

15、 Poll specification# # The poll object takes a numerical count of seconds.# This specifies how often the agent solicits# information from the array, rather than using cached# information. The minimum is 10.#poll 60# Eventlog specification# # The eventlog object takes a numerical count of log# entrie

16、s.# This defines the maximum number of SP log events# received by the agent on startup, and received by# clients per poll. A value of 0 causes the devices# entire log to be read at startup. A minimum of 100# events will be read on serial, and 2048 on fibre,# overriding any lower value configured bel

17、ow.#eventlog 100# Baud Rate specification# # If the agent is using a serial port to manage a# device, the next entry can specify either 9600 baud# or 19200 baud.#baud 9600# end of configuration file#保存配置文件,然后可以啟動/停止agent服務。命令如下:bash3.00#/etc/init.d/agent stopbash3.00#/etc/init.d/agent start如果安裝配置正常,

18、啟動agent服務后在Navisphere Manager管理界面中的Connective中會看到鏈路狀態(tài)register為yes。如register顯示為no,可以考慮重啟服務器或者重啟agent服務,或者在Navisphere Manager界面中進行手動注冊也可以。注冊完成后會在鏈路狀態(tài)中顯示主機名稱等信息。PowerPath的安裝與注冊PowerPath的安裝1、Mount CDROM2、bash3.00# mkdir /unload3、bash3.00#cd /unload4、bash3.00#cp /. 從光盤將安裝文件拷貝到新建的目錄下面。5、bash3.00# gunzip 解

19、壓縮文件6、bash3.00# tar -xvf 解壓縮文件7、bash3.00#pkgadd d . 安裝PowerPath按照下述提示操作:SPARC host:The following packages are available:EMCpower EMC PowerPath(sparc) 5.2.x_bxxxSelect package(s) you wish to process (or all toprocess all packages). (default: all) ?,?,q:x86 (i386) host:The following packages are avail

20、able:EMCpower EMC PowerPath(i386) 5.2.x_bxxxSelect package(s) you wish to process (or all toprocess all packages). (default: all) ?,?,q:Enter 1 and press ENTER. Enter package base directory (default: /opt):Press ENTER to accept the default base directory (/opt), or type thepath to an alternate base

21、directory and press ENTER.This package contains scripts which will be executedwith super-user permission during the process ofinstalling this package.Do you want to continue with the installation of y,n,?Enter y and press ENTER.Installation of was successful.8、安裝完成后需要進行PowerPath的注冊注冊方法如下:bash3.00#/e

22、tc/emcpreg -installYou see the following output:= EMC PowerPath Registration =Do you have a new registration key or keys to enter? nType y and press ENTER.You see the following output:Enter the registration key(s) for your product(s),one per line, pressing Enter after each key.After typing all keys,

23、 press Enter again.Key (Enter if done):Enter the PowerPath registration key and press ENTER. You can alsoadd keys for other technologies, such as PowerPath MigrationEnabler or PowerPath Encryption with RSA.If you entered a valid key, you see the following output:1 key(s) successfully added.Key succe

24、ssfully installed.Key (Enter if done):Press ENTER. You see the following output if you entered one key:1 key(s) successfully registered.在PowerPath軟件安裝注冊完成后重啟服務器,輸入下述命令可以看到服務器與存在之間的兩條鏈路:bash3.00#powermt display dev=all會顯示鏈路情況。還需要將Solaris主機的MPxIO功能關(guān)閉。(主要是由于Solaris自帶的MPxIO功能與PowerPath的多路徑功能相沖突)具體修改文件如下

25、:修改/kernel/drv/fp.conf,修改內(nèi)容如下:mpxio-disable=yes修改/kernel/drv/scsi_vhci.conf,修改內(nèi)容如下:mpxio-disable=yes修改完成后,運行如下命令:powermt display dev=all powermt check (Choose A for all. Clear the dead paths.) devfsadm C (Scan the SCSI bus.) powercf -q (Rebuild the logical link layer.) powermt config (Bring the devi

26、ce pathsinto PowerPath control.) powermt save (Save the current configuration.)完成配置保存等工作后PowerPath軟件即可正常使用。存儲建立RAID Group,Storage Group,將服務器與LUN映射關(guān)系對應上。服務器端識別存儲,格式化硬盤以及做文件系統(tǒng)。具體操作如下:sh-3.00# formatSearching for disks.doneAVAILABLE DISK SELECTIONS: 0. c0t0d0 /pci1d,700000/scsi4/sd0,0 1. c0t8d0 /pci1d,

27、700000/scsi4/sd8,0 2. c3t0d0 /pci1d,700000/QLGC,qlc2/sd0,0 3. c3t1d0 /pci1d,700000/QLGC,qlc2/sd1,0 4. emcpower0a /pseudo/emcp0Specify disk (enter its number): 4selecting emcpower0adisk formattedFORMAT MENU: disk - select a disk type - select (define) a disk type partition - select (define) a partiti

28、on table current - describe the current disk format - format and analyze the disk repair - repair a defective sector label - write label to the disk analyze - surface analysis defect - defect list management backup - search for backup labels verify - read and display labels inquiry - show vendor, pr

29、oduct and revision volname - set 8-character volume name ! - execute , then return quitformat pPARTITION MENU: 0 - change 0 partition 1 - change 1 partition 2 - change 2 partition 3 - change 3 partition 4 - change 4 partition 5 - change 5 partition 6 - change 6 partition select - select a predefined

30、 table modify - modify a predefined partition table name - name the current table print - display the current table label - write partition map and label to the disk ! - execute , then return quitpartition pCurrent partition table (original):Total disk sectors available: 3076627422 + 16384 (reserved

31、 sectors)Part Tag Flag First Sector Size Last Sector0 root wm 34 128.00MB 262177 1 swap wu 262178 128.00MB 524321 2 unassigned wm 0 0 0 3 unassigned wm 0 0 0 4 unassigned wm 0 0 0 5 unassigned wm 0 0 0 6 usr wm 524322 1.43TB 3076627421 8 reserved wm 3076627422 8.00MB 3076643805 partition labelReady

32、to label disk, continue? ypartition qFORMAT MENU: disk - select a disk type - select (define) a disk type partition - select (define) a partition table current - describe the current disk format - format and analyze the disk repair - repair a defective sector label - write label to the disk analyze

33、- surface analysis defect - defect list management backup - search for backup labels verify - read and display labels inquiry - show vendor, product and revision volname - set 8-character volume name ! - execute , then return quitformat q創(chuàng)建文件系統(tǒng),Solaris默認格式bash-3.00# newfs /dev/rdsk/emcpower0g newfs:

34、 建構(gòu)新的文件系統(tǒng) /dev/rdsk/ emcpower0g: (y/n)? y警告:最后一個未分配柱面中的 1104 扇區(qū)/dev/rdsk/ emcpower0g: 在 500668 磁道上,48 扇區(qū)的 128 柱面的 3076103088 扇區(qū)1502003.5MB 在 3502 柱面群組 (143 c/g, 429.00MB/g, 448 i/g)超塊 (fsck -F ufs -o b=#) 備份在:32, 878752, 1757472, 2636192, 3514912, 4393632, 5272352, 6151072, 7029792, 7908512,初始化柱面組:最

35、后 10 個柱面組的超級塊備份位置: 3068047904, 3068926624, 3069805344, 3070684064, 3071562784, 3072441504, 3073320224, 3074198944, 3075077664, 3075956384,文件系統(tǒng)做完。掛載硬盤bash-3.00# mkdir emcdiskbash-3.00# mount /dev/dsk/ emcpower0g /mnt/emcdisk/其它鏈路也如上述操作,完成后運行下面命令可以看到磁盤大小以及利用情況。bash-3.00# df -kh文件系統(tǒng) 大小 用了 可用 容量 掛接在/dev

36、/dsk/c0t0d0s0 32G 1.1G 30G 4% /devices 0K 0K 0K 0% /devicesctfs 0K 0K 0K 0% /system/contractproc 0K 0K 0K 0% /procmnttab 0K 0K 0K 0% /etc/mnttabswap 2.1G 1.0M 2.1G 1% /etc/svc/volatileobjfs 0K 0K 0K 0% /system/object/dev/dsk/c0t0d0s3 23G 4.3G 19G 19% /usrfd 0K 0K 0K 0% /dev/fd/dev/dsk/c0t8d0s7 67G 7

37、43M 66G 2% /varswap 2.1G 312K 2.1G 1% /tmpswap 2.1G 24K 2.1G 1% /var/run/dev/dsk/c0t0d0s6 1.2G 83M 1.1G 7% /temp/dev/dsk/c0t0d0s7 10G 1.9G 8.2G 19% /export/home/dev/dsk/emcpower0g 1.4T 64M 1.4T 1% /mnt/emcdisk硬盤自動掛載,修改配置文件,配置文件在/etc/vfstab具體修改參考下面文檔:bash-3.00# vi /etc/vfstab#device device mount FS f

38、sck mount mount#to mount to fsck point type pass at boot options#fd - /dev/fd fd - no -/proc - /proc proc - no -/dev/dsk/c0t0d0s1 - - swap - no -/dev/dsk/c0t0d0s0 /dev/rdsk/c0t0d0s0 / ufs 1 no -/dev/dsk/c0t0d0s3 /dev/rdsk/c0t0d0s3 /usr ufs 1 no -/dev/dsk/c0t8d0s7 /dev/rdsk/c0t8d0s7 /var ufs 1 no -/d

39、ev/dsk/c0t0d0s7 /dev/rdsk/c0t0d0s7 /export/home ufs 2 yes -/dev/dsk/c0t0d0s6 /dev/rdsk/c0t0d0s6 /temp ufs 2 yes -/devices - /devices devfs - no -ctfs - /system/contract ctfs - no -objfs - /system/object objfs - no -swap - /tmp tmpfs - yes -/dev/dsk/emcpower0g /dev/rdsk/emcpower0g /mnt/emcdisk ufs 1

40、yes -光纖交換機配置zone光纖交換機主要配置管理ip地址,zone等,在初始化時已經(jīng)完成了ip地址的配置,配置zone的方法如下:SW200E:admin switchshow 查看交換機信息switchName: SW200EswitchType: 34.0switchState: Online switchMode: NativeswitchRole: PrincipalswitchDomain: 1switchId: fffc01switchWwn: 10:00:00:05:1e:5b:f7:3ezoning: ON (XXXX)switchBeacon: OFFArea Port

41、 Media Speed State Proto= 0 0 id N4 Online F-Port 21:00:00:1b:32:08:2a:d4 1 1 id N4 Online F-Port 50:06:01:69:41:e0:b2:5f 2 2 id N4 Online F-Port 50:06:01:61:41:e0:b2:5f 3 3 id N4 Online F-Port 21:00:00:e0:8b:8f:57:b3 4 4 id N4 Online F-Port 21:00:00:e0:8b:8f:a8:b3 5 5 id N4 No_Light 6 6 id N4 No_Li

42、ght 7 7 id N4 No_Light 8 8 - N4 No_Module (No POD License) Disabled 9 9 - N4 No_Module (No POD License) Disabled 10 10 - N4 No_Module (No POD License) Disabled 11 11 - N4 No_Module (No POD License) Disabled 12 12 - N4 No_Module (No POD License) Disabled 13 13 - N4 No_Module (No POD License) Disabled

43、 14 14 - N4 No_Module (No POD License) Disabled 15 15 - N4 No_Module (No POD License) DisabledSW200E:admin alicreate “SPA_0”,” 50:06:01:69:41:e0:b2:5f” /創(chuàng)建WWN的別名SW200E:admin alicreate “SPB_0”,” 50:06:01:61:41:e0:b2:5f”SW200E:admin alicreate “mailbak”,” 21:00:00:e0:8b:8f:57:b3”SW200E:admin alicreate

44、“student_mail”,” 21:00:00:1b:32:08:2a:d4”SW200E:admin alicreate “v490”,” 21:00:00:e0:8b:8f:a8:b3”SW200E:admin zonecreate “bak”,” SPA_0; SPB_0; mailbak” /創(chuàng)建zoneSW200E:admin zonecreate “mail”,” SPA_0; SPB_0; v490”SW200E:admin zonecreate “st_mail”,” SPA_0; SPB_0; student_mail”SW200E:admin cfgcreate XXX

45、X, bak; mail ;st_mail /創(chuàng)建cfgSW200E:admin cfgsave “XXXX” /保存cfgSW200E:admin cfgenable “XXXX” /enable cfg配置完成。可以通過switchshow、fabricshow、zoneshow、cfgshow等查看配置。一定要注意創(chuàng)建別名時WWN的準確性。其它注意事項以及特殊情況處理:PowerPath鏈路不正常情況下的處理PowerPath鏈路不正常主要有幾種情況:鏈路識別不了解決辦法:重啟服務器。或者使用如下命令:bash3.00#powermt checkbash3.00#powermt rest

46、ore掃描通道bash3.00#powercf q bash3.00#powermt configbash3.00#powermt save在Navisphere Manager上檢查鏈路發(fā)現(xiàn)情況,如發(fā)現(xiàn)不了,進行掃描,檢查HBA卡狀態(tài),如果狀態(tài)不對,需要安裝HBA卡驅(qū)動。鏈路數(shù)量狀態(tài)不對當鏈路數(shù)量狀態(tài)不對時可以使用A中所提到的命令進行鏈路通道掃描,同時結(jié)合Navisphere Manager 檢查鏈路情況,可以運行CTRL+ALT+SHIFT+F12進入工程師配置模式,密碼是messner.檢查鏈路以及Storage Group主機配置信息是否勾選。同時也可以檢查光纖交換機配置信息。修改So

47、laris配置文件系統(tǒng)不能啟動的問題在修改vfstab等文件造成系統(tǒng)啟動不起來,需要采用單用戶模式將配置文件修改后再重啟即可。主要方法如下:1插入Solaris 10光盤2利用光盤啟動到單用戶模式ok boot cdrom -s3裝配/(root)文件系統(tǒng)到/a目錄,以允許對磁盤上的文件系統(tǒng)的訪問。# mount /dev/dsk/c0t0d0s0 /a4設(shè)置并且輸出TERM變量允許vi編輯器進行工作# TERM=sun# export TERM5編輯/etc/vfstab文件并且糾正問題。然后退出保存文件# vi /a/etc/vfstab:wq!6卸載文件系統(tǒng)# cd /# umount

48、/a7重新啟動系統(tǒng)# reboot附錄資料:不需要的可以自行刪除bat文件的基本應用bat是dos下的批處理文件 .cmd是nt內(nèi)核命令行環(huán)境的另一種批處理文件 從更廣義的角度來看,unix的shell腳本以及其它操作系統(tǒng)甚至應用程序中由外殼進行解釋執(zhí)行的文本,都具有與批處理文件十分相似的作用,而且同樣是由專用解釋器以行為單位解釋執(zhí)行,這種文本形式更通用的稱謂是腳本語言。所以從某個程度分析,batch, unix shell, awk, basic, perl 等腳本語言都是一樣的,只不過應用的范圍和解釋的平臺各有不同而已。甚至有些應用程序仍然沿用批處理這一稱呼,而其內(nèi)容和擴展名與dos的批處

49、理卻又完全不同。 = 首先批處理文件是一個文本文件,這個文件的每一行都是一條DOS命令(大部分時候就好象我們在DOS提示符下執(zhí)行的命令行一樣),你可以使用DOS下的Edit或者Windows的記事本(notepad)等任何文本文件編輯工具創(chuàng)建和修改批處理文件。 = 注 = 批處理文件中完全可以使用非dos命令,甚至可以使用不具有可執(zhí)行特性的普通數(shù)據(jù)性文件,這緣于windows系統(tǒng)這個新型解釋平臺的涉入,使得批處理的應用越來越邊緣化。所以我們討論的批處理應該限定在dos環(huán)境或者命令行環(huán)境中,否則很多觀念和設(shè)定都需要做比較大的變動。 = 其次,批處理文件是一種簡單的程序,可以通過條件語句(if)和

50、流程控制語句(goto)來控制命令運行的流程,在批處理中也可以使用循環(huán)語句(for)來循環(huán)執(zhí)行一條命令。當然,批處理文件的編程能力與C語言等編程語句比起來是十分有限的,也是十分不規(guī)范的。批處理的程序語句就是一條條的DOS命令(包括內(nèi)部命令和外部命令),而批處理的能力主要取決于你所使用的命令。 = 注 = 批處理文件(batch file)也可以稱之為批處理程序(batch program),這一點與編譯型語言有所不同,就c語言來說,擴展名為c或者cpp的文件可以稱之為c語言文件或者c語言源代碼,但只有編譯連接后的exe文件才可以稱之為c語言程序。因為批處理文件本身既具有文本的可讀性,又具有程序

51、的可執(zhí)行性,這些稱謂的界限是比較模糊的。 = 第三,每個編寫好的批處理文件都相當于一個DOS的外部命令,你可以把它所在的目錄放到你的DOS搜索路徑(path)中來使得它可以在任意位置運行。一個良好的習慣是在硬盤上建立一個bat或者batch目錄(例如C:BATCH),然后將所有你編寫的批處理文件放到該目錄中,這樣只要在path中設(shè)置上c:batch,你就可以在任意位置運行所有你編寫的批處理程序。 = 注 = 純以dos系統(tǒng)而言,可執(zhí)行程序大約可以細分為五類,依照執(zhí)行優(yōu)先級由高到低排列分別是:DOSKEY宏命令(預先駐留內(nèi)存),COMMAND.COM中的內(nèi)部命令(根據(jù)內(nèi)存的環(huán)境隨時進駐內(nèi)存),以

52、com為擴展名的可執(zhí)行程序(由 直接載入內(nèi)存),以exe位擴展名的可執(zhí)行程序(由 重定位后載入內(nèi)存),以bat位擴展名的批處理程序(由 解釋分析,根據(jù)其內(nèi)容按優(yōu)先級順序調(diào)用第2,3,4,5種可執(zhí)行程序,分析一行,執(zhí)行一行,文件本身不載入內(nèi)存) = 第四,在DOS和Win9x/Me系統(tǒng)下,C:盤根目錄下的AUTOEXEC.BAT批處理文件是自動運行批處理文件,每次系統(tǒng)啟動時會自動運行該文件,你可以將系統(tǒng)每次啟動時都要運行的命令放入該文件中,例如設(shè)置搜索路徑,調(diào)入鼠標驅(qū)動和磁盤緩存,設(shè)置系統(tǒng)環(huán)境變量等。下面是一個運行于Windows 98下的autoexec.bat的示例: ECHO OFF PA

53、TH C:WINDOWS;C:WINDOWSCOMMAND;C:UCDOS;C:DOSTools; C:SYSTOOLS;C:WINTOOLS;C:BATCH LH SMARTDRV.EXE /X LH DOSKEY.COM /insert LH CTMOUSE.EXE SET TEMP=D:TEMP SET TMP=D:TEMP = 注 = AUTOEXEC.BAT為DOS系統(tǒng)的自動運行批處理文件,由COMMAND.COM啟動時解釋執(zhí)行; 而在Win9x環(huán)境中,不僅增加支持了 DOSSTART.BAT, WINSTART.BAT 等許多其它自動運行的批處理文件,對AUTOEXEC.BAT 也

54、增加了 .DOS .W40 .BAK .OLD .PWS 等許多變體以適應復雜的環(huán)境和多變的需求。 = willsort 編注 = 以下關(guān)于命令的分類,有很多值得推敲的地方。常用命令中的本不是命令,而dir、copy等也很常用的命令卻沒有列入, 而特殊命令中所有命令對我來說都是常用命令。建議將批處理所引用的命令分為內(nèi)部命令、外部命令、第三方程序三類。而內(nèi)部命令和外部命令中別有一類是專用于或常用于批處理中的命令可稱之為批處理命令。 以下摘錄MS-DOS 6.22 幫助文檔中關(guān)于批處理命令的文字,當然,其中有些概念和定義已經(jīng)有些落后了。 批處理命令 批處理文件或批處理程序是一個包含若干MS-DOS

55、命令的正文文件,擴展名為.BAT。當在命令提示符下敲入批處理程序的名稱時,MS-DOS成組執(zhí)行此批處理程序中的命令。 任何在命令提示符下可使用的命令都可用在批處理程序中。此外,下面MS-DOS命令是專門在批處理程序中使用的。 = 常用命令 echo、call、pause、rem(小技巧:用:代替rem)是批處理文件最常用的幾個命令,我們就從他們開始學起。 = 注 = 首先, 不是一個命令, 而是DOS 批處理的一個特殊標記符, 僅用于屏蔽命令行回顯. 下面是DOS命令行或批處理中可能會見到的一些特殊標記符: CR(0D) 命令行結(jié)束符 Escape(1B) ANSI轉(zhuǎn)義字符引導符 Space(

56、20) 常用的參數(shù)界定符 Tab(09) ; = 不常用的參數(shù)界定符 + COPY命令文件連接符 * ? 文件通配符 字符串界定符 | 命令管道符 文件重定向符 命令行回顯屏蔽符 / 參數(shù)開關(guān)引導符 : 批處理標簽引導符 % 批處理變量引導符 其次, : 確實可以起到rem 的注釋作用, 而且更簡潔有效; 但有兩點需要注意: 第一, 除了 : 之外, 任何以 :開頭的字符行, 在批處理中都被視作標號, 而直接忽略其后的所有內(nèi)容, 只是為了與正常的標號相區(qū)別, 建議使用 goto 所無法識別的標號, 即在 :后緊跟一個非字母數(shù)字的一個特殊符號. 第二, 與rem 不同的是, :后的字符行在執(zhí)行時

57、不會回顯, 無論是否用echo on打開命令行回顯狀態(tài), 因為命令解釋器不認為他是一個有效的命令行, 就此點來看, rem 在某些場合下將比 : 更為適用; 另外, rem 可以用于 config.sys 文件中. = echo 表示顯示此命令后的字符 echo off 表示在此語句后所有運行的命令都不顯示命令行本身 與echo off相象,但它是加在每個命令行的最前面,表示運行時不顯示這一行的命令行(只能影響當前行)。 call 調(diào)用另一個批處理文件(如果不用call而直接調(diào)用別的批處理文件,那么執(zhí)行完那個批處理文件后將無法返回當前文件并執(zhí)行當前文件的后續(xù)命令)。 pause 運行此句會暫停

58、批處理的執(zhí)行并在屏幕上顯示Press any key to continue.的提示,等待用戶按任意鍵后繼續(xù) rem 表示此命令后的字符為解釋行(注釋),不執(zhí)行,只是給自己今后參考用的(相當于程序中的注釋)。 = 注 = 此處的描述較為混亂, 不如直接引用個命令的命令行幫助更為條理 ECHO 當程序運行時,顯示或隱藏批處理程序中的正文。也可用于允許或禁止命令的回顯。 在運行批處理程序時,MS-DOS一般在屏幕上顯示(回顯)批處理程序中的命令。 使用ECHO命令可關(guān)閉此功能。 語法 ECHO ON|OFF 若要用echo命令顯示一條命令,可用下述語法: echo message 參數(shù) ON|OF

59、F 指定是否允許命令的回顯。若要顯示當前的ECHO的設(shè)置,可使用不帶參數(shù)的ECHO 命令。 message 指定讓MS-DOS在屏幕上顯示的正文。 CALL 從一個批處理程序中調(diào)用另一個批處理程序,而不會引起第一個批處理的中止。 語法 CALL drive:pathfilename batch-parameters 參數(shù) drive:pathfilename 指定要調(diào)用的批處理程序的名字及其存放處。文件名必須用.BAT作擴展名。 batch-parameters 指定批處理程序所需的命令行信息。 PAUSE 暫停批處理程序的執(zhí)行并顯示一條消息,提示用戶按任意鍵繼續(xù)執(zhí)行。只能在批處 理程序中使用

60、該命令。 語法 PAUSE REM 在批處理文件或CONFIG.SYS中加入注解。也可用REM命令來屏蔽命令(在CONFIG.SYS 中也可以用分號 ; 代替REM命令,但在批處理文件中則不能替代)。 語法 REM string 參數(shù) string 指定要屏蔽的命令或要包含的注解。 = 例1:用edit編輯a.bat文件,輸入下列內(nèi)容后存盤為c:a.bat,執(zhí)行該批處理文件后可實現(xiàn):將根目錄中所有文件寫入 a.txt中,啟動UCDOS,進入WPS等功能。 批處理文件的內(nèi)容為: 命令注釋: echo off 不顯示后續(xù)命令行及當前命令行 dir c:*.* a.txt 將c盤文件列表寫入a.tx

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論