cd, cp, du, find, ls, lsof, mkalias, pwd, rm, rmalias
cd 切换目录,和操作系统命令cd差不多
Changes the current directory to the specified directory dir can be specified as either an absolute path or a relative path, including the . and .. ASMCMD> cd pgold ASMCMD> ls CONTROLFILE/ DATAFILE/ ONLINELOG/ PARAMETERFILE/ TEMPFILE/ control01.ctl control02.ctl redo01.log redo02.log redo03.log redo04.log spfilepgold.ora sysaux01.dbf system01.dbf temp01.dbf undotbs01.dbf undotbs02.dbf users01.dbf
cp 复制文件,可以在操作系统和磁盘组直接,磁盘组和磁盘组之间,以及本地节点和远程实例之间复制
Enables you to copy files between Oracle ASM disk groups on local instances to and from remote instances. cp [--service <name>] [--port <port>] [connect_str:]src_file [connect_str:]tgt_file The options for the cp command are described below. --service - name of the ASM instance name if not default +ASM. --port - Listener port number, default is 1521. connect_str - The connection string for use with a remote instance copy. src_file - Name of the source file to copy. tgt_file - A user alias for the created target file name or alias directory name. cp cannot copy files between two remote instances. The local Oracle ASM instance must be either the source or the target of the operation. You can use the cp command to: Copy files from a disk group to the operating system Copy files from a disk group to a disk group Copy files from the an OS File system to a disk group ASMCMD> cp users01.dbf /tmp copying +data_pgold/pgold/users01.dbf -> /tmp/users01.dbf ASMCMD> ASMCMD> pwd + ASMCMD> cd ohsdba ASMCMD> pwd +ohsdba ASMCMD> mkdir ohs ASMCMD> ls ohs/ ASMCMD> cp +data_pgold/pgold/users01.dbf . copying +data_pgold/pgold/users01.dbf -> +ohsdba/users01.dbf ASMCMD> ls -l Type Redund Striped Time Sys Name Y ASM/ N ohs/ ASMCMD> cp /etc/hosts +ohsdba ASMCMD-8012: can not determine file type for file ORA-15056: additional error message ORA-27046: file size is not a multiple of logical block size Additional information: 1 ORA-06512: at "SYS.X$DBMS_DISKGROUP", line 320 ORA-06512: at line 3 (DBD ERROR: OCIStmtExecute) ASMCMD> 模拟1个大小为1024的block [oracle@ohs1 ~]$ dd if=/dev/zero of=1block bs=1024 count=1 1+0 records in 1+0 records out 1024 bytes (1.0 kB) copied, 0.00312318 seconds, 328 kB/s [oracle@ohs1 ~]$ ls -l block1 -rw-r--r-- 1 oracle oinstall 1024 May 12 00:40 block1 [oracle@ohs1 ~]$ pwd /home/oracle [oracle@ohs1 ~]$ asmcmd ASMCMD> exit [oracle@ohs1 ~]$ asmcmd -v debug ASMCMD> cp /home/oracle/block1 +ohsdba ASMCMD-8012: can not determine file type for file ORA-15056: additional error message ORA-15312: invalid file type ORA-06512: at "SYS.X$DBMS_DISKGROUP", line 320 ORA-06512: at line 3 (DBD ERROR: OCIStmtExecute) ASMCMD>
注意:cp命令适用于Oracle数据文件,从上面错误可以看出,在复制之前,oracle会做验证大小和文件头。
du 显示当前或指定目录的使用情况
Displays the total space used for files in the specified directory and in the entire directory tree under the directory. ASMCMD> du Used_MB Mirror_used_MB 1724 1724 ASMCMD>
find 查找文件
Displays the absolute paths of all occurrences of the specified name pattern (with wildcards) in a specified directory and its subdirectories. ASMCMD> find . undo* +data_pgold/pgold/DATAFILE/UNDOTBS1.258.911137953 +data_pgold/pgold/DATAFILE/UNDOTBS2.265.911138161 +data_pgold/pgold/undotbs01.dbf +data_pgold/pgold/undotbs02.dbf ASMCMD> ASMCMD> find --type CONTROLFILE +DATA_PGOLD * +DATA_PGOLD/PGOLD/CONTROLFILE/Current.260.911138025 +DATA_PGOLD/PGOLD/CONTROLFILE/Current.261.911138027 +DATA_PGOLD/PGOLD/control01.ctl +DATA_PGOLD/PGOLD/control02.ctl ASMCMD>
ls 列出ASM目录下的内容
Lists the contents of an Oracle ASM directory, the attributes of the specified file, or the names and attributes of all disk groups from the V$ASM_DISKGROUP_STAT or V$ASM_DISKGROUP view. The default view is V$ASM_DISKGROUP_STAT. ASMCMD> ls CONTROLFILE/ DATAFILE/ ONLINELOG/ PARAMETERFILE/ TEMPFILE/ control01.ctl control02.ctl redo01.log redo02.log redo03.log redo04.log spfilepgold.ora sysaux01.dbf system01.dbf temp01.dbf undotbs01.dbf undotbs02.dbf users01.dbf ASMCMD> ls -l Type Redund Striped Time Sys Name Y CONTROLFILE/ Y DATAFILE/ Y ONLINELOG/ Y PARAMETERFILE/ Y TEMPFILE/ N control01.ctl => +DATA_PGOLD/PGOLD/CONTROLFILE/Current.260.911138025 N control02.ctl => +DATA_PGOLD/PGOLD/CONTROLFILE/Current.261.911138027 N ohsdba01.dbf => +DATA_PGOLD/PGOLD/DATAFILE/OHSDBA.269.911599547 N redo01.log => +DATA_PGOLD/PGOLD/ONLINELOG/group_1.262.911138045 N redo02.log => +DATA_PGOLD/PGOLD/ONLINELOG/group_2.263.911138047 N redo03.log => +DATA_PGOLD/PGOLD/ONLINELOG/group_3.266.911138243 N redo04.log => +DATA_PGOLD/PGOLD/ONLINELOG/group_4.267.911138243 N spfilepgold.ora => +DATA_PGOLD/PGOLD/PARAMETERFILE/spfile.268.911138243 N sysaux01.dbf => +DATA_PGOLD/PGOLD/DATAFILE/SYSAUX.257.911137953 N system01.dbf => +DATA_PGOLD/PGOLD/DATAFILE/SYSTEM.256.911137951 N temp01.dbf => +DATA_PGOLD/PGOLD/TEMPFILE/TEMP.264.911138051 N undotbs01.dbf => +DATA_PGOLD/PGOLD/DATAFILE/UNDOTBS1.258.911137953 N undotbs02.dbf => +DATA_PGOLD/PGOLD/DATAFILE/UNDOTBS2.265.911138161 N users01.dbf => +DATA_PGOLD/PGOLD/DATAFILE/USERS.259.911137953
lsof 列出本地client打开的文件
Lists the open files of the local clients. lsof [--suppressheader] {-G diskgroup|--dbname db| -C instance} The options for the lsof command are described below. --suppressheader - Suppresses column headings. -G diskgroup - List files only from this specified disk group. --dbname db - List files only from this specified database. -C instance - List files only from this specified instance. ASMCMD> lsof DB_Name Instance_Name Path +ASM +ASM1 +systemdg.255.4294967295 asmvol +ASM1 +ohsdba/OHS1.256.911435005 pgold pgold1 +data_pgold/pgold/control01.ctl pgold pgold1 +data_pgold/pgold/control02.ctl pgold pgold1 +data_pgold/pgold/redo01.log pgold pgold1 +data_pgold/pgold/redo02.log pgold pgold1 +data_pgold/pgold/redo03.log pgold pgold1 +data_pgold/pgold/redo04.log pgold pgold1 +data_pgold/pgold/sysaux01.dbf pgold pgold1 +data_pgold/pgold/system01.dbf pgold pgold1 +data_pgold/pgold/temp01.dbf pgold pgold1 +data_pgold/pgold/undotbs01.dbf pgold pgold1 +data_pgold/pgold/undotbs02.dbf pgold pgold1 +data_pgold/pgold/users01.dbf ASMCMD>
mkalias 为系统生成的文件创建别名,没有什么实际意义,和操作系统的alias差不多
Creates an alias for the specified system-generated filename. ASMCMD> mkalias '+DATA_PGOLD/PGOLD/DATAFILE/OHSDBA.269.911599547' ohsdba01.dbf ASMCMD> ls -l Type Redund Striped Time Sys Name Y CONTROLFILE/ Y DATAFILE/ Y ONLINELOG/ Y PARAMETERFILE/ Y TEMPFILE/ N control01.ctl => +DATA_PGOLD/PGOLD/CONTROLFILE/Current.260.911138025 N control02.ctl => +DATA_PGOLD/PGOLD/CONTROLFILE/Current.261.911138027 N ohsdba01.dbf => +DATA_PGOLD/PGOLD/DATAFILE/OHSDBA.269.911599547 N redo01.log => +DATA_PGOLD/PGOLD/ONLINELOG/group_1.262.911138045 N redo02.log => +DATA_PGOLD/PGOLD/ONLINELOG/group_2.263.911138047 N redo03.log => +DATA_PGOLD/PGOLD/ONLINELOG/group_3.266.911138243 N redo04.log => +DATA_PGOLD/PGOLD/ONLINELOG/group_4.267.911138243 N spfilepgold.ora => +DATA_PGOLD/PGOLD/PARAMETERFILE/spfile.268.911138243 N sysaux01.dbf => +DATA_PGOLD/PGOLD/DATAFILE/SYSAUX.257.911137953 N system01.dbf => +DATA_PGOLD/PGOLD/DATAFILE/SYSTEM.256.911137951 N temp01.dbf => +DATA_PGOLD/PGOLD/TEMPFILE/TEMP.264.911138051 N undotbs01.dbf => +DATA_PGOLD/PGOLD/DATAFILE/UNDOTBS1.258.911137953 N undotbs02.dbf => +DATA_PGOLD/PGOLD/DATAFILE/UNDOTBS2.265.911138161 N users01.dbf => +DATA_PGOLD/PGOLD/DATAFILE/USERS.259.911137953
pwd 显示当前目录的绝对路径
Displays the absolute path of the current directory. ASMCMD> pwd +data_pgold/pgold ASMCMD> ASMCMD> pwd +OHSDBA/asm ASMCMD> cd .. ASMCMD> ls -l Type Redund Striped Time Sys Name Y ASM/ N ohs/
rm 删除指定的文件和目录
Deletes the specified Oracle ASM files and directories. rm [-f|-r] name [name...] The options for the rm command are described below. -r - Recursively deletes files and subdirectories. -f - Forces the deletion of files and subdirectories. name - Name of the file, pattern, or directory you want to remove. ASMCMD> pwd +OHSDBA ASMCMD> ls ASM/ ohs/ users01.dbf ASMCMD> rm users01.dbf ASMCMD> ls -l Type Redund Striped Time Sys Name N ohs/ ASMCMD>
rmalias 移除别名,不会删除文件。别名不要随便删除,删除可能导致数据库启动不了,通过mkalias可以解决问题
Removes the specified aliases, retaining the files that the aliases reference. ASMCMD> rmalias users01.dbf shutdown database and restart database SQL> startup ORACLE instance started. Total System Global Area 318046208 bytes Fixed Size 1344680 bytes Variable Size 192940888 bytes Database Buffers 117440512 bytes Redo Buffers 6320128 bytes Database mounted. ORA-01157: cannot identify/lock data file 4 - see DBWR trace file ORA-01110: data file 4: '+DATA_PGOLD/pgold/users01.dbf'
mkdir 创建目录
Creates Oracle ASM directories under the current directory. ASMCMD> pwd + ASMCMD> cd ohsdba ASMCMD> pwd +ohsdba ASMCMD> mkdir ohs ASMCMD> ls ohs/
Reference
http://docs.oracle.com/cd/B14117_01/server.101/b10739/storeman.htm
http://docs.oracle.com/cd/B19306_01/server.102/b14231/storeman.htm#i1021337
http://docs.oracle.com/cd/B19306_01/server.102/b14215/asm_util.htm
http://docs.oracle.com/cd/E11882_01/server.112/e18951/asmcon.htm
http://docs.oracle.com/cd/E11882_01/server.112/e18951/asm_util001.htm
http://docs.oracle.com/database/121/OSTMG/GUID-34A732CD-CC55-4A25-982A-209FDF6134BE.htm
http://docs.oracle.com/database/121/OSTMG/GUID-1E5C4FAD-087F-4598-B959-E66670804C4F.htm
http://docs.oracle.com/database/121/OSTMG/GUID-995198B7-9235-4FCF-988E-A48B3B62B405.htm