Solaris&oracle运用点

来源:互联网 发布:淘宝打招呼软件 编辑:程序博客网 时间:2024/06/05 02:57

Oracle Temporary Tablespace

SQL>  alter tablespace temp add tempfile '/data/oradata/devdb3/temp01.dbf' size 50m autoextend on;

SQL> alter database tempfile '/data/oradata/devdb3/temp02.dbf' drop ;

SQL> alter tablespace temp add tempfile '/data/oradata/devdb3/temp02.dbf' reuse;

SQL> alter database tempfile '/data/oradata/devdb3/temp02.dbf' drop including datafiles;

==========================================================================================

Relocated Data file

SELECT * FROM DBA_DATA_FILES
select * from dba_temp_files

SQL> alter tablespace my_TABLESPACE read only;
SQL> !cp -p /data/oradata/ndrs/my_TABLESPACE01.dbf /opt/oracle/ndrs/.
SQL> alter tablespace my_TABLESPACE offline;
SQL> alter database rename file '/data/oradata/ndrs/my_TABLESPACE01.dbf' to '/opt/oracle/ndrs/my_TABLESPACE01.dbf';
SQL> alter tablespace my_TABLESPACE online;
SQL> alter tablespace my_TABLESPACE read write;
SQL> alter database backup controlfile to trace;
SQL> !rm /data/oradata/ndrs/my_TABLESPACE01.dbf

ALTER DATABASE
DATAFILE '/opt/oracle/ndrs/my_TABLESPACE01.dbf' RESIZE 800M

=========================================================================================

在DOS命令行状态下,输入字符串命令“netsh -c interface dump>c:net1.txt”,单击回车键后,当前工作站的网络配置信息,就全部被保存到C盘net1.txt文件中了(该文件保存着网络1环境中的上网参数);下面,打开net1.txt文件,你可以看到如图5所示的配置信息,包括工作站的IP地址、掩码IP地址、网关IP地址等。现在,你可以用笔记本电脑可能使用到的其他网络环境中的配置参数,替换这里的对应参数,其余内容保持不变,然后再将该文本文件另存为“net2.txt”(该文件保存着网络2环境中的上网参数);同样地,你可以生成net3.txt、net4.txt……netn.txt,让这些文件保存着网络3、网络4……网络n环境中的上网参数。 以后,笔记本电脑无论接入到哪个网络环境中,只要在DOS命令行状态下,执行“netsh exec c:netn.txt”命令,就能实现快速修改网络配置的目的了(这里的“netn.txt”文件,必须对应着指定的网络环境)。
http://www.netland.com.cn/TechDoc/T10426.asp?ID=861

===============================================================================================

Solaris cmd: find


find /path/dir1 -name "xxxx.yyy" -exec mv {} ./path/dir2 ;
find ./ -mtime +1 -print

find /path/dir1 -mtime +46 -exec mv {} /path/dir2 ;

如何查所有非*.c的文件呢?
find / -name "*.c" -prune -o -print
find . ! -name *.c

目录树小,可以用:
grep xxx `find .`

目录树大:
find . -type f -print | xargs grep xxx

