常用命令
查看全文truss executable
/* Trace doing of given command ( useful debugging ) */
truss -f -p <pid of a shell>
/* Using multiple windows, this can be used to trace setuid/setgid programs */
Arp, ethernet trouble shooting
arp -a .
/* Shows the ethernet address arp table */
arp -d myhost
/* Delete a stale ethernet entry for host myhost */
Disk Commands
du -k .
/* Reports disk space used in Kilobytes */
du -sk .
/* Reports only total disk space used in Kilobytes */
du -ad /var | sort -nr
/* Tells you how big the /var files are in reverse order */
fdformat -d -U
/* Format diskette */
/usr/bin/iostat -E
/* Command to display drives statistics */
/bin/mount -F hsfs -o ro /dev/sr0 /cdrom
/* Mount an ISO 9660 CDROM */
prtvtoc /dev/rdsk/c0t0d0s2
/* Disk geometry and partitioning info */
quot -af
/* How much space is used by users in kilobytes */
Driver Parameters
ndd /dev/ip ?
/* Shows IP variables in the kernel */
ndd /dev/ip ip_forwarding
/* Tells you if forwarding is on (=1) */
ndd -set /dev/ip ip_forwarding 1
/* Enables IP forwarding between interfaces */
File Manipulation
dos2unix | -ascii <filename>
/* Converts DOS file formats to Unix */
split
/* Split files into pieces */
[vi] : %s/existing/new/g
/* Search and Replace text in vi */
[vi] :set nu
/* Set line numbers in vi */
[vi] :set ts=[num]
/* Set tab stops in vi */
File System
cat /dev/null > filename
/* Zero's out the file without breaking pipe */
dd if=/dev/rdsk/... of=/dev/rdsk/... bs=4096
/* Make a mirror image of your boot disk */
df -k | grep dg| awk '{print $6}' |xargs -n 1 umount
/* Unmount all file systems in disk group dg */
fsck -F ufs /dev/rdsk/c0t0d0s0
/* Check a UFS filesystem on c0t0d0s0 */
fsck -F ufs -y /dev/rdsk/c0t0d0s0
/* Check answering yes to all questions */
fsck -F ufs -o b=97472 /dev/rdsk/c0t0d0s0
/* Check using an alternate super block */
gzip -dc file1.tar.gz | tar xf -
/* Unpack .tar.gz files in place */
ln [-fhns] <source file> <destination file>
/* Creating hard links and soft links */
ls -la | awk '{ print $5," ",$9 }' | sort -rn
/* File sizes of current directory */
mount -f pcfs /dev/dsk/c0d0p1 /export/dos
/* Mount DOS fdisk partition from Solaris */
mount -F ufs -o rw,remount /
/* Used to remount root to make it writeable */
mount -o remount,logging /spare
/* Re-mount the ro file system rw and turn on ufs logging */
tar cvf filename.tar
/* Create a tape (tar) archive */
tar xvf filename.tar
/* Extract a tape (tar) archive */
tar cf - . | (cd /newdir ; tar xf -)
/* Recursively copy files and their permissions */
/sbin/uadmin x x
/* Syncs File Systems and Reboots systems fast */
zcat <patch_file.tar.Z | tar xvf -
/* Extract the patch_file that is a compressed tar file */
File Transfer
put "| tar cf - ." filename.tar
/* Undocumented Feature of FTP */
find . -depth | cpio -pdmv /path/tobe/copied/to
/* Fast alternative to cp -pr */
sendport
/* Transferring large numbers of files within the same ftp control session */
General
/usr/bin/catman -w
/* Create windex databases for man page directories */
mailx -H -u <username>
/* List out mail headers for specified user */
set filec
/* Set file-completion for csh */
Hardware
cfgadm
/* Verify reconfigurable hardware resources */
m64config -prconf
/* Print M64 hardware configuration */
m64config -depth 8|24
/* Sets the screen depth of your M64 graphics accelerator */
m64config -res 'video_mode'
/* Change the resolution of your M64 graphics accelerator */
Kernel
/usr/sbin/modinfo
/* Display kernel module information */
/usr/sbin/modload <module>
/* Load a kernel module */
/usr/sbin/modunload -i <module id>
/* Unload a kernel module */
nm -x /dev/ksyms | grep OBJ | more
/* Tuneable kernel parameters */
/usr/sbin/sysdef
/* Show system kernal tunable details */
Memory
prtconf | grep "Memory size"
/* Display Memory Size */
Network Information
ndd /dev/arp arp_cache_report
/* Prints ARP table in cache with IP and MAC address */
netstat -a | grep EST | wc -l
/* Displays number active established connections to the localhost */
netstat -k hme0
/* Undocumented netstat command */
netstat -i
/* Show the TCP/IP network interfaces */
netstat -np
/* Similar to arp -a without name resolution */
netstat -r
/* Show network route table */
netstat -rn
/* Displays routing information but bypasses hostname lookup. */
netstat -a | more
/* Show the state of all sockets */
traceroute <ipaddress>
/* Follow the route to the ipaddress */
Network/Tuning
ifconfig eth0 mtu 1500
/* Change MTU of interface */
ifconfig eth0 10.1.1.1 netmask 255.255.255.255
/* Add an Interface */
/sbin/ifconfig hme0:1 inet 10.210.xx.xxx netmask 255.255.0.0 broadcast 10.210.xxx.xxx
/* Virtual Interfaces */
/sbin/ifconfig hme0:1 up
/* Bring virtual interface up */
/usr/sbin/ndd -set /dev/hme adv_100fdx_cap 1
/* Nailling to 100Mbps */
ndd -set /dev/ip ip_addrs_per_if 1-8192
/* To set more than 256 virtual ip addresses. */
ndd -set /dev/tcp tcp_xmit_hiwat 65535
/* Increase TCP-transmitbuffers */
ndd -set /dev/tcp tcp_recv_hiwat 65535
/* Increase TCP-receivebuffers */
Processes
fuser -uc /var
/* Processes that are running from /var */
kill -HUP `ps -ef | grep [p]roccess | awk '{print $2}'`
/* HUP any related process in one step */
pfiles <pid>
/* Shows processes' current open files */
pkill -n <name>
/* Kill a process by name */
kill `ps -ef | grep program_name | grep -v grep | cut -f8 -d ' '`
/* pkill for solaris 2.6 */
prstat -a
/* An alternative for top command */
/usr/ucb/ps -aux | more
/* Displays CPU % usage for each process in ascending order */
/usr/ucb/ps -auxww | grep <process name>
/* Gives the full listing of the process (long listing) */
ps -ef | grep -i <string> | awk '{ print $2 }'
/* Creates list of running PID by */
ps -ef | grep -v "0:00" | more
/* Gives you a list of any process with CPU time more than 0:00 */
ps -ef | more
/* Show all processes running */
ps -fu oracle|grep pmon
/* See which instances of Oracle are running */
/usr/proc/bin/ptree <pid>
/* Print the parent/child process 'tree' of a process */
/usr/proc/bin/pwdx <pid>
/* Print the working directory of a process */
top -b 1
/* Returns the process utilizing the most cpu and quits */
Resource Management
/usr/bin/ldd [filename]
/* List the dynamic dependencies of executable files */
/usr/proc/bin/pmap pid
/* Report address space map a process occupies */
Route Configuration
route add net 128.50.0.0 128.50.1.6 1
/* Adds route to 128.50 network via 128.50.1.6 */
route delete net 128.50.0.0 128.50.1.6
/* Deletes route to 128.50 network */
route get [hostname]
/* Which interface will be used to contact hostname */
route monitor
/* Monitors traffic to the routes */
route flush
/* Removes all entries in the route table */
Searching Items
egrep "patterna|patternb" <filename>
/* Search for multiple patterns within the same file */
find . -exec egrep -li "str" {} ;
/* Find a string in files starting cwd */
find / -fstype nfs -prune -o fstype autofs -prune -o -name filename -print
/* Find without traversing NFS mounted file systems */
find . -mtime -1 -type f
/* Find recently modified files */
find / -mtime <# of days>
/* Find files modified during the past # of days */
find . ! -mtime -<days> | /usr/bin/xargs rm -rf
/* Finds and removes files older than <days> specified */
find . -type f -exec grep "<sub-string>" {} ; -print
/* Find files containing <sub-string> within directory tree */
find . -type f -print | xargs grep -i [PATTERN]
/* Recursive grep on files */
find / -user <username>
/* Find all files owned by <username> */
find / | grep [file mask]
/* Fast way to search for files */
find <start_path> -name "<file_name>" -exec rm -rf {} ;
/* Recursively finds files by name and automatically removes them */
find /proc/*/fd -links 0 -type f -size +2000 -ls
/* Find large files held open by a process */
ls -lR | grep <sub_string>
/* Fast alternative to find */
Security
echo 'Please go away' > /etc/nologin
/* Stops users logging in */
find / -perm -0777 -type d -ls
/* Find all your writable directories */
find / -type f -perm -2000 -print
/* Find all SGID files */
find / -type f -perm -4000 -print
/* find all SUID files */
Set Terminal Options
stty erase ^H
/* Sets the Backspace Key to erase */
stty erase ^?
/* Sets the Delete Key to erase */
stty sane
/* Rreset terminal after viewing a binary file. */
tput rmacs
/* Reset to standard char set */
Snoop Your Network
snoop -d pcelx0
/* Watch all network packets on device pcelx0 */
snoop -o /tmp/mylog pcelx0
/* Saves packets from device pcelx0 to a file */
snoop -i /tmp/mylog host1 host2
/* View packets from logfile between host1 & host2 */
snoop -i /tmp/mylog -v -p101
/* Show all info on packet number 101 from a logfile */
snoop -i /tmp/mylog -o /tmp/newlog host1
/* Write a new logfile with all host1 packets */
snoop -s 120
/* Return the first 120 bytes in the packet header */
snoop -v arp
/* Capture arp broadcasts on your network */
Swap File
mkfile -v 10m /export/disk1/myswap
/* Makes a 10 Megabyte swapfile in /export/disk */
mkfile -nv 10m /export/disk1/myswap
/* Makes an empty 10 Megabyte swapfile */
Swap Space
swap -s
/* List the amount of swap space available, also see mkfile */
swap -a /export/disk1/swapfile
/* Add a swapfile */
swap -d /dev/dsk/c0t0d0s4
/* Deletes a swap device */
swap -l
/* List the current swap devices */
System Configuration
/usr/sbin/eeprom auto-boot? false
/* Changes eeprom autoboot? setting without going to Ok prompt */
/usr/sbin/eeprom diag-switch? true
/* Set the system to perform diagnostics on the next reboot. */
/usr/sbin/grpck
/* Check /etc/group file syntax */
/usr/sbin/pwck
/* Check /etc/passwd file syntax */
/usr/sbin/sys-unconfig
/* Clear host specific network configuration information */
System Information and Monitoring
coreadm -e log
/* Report global core */
/bin/echo "0t${stamp}>Yn<Y=Y" | adb
/* Convert UNIX timestamp to something human-readable */
/usr/sbin/eeprom
/* Show eeprom parameters */
grep "-root" /var/adm/sulog | grep -v + | tail -25
/* List most recent attempts to switch to superuser account. */
isainfo -bv
/* Quickly checkout if machine is in 32 or 64 bit mode */
last
/* Tells who was or still is on the system */
logger -i
/* Log the process ID */
/usr/sbin/prtconf -vp
/* Show system configuration details */
/usr/platform/`/bin/uname -i`/sbin/prtdiag -v
/* System Diagnostics */
psrinfo | wc -l
/* Display number of processors */
sar -A <time in sec>
/* Provides cumulative system report. */
sar -a <time in sec>
/* Report use of file access system routines. */
sar -u
/* Report CPU Utilization */
uname -a
/* Displays system information */
vmstat 10
/* Displays summary of what the system is doing every 10 seconds */
ypcat hosts | sort -n -t. +0 -1 +1 -2 +2 -3 +3 -4
/* Take the input of "ypcat hosts" or "cat /etc/inet/hosts" and sort by IP. */
Hope you all remember those useful command !
查看交换区信息:
lsps -a 显示交换区的分布信息
lsps -s 显示交换区的使用信息
slibclean 清除处理程序遗留的旧分页信息
smit mkps 建立交换区空间信息
swapon -a 启动所有的分页空间
/etc/swapspaces 存放分页空间表格信息
-------------------------------------------------
显示卷信息:
lsvg 显示卷的名称
lsvg -l rootvg 显示rootvg卷的详细信息
-------------------------------------------------
mount卷的方法:
varyonvg datavg 加载datavg卷
mount /dev/data1 加载datavg下的一个data1卷
裸设备类型:raw,jfs jfs可以转变成文件系统,而raw则不行
-------------------------------------------------
在裸设备上安装oracle系统:
修改裸设备的权限,如裸设备名为system01,安装数据库用户为oracle
chown oracle:dba /dev/system01
chown oracle:dba /dev/rsystem01
在使用文件时必须用rsystem01
-------------------------------------------------
smit快速路径名称:(smit:图形方式,smitty:字符方式)
dev 设备管理
diag 诊断
jfs 定期档案管理系统
lvm 逻辑卷册系统管理员管理
nfs NFS管理
sinstallp 软件安装及维护
spooler 列印队列管理
system 系统管理
tcpip TCP/IP管理
USER 使用者管理
clstart,clstop:启动和停止cluster
lssrc -g cluser:查看cluser的状态
-------------------------------------------------
查看已安装的软件信息:
ls -aF /usr/lpp (lpp:Licensed Program Products)
查看安装媒体内容:
installp -q -d /dev/cdrom -l
-------------------------------------------------
启动时自动加载文件系统信息:
需要加载的信息存放在/etc/filesystems
mount -t nf 加载所有在/ect/filesystems中定义type=nfs的文件系统
显示已加载的文件系统及状态: df -v,mount
-------------------------------------------------
查看错误日志信息:
errpt -a
-------------------------------------------------
有关TCP/IP的命令
网路卡:
smit chgenet,chgtok,chgfddi,opschange,mktty:adptr架构快速路径
smit mkinet,ppp:slip与ppp快速路径
ifconfig:config界面
位址:
/etc/hosts 静态主机表
/etc/resolv.conf 位址解析的名称服务器
/etc/named.boot 名称服务器架构
/etc/named.ca 根名称服务器快取
/etc/named.data 位址列表
/etc/named.rev 反转指标列表
nslookup 查询名称服务器资讯
网络路由:
route 管理路由
netstat -rn 列出定义的路由
routed 路由(daekmin rip)
gated 路由(daekmin rip、egp、hello)
/etc/gateways 已知网关
/etc/networks 已知网路
服务:
/etc/services
/etc/inetd.conf
TCP/IP群组子系统:
/etc/rc.net
startsrc -g tcpip 启动全部的tcpip子系统
startsrc -s inetd 启动主要internet
除错:
iptrace 启动封包追踪
ipreport 追踪结果格式化输出
netstat 网络统计
ping 检查是否可以到达
查看HACMP,外部硬盘信息:
lscfg -v
lsdev -Cc adapter
对等机器信息:
/etc/.rhosts
/etc/hosts.equiv
/etc/hosts
-------------------------------------------------
观察进程内存使用情况:
ps aux 观察参数%mem:内存使用百分比 RSS:实际使用内存
vmstat free的单位为块,缺省值为4096bytst
-------------------------------------------------
创建raw设备时选择的类型:
raw_lv
从别的地方看来的,对于基本的日常维护有参考价值:
1. 文件系统是否满
方法: df –k 可以以K为单位检查文件系统的使用率。(90%以上,需要调整)
2. 检查系统出错日志 使用errpt |more来检查
清除现有的log: Errclear 0
3. 检查系统合法/非法登陆情况
使用Last命令来检查来自登陆的地方。
4. 检查系统是否有巨大的Core文件生成
使用 find / -name core –print来检查。对Core文件,一般直接删除就可以了。
5. 系统性能检查:
a) CPU性能:使用Vmstat, topas来检查
b) 内存使用情况:也是使用topas, vmstat来检查
c) 检查IO平衡使用情况:使用iostat来检查
d) 交换空间使用情况:使用lsps –a来检查
6. Mail检查
7. Diag 一个月一次
//mhy edit
系统关机:
shutdown +10
shutdown now
shutdown -r 重起
shutdown -Fr
切换到单模式:
telinit S
init s
shutdown -m
查看用户信息 lsuser -f
改变用户属性 chuser 参数=.. username
smit 用于图行方式 ,smitty用于命令行方式
例如smitty device
查看未定义的设备
lsdev -P |grep -i other
删除设备
rmdev -l name 此命令将设备处于断电状态。
彻底删除
rmdev -d -l name
set nonu -- not to display line no
:下输入行号,可到达对应行
在vi界面下使用命令
:%s#/usr/bin#/bin#g
可以把文件中所有路径/usr/bin换成/bin。也可以使用命令:
:%s/usr/bin/bin/g
其中“”是转义字符,表明其后的“/”字符是具有实际意义的字符,不是分隔符。
ctrl+u 向上移动
ctrl+d 向下移动
如何通过RMAN 来在线克隆一个RAC的数据库到单点的数据库。
大致步骤:
1。首先创建一个rman数据库,建议使用catalog , 在RAC以及被复制的服务器之外建立。并使RMAN能够与RAC数据库相连,并利用此rman程序实现对RAC数据库的备份。
2。建立将复制的数据库的实例SID , 可以不要数据文件,但要配置好listener并将其启动,将数据库启动到nomount状态,配置RMAN服务器,使得rman可以与复制数据库相连。
3。启动rman,具体语法参见:rman TARGET SYS/oracle@erptest1 CATALOG rman/rman AUXILIARY SYS/oracle@oraaux
4。配置相关通道,语法可以参考:CONFIGURE CHANNEL DEVICE TYPE disk CLEAR; RMAN> CONFIGURE DEFAULT DEVICE TYPE TO disk;RMAN> CONFIGURE DEVICE TYPE disk PARALLELISM 3;
5。创建一个数据库恢复script。比如:dbrec
具体语法可以参见:aa-rman.sql文件,摘录如下:
create script dbrec
{
set until time "to_date('2004/09/26:00:00:00','YYYY/MM/DD:HH24:MI:SS')";
SET NEWNAME FOR DATAFILE 1 TO '/d02/proddata/oravol401';
。。。。。。
set newname for datafile 437 to '/d02/proddata/oravol446';
DUPLICATE TARGET DATABASE TO ORAAUX
LOGFILE GROUP 1 ('/d02/proddata/redo01a.log',
'/d02/proddata/redo01b.log') SIZE 51200K ,
GROUP 2 ('/d02/proddata/redo02a.log',
'/d02/proddata/redo02b.log') SIZE 51200K ,
GROUP 3 ('/d02/proddata/redo03a.log',
'/d02/proddata/redo03b.log') SIZE 51200K ;
}
运行该恢复脚本
RMAN> run {execute script dbrec;}
1。先打PAatch 3766934
2。然后打3672076 ,这个patch比较麻烦,有很多预安装patch 3162988-----》3484474---》3671463
3298423, 3423613,3432914,3440815,3514816,3672076
3。设置workflow mail 这个步骤我就不说了,注意两个文件夹discard 和PROCESS一定要设。
4。修改用户的首选项,将通知格式设置为plain text mail的格式。
5。修改po 模块下的setup--->employee---->修改相关人员的mail设定。
6。以sysadmin职责运行 同步工作流(sync%wf%).
7。提交采购申请,正常情况下你就可以收到mail了。
问题仍有待解决。
哈哈,经过本人测试,目前没有特别好的方法。必须关掉一个实例和一个线程。
可以通过 RMAN的复制功能,轻松解决这个问题。