find . -type f -size +10000 -exec ls -al {} ;
find . -atime +1 -type f - exec mv {} TMP ; # mv files older then 1 day to dir TMP
find . -name "-F" -exec rm {} ;   # a script error created a file called -F
find . -exec grep -i "vds admin" {} ;
find . ! -name "*.Z" -exec compress -f {} ;
find . -type f ! -name "*.Z" ! -name ".comment" -print | tee -a /tmp/list
find . -name *.ini
find . -exec chmod 775 {} ;
find . -user xuser1 -exec chown -R user2 {} ;
find . -name ebtcom*
find . -name mkbook
find . -exec grep PW0 {} ;
find . -exec grep -i "pw0" {} ;
find . -atime +6
find . -atime +6 -exec ll | more
find . -atime +6 -exec ll | more ;
find . -atime +6 -exec ll ;
find . -atime +6 -exec ls ;
find . -atime +30 -exec ls ;
find . -atime +30 -exec ls ; | wc -l
find . -name auth*
find . -exec grep -i plotme10 {};
find . -exec grep -i plotme10 {} ;
find . -ls -exec grep 'PLOT_FORMAT 22' {} ;
find . -print -exec grep 'PLOT_FORMAT 22' {} ;
find . -print -exec grep 'PLOT_FORMAT' {} ;
find . -print -exec grep 'PLOT_FORMAT' {} ;
find ./machbook -exec chown 184 {} ;
find . ! -name '*.Z' -exec compress {} ;
find . ! -name "*.Z" -exec compress -f {} ;
find /raid/03c/ecn -xdev -type f -print
find /raid/03c/ecn -xdev -path -type f -print
find / -name .ssh* -print | tee -a ssh-stuff
find . -name "*font*"
find . -name hpmcad*
find . -name *fnt*
find . -name hp_mcad* -print
find . -grep Pld {} ;
find . -exec grep Pld {} ;
find . -exec grep Pld {} ;
find . -exec grep PENWIDTH {} ; | more
find . -name config.pro
find . -name config.pro
find /raid -type d ".local_sd_customize" -print
find /raid -type d -name ".local_sd_customize" -print
find /raid -type d -name ".local_sd_customize" -ok cp /raid/04d/MCAD-apps/I_Custom/SD_custom/site_sd_customize/user_filer_project_dirs {} ;
find /raid -type d -name ".local_sd_customize" -exec cp /raid/04d/MCAD-apps/I_Custom/SD_custom/site_sd_customize/user_filer_project_dirs {} ;
find . -name xeroxrelease
find . -exec grep xeroxrelease {} ;
find . -name xeroxrelease
find . -name xeroxrelease* -print 2>/dev/null
find . -name "*release*" 2>/dev/null
find / -name "*xerox*" 2>/dev/null
find . -exec grep -i xeroxrelease {} ;
find . -print -exec grep -i xeroxrelease {} ;
find . -print -exec grep -i xeroxrelease {} ; > xeroxrel.lis
find . -exec grep -i xeroxrel {} ;
find . -print -exec grep -i xeroxrel {} ;
find . -print -exec grep -i xeroxrel {} ; | more
find /raid/03c/inwork -xdev -type f -print >> /raid/04d/user_scripts/prt_list.tmp
find . -exec grep '31.53' {} ;
find . -ls -exec grep "31/.53" {} ; > this.lis
find . -print -exec grep "31/.53" {} ; > this.lis
find . -print -exec grep 31.53 {} ; > this.lis
find . -exec grep -i pen {} /;
find . -exec grep -i pen {} ;
find . -print -exec grep -i pen {} ; | more
find . -exec grep -i pen {} ;
find . -atime +6 -exec ll | more ;
find . -atime +6 -exec ll ;
find . -atime +6 -exec ls ;
find . -atime +30 -exec ls ;
find . -atime +30 -exec ls ; | wc -l
find . ! -name '*.Z' -exec compress -f {} ;
find . -name 'cache*' -depth -exec rm {} ;
find . -name 'cache*' -depth -print | tee -a /tmp/cachefiles
find . -name 'cache[0-9][0-9]*' -depth -print | tee -a /tmp/cachefiles
find . -name 'hp_catfile' 'hp_catlock' -depth -print | tee -a /tmp/hp.cats
find . -name 'hp_catfile' -name 'hp_catlock' -depth -print | tee -a /tmp/hp.cats
find . -name 'hp_cat*' -depth -print | tee -a /tmp/hp.cats
find . -name 'hp_cat[fl]*' -depth -print | tee -a /tmp/hp.cats
find /raid -name 'hp_cat[fl]*' -depth -print
find . ! -name '*.Z' -exec compress -f {} ;
find . -name '*' -exec compress -f {} ;
find . -xdev -name "wshp1*" -print
find . -xdev -name "wagoneer*" -print
find . -name "xcmd" -depth -print
find /usr/contrib/src -name "xcmd" -depth -print
find /raid -type d -name ".local_sd_customize" -exec ls {} ;
find /raid -type d -name ".local_sd_customize"
   -exec cp /raid/04d/MCAD-apps/I_Custom/SD_custom/site_sd_customize/user_filer_project_dirs {} ;

=================================================================================

Solaris平台下的硬盘增设方法


Solaris平台下的硬盘增设方法大致如下:
1. 关闭系统,进入PROM状态 % init 0 ok (PROM状态提示)
2. 在PROM状态提示符下确认当前系统所连接的SCSI设备状况 ok probe-scsi 或 ok probe-scsi-all
这时,系统将显示所能识别的SCSI设备极其设备号(Target ID).如果新连接的硬 盘之信息没有出现时,请按下述方法进行确认.
1) 检查设备号是否重复?
    Target-ID SunOS 4.xSolaris 2.x
    3 内藏硬盘 
    1 硬盘 通常与SunOS 4.x一致.
    2 硬盘 当ID不重复时, 4,5也
    0 硬盘 可以用于硬盘.
    4 磁带  
    5 磁带  
    6 CD-ROM CD-ROM
2) 检查电缆,插口,终端器等物理连接是否无误?
3) SCSI电缆的总长度是否在6米以内?
3. 重新起动系统 ok boot -r
注意,只有加入"-r"选项时, 系统在起动时才给所识别了的设备(包括SCSI设备) 生成相应的设备文件.
4. 对新增设的硬盘进行盘区划分
进入系统状态后,执行format命令,对新增设的硬盘进行盘区划分.
执行例
% format (CR)
Searching for disks...done
 AVAILABLE DISK SELECTIONS:
       0. c0t3d0
          /sbus@1,f8000000/esp@0,800000/sd@3,0
Specify disk (enter its number): 0   //<-- 选择硬盘 
selecting c0t3d0
[disk formatted]
FORMAT 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
show         translate a disk address
label        write label to the disk
analyze      surface analysis
defect       defect list management
backup       search for backup labels
verify       read and display labels
save         save new disk/partition definitions
inquiry      show vendor, product and revision
volname      set 8-character volume name
!<cmd>       execute <cmd>, then return
quit
format> partition  <-- 键入partition(或par)进入分区状态
PARTITION 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
       7      - change `7' partition
       select - select a predefined 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
       !<cmd> - execute <cmd>, then return
       quit                     
partition> modify   <-- 键入modify(或mod),修改当前分区表.
Select partitioning base:
0. Current partition table (original)
1. All Free Hog Choose base
(enter number) [0]? 0 <-- 选择当前分区表.
Part    Tag    Flag    Cylinders Size    Blocks
0   unassigned  wm     0  17   15.90MB   (18/0/0)
1   unassigned  wm     18 88   62.71MB   (71/0/0)
2   unassigned  wm     0  742  656.29MB  (743/0/0)
3   unassigned  wm     89 121  29.15MB   (33/0/0)
4   unassigned  wm     0  0              (0/0/0)
5   unassigned  wm     122 230 96.28MB   (109/0/0)
6   unassigned  wm     231 555 287.07MB  (325/0/0)
7   unassigned  wm     556 742 165.18MB  (187/0/0)
Do you wish to continue creating a new partition
table based on above table[yes]? y <-- 键入y,以当前分区表为基准分区.
Free Hog partition[6]? 7 <-- 选择适当的浮动区.
(注1) Enter size of partition '0' [32562b, 18c, 15.90mb]: 16mb <-- 指定容量
Enter size of partition '1' [128439b, 71c, 62.71mb]: 62.7mb
(注2) Enter size of partition '3' [59697b, 33c, 29.15mb]: 29mb
Enter size of partition '4' [0b, 0c, 0.00mb]: 0
Enter size of partition '5' [197181b, 109c, 96.28mb]: 96mb
Enter size of partition '6' [587925b, 325c, 287.07mb]: 287mb
Part Tag Flag Cylinders Size Blocks
0 unassigned wm 0 18 16.78MB (19/0/0)
1 unassigned wm 19 89 62.71MB (71/0/0)
2 unassigned wm 0 742 656.29MB (743/0/0)
3 unassigned wm 90 122 29.15MB (33/0/0)
4 unassigned wm 0 0 (0/0/0)
5 unassigned wm 123 231 96.28MB (109/0/0)
6 unassigned wm 232 556 287.07MB (325/0/0)
7 unassigned wm 557 742 164.29MB (186/0/0)
Okay to make this the current partition table[yes]? y <-- 确认后键入y.
Enter table name (remember quotes): new_table <-- 键入适当的名称.
partition> label       <-- 键入label(或lab),设定系统标识.
ok to label disk? y <-- 键入y
partition> q           <-- 键入q退出分区状态.
format> q              <-- 键入q退出format
(注1) 当改变其他分区尺寸时, 浮动区(Free Hog)用于在容量范围内进行自动调 节.
(注2) 分区容量的具体指定方法为:
容量数值后面加"b": 指定块数.
容量数值后面加"c": 指定柱面数.
容量数值后面加"mb": 指定MB数.
建议采用"mb",以兆字节为单位指定分区容量.
5. 生成新的文件系统 用newfs命令将所划分的分区生成为新的文件系统.
% /usr/sbin/newfs /dev/rdsk/c0t1d0s7 (CR)
如果在上述过程中将整个硬盘指定为一个分区,可执行下述命令.
% /usr/sbin/newfs /dev/rdsk/c0t1d0s2 (CR)
6. 检查新生成的文件系统
用fsck命令检查新生成的文件系统是否正确.
% /usr/sbin/fsck /dev/rdsk/c0t1d0s7 (CR)
如果在上述过程中将整个硬盘指定为一个分区,可执行下述命令.
% /usr/sbin/fsck /dev/rdsk/c0t1d0s2 (CR)
7. 安装新生成的文件系统
建立安装用目录后用mount命令进行安装.
例如,要将第7分区之文件系统用于home1时,可执行下述命令.
% mkdir /home1 (CR)
% mount /dev/dsk/c0t1d0s7 /home1 (CR)
8. 确认安装结果 用df命令确认安装结果.
% df -k (CR)
9. 自动安装新设文件系统
为在系统起动时自动安装新设文件系统,修改/etc/vfstab文件.
 % vi /etc/vfstab (CR)
 #device     device      mount       FS      fsck    mount   mount
 #to mount   to fsck     point      type    pass    at boot options
 #
 /dev/dsk/c0t3d0s7 /dev/rdsk/c0t3d0s7 /home1  ufs    6     yes     -
10. 重新起动系统
% sync;sync;reboot (CR)


======================================================================

Solaris CPU offline/ online

 

psrinfo -v

psradm
psrset

prsradm -f procid 将处理器procid设为离线.
-n 让指定处理器在线.
-a 作用于所有处理器.
-v 对每次操作尝试的结果显示一条信息.

只有超级用户和系统管理员才能执行这条命令,
如果有LWP被绑定在某处理器上,那么该处理器不能设为离线.

 


From the OK prompt run
OK .asr // not the preceding '.'
To generate a listing of system devices. You will see the cpu in question labelled as 'CPU1'.

Enter
OK asr-disable cpu1
Verify the that CPU1 has been disabled by again running '.asr'. To enable the CPU1 again simple run
OK asr-enable cpu1

SQL Tuning


select sql_text from v$sqltext a where a.hash_value = (select sql_hash_value from v$session b where b.sid='&sid') order by piece asc

SQL> set autotrace trace explain

SQL> select index_name,column_name from user_ind_columns  where table_name ='my_tables';

SQL> alter session set sql_trace=true;

SQL> exec dbms_system.set_sql_trace_in_session(7,284,true)

===================================================================================

Temporary Tablespace


Creation of a TEMPORARY Tablespace
----------------------------------

SQL> create TEMPORARY tablespace temp_tempfile_local
2 TEMPFILE '/ora/V817/temp_temp.dbf' size 100M
3 EXTENT MANAGEMENT LOCAL UNIFORM SIZE 128K;
----------------------------------
SQL> create tablespace TEMP_DATAFILE_DICT
2 datafile '/tcase/oradata/V901/temp_data.dbf' size 100M
3 TEMPORARY;
Tablespace created.


Tempfiles Removal
---------------------------

a. You cannot remove datafiles from a tablespace until you drop the tablespace.
b. You can remove tempfiles from temporary tablespaces and keep the logical structure empty.
=> in 8i:
SQL> alter tablespace TEMP_TEMPFILE_LOCAL add tempfile '/oradata/V817/temp_temp01.dbf';
SQL> alter database tempfile '/oradata/V817/temp_temp01.dbf' drop;
SQL> !rm /oradata/V817/temp_temp01.dbf

=> in 9i: you can use the new clause INCLUDING DATAFILES to remove OS files
SQL> alter database tempfile '/oradata/V901/temp_temp01.dbf' drop including datafiles;

Note:160426.1

[NOTE:132663.1] ORA-03296 Resizing Temporary Locally Managed Tablespace
[NOTE:131769.1] ORA-03212 at Instance Startup
[NOTE:102339.1] Temporary Segments: What Happens When a Sort Occurs