免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2035 | 回复: 1
打印 上一主题 下一主题

solaris learning tips (solaris学习笔记) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-02-21 22:33 |只看该作者 |倒序浏览
本文档是本人学习solaris时所做笔记。其中包含一些总结和练习。供参考。

这累点点滴滴从底向上的学习方法觉得虽然系统,但是比较累。
另外一种是出问题后在网上临时搜解决方案照做,也许有效率。

如何学习solaris及其他系统,请提出宝贵意见。

author: ping


******************************************************************************************************************
**************************************************basis1**********************************************************
**************************************************basis1**********************************************************
**************************************************basis1**********************************************************
******************************************************************************************************************
Unix history:
        AT&T unix 1969                                        IBM AIX
                        ==> SVR4(industry std) ==>         Solaris
        BSD UNIX ==> SunOS        1988                        HP HP-UX


Solaris 10
        SunOS 5.x OS
        OpenNetworkComputing(ONC+)
        solaris desktop env GUI
shell:
        B shell (original UNIX)                        $                #                default for root

        C shell        (new features)                        hostname$        hostname#
       
        Korn shell: superset of B shell                $                #                default for non-root
                with C shell-like enhance

        Bash:        GNU B-again shell,
                features B & C
        Z,TC
       
uname -X
cal 2 2009                #calendar for current month
clear                        #clear the screen

##using man to search a command
    catman                        ##create windex database
    man -k KEYWORD                #search a command using the KEYWORD from the system
        man -k perl
        ......
        perl            perl (1)        - Practical Extraction and Report Language
        ......

#enter home dir
        cd
        cd ~                        #~ not supported in B shell, all others support
        cd ~HOMEDIR                #enter other users' homedir
        cd ~/DIR/..
       
#switch between 2 dirs: cd -
        bash-3.00# cd /
        bash-3.00# cd /export/home/
        bash-3.00# cd -
        /
        bash-3.00# cd -
        /export/home

#k shell metacharactor:
        *:        zero or any ch (except leading .)
            bash-3.00# ls -d d*
            dev      devices
        ?:        any single ch (except leading .)
            bash-3.00# ls -d de?
            dev       
        []        a SET of ch
            [a-z], [0-9]
                    #
                    ls [a-f]*
                    ls [fp]*
       
        quoting ch
            ''        instruct the shell to ignore all enclosed metacharacters
                    $ echo '$SHELL'
                $SHELL
                   
            ""       
            
                    ``        single backward quotation marks
                   
                    \       
                    $
                   
                    $ echo $SHELL
                /bin/ksh
                $ echo "$SHELL"
                /bin/ksh
               
                echo "user is in $(pwd) dir"
                user is in /export/home/user3 dir
                   

                   
    B shell:        /bin/sh                        /sbin/sh        root def
    C shell:        /bin/csh
    K shell:        /bin/ksh                                non-root def
    bash sh:        /bin/bash                   
   
        bash-3.00# ls -ld /bin      
        lrwxrwxrwx   1 root     root           9 Jan  5 13:24 /bin -> ./usr/bin

#ksh variables
    ##set var
        $ test=abc
            $ export $test                ##make the value of a variable known to a sub-shell
           
    ##display all vars: set/export/env
            $ export  
        HOME=/export/home/user3
        HZ=100
        LOGNAME=user3
        MAIL=/usr/mail/user3
        PATH=/usr/bin:
        PWD=/export/home/user3
        SHELL=/bin/ksh
        TERM=vt100
        TZ=PRC
        _=env
        abc
           
            $ set
            ERRNO=13
            FCEDIT=/bin/ed
            HOME=/export/home/user3
            HZ=100
            IFS='   
            '
            LINENO=1
            LOGNAME=user3
            MAIL=/usr/mail/user3
            MAILCHECK=600
            OPTIND=1
            PATH=/usr/bin:
            PPID=24873
            PS1='$ '
            PS2='> '
            PS3='#? '
            PS4='+ '
            PWD=/export/home/user3
            RANDOM=26820
            SECONDS=228
            SHELL=/bin/ksh
            TERM=vt100
            TMOUT=0
            TZ=PRC
            _=export
            abc
            test=abc
           
           
            $ env
            _=/usr/bin/env
            HZ=100
            PATH=/usr/bin:
            LOGNAME=user3
            MAIL=/usr/mail/user3
            SHELL=/bin/ksh
            HOME=/export/home/user3
            TERM=vt100
            PWD=/export/home/user3
            TZ=PRC

           
    ##echo or print a single var
        $ echo $test
        abc
        $ print $test
        abc
        $ set | grep test
        test=abc
   
    ##unset a var
        $ unset test
        $ set | grep test
        _=test
        $
        $ echo $test

        $ print $test

    ##customize ksh var
        PS1="$LOGNAME@`uname -n` \$PWD $"

        user3@x86npm /etc $cd /
        user3@x86npm / $
        user3@x86npm / $cd
        user3@x86npm /export/home/user3 $
       

    history
            recorded in .sh_history, which is controlled by HISTFILE, HISTSIZE
           
    complete filename
            ESC \
    asking for hints
            ESC =
           
           
#view file content       
cat, more, less, head, tail,

head -N
tail -N/+N

# count line/word/ch
wc -l/w/c/m FILENAME

cp -i                 #interactive mode, prevent overwriting to existing file
mv -i
rm -i

##completely remove a dir usually requires 2 steps:
rm -r /dir        #remove all content under the dir
rmdir                #remove an EMPTY dir


vi (=view)
    #cmd mode
           
    #edit mode
            i/I:        insert before the cursor/line
            a/A:        append after the cursor/line
            o/O:        open a new line above/below current curse
           
    #last line mode
            :


******************************************************************************************************************
**************************************************book1**********************************************************
**************************************************book1**********************************************************
**************************************************book1**********************************************************
******************************************************************************************************************


********************************************************************************
********************module 1: installation
********************************************************************************

grep METACLUSTER /var/sadm/system/admin/.clustertoc        #names of possible cluster configurations
cat /var/sadm/system/admin/CLUSTER                        #which cluster has been installed

!installation log:
/var/sadm/install_data/install_log


********************************************************************************
********************module 2: directory hierarchy
********************************************************************************
in memory:
/dev/fd
/devices
/etc/mnttab
/etc/svc/volatile
/proc
/system/contract        /system/object
/tmp
/var/run

file:
        inode
        datablocks
file type:
        - d l         !regular
        b c        !device
l:       
symbolic link: a file point to another file
        ln -s file1 link1
        can span FS
       
hard link: name <--> inode
        ln file1 file2                (file2 will be linked to same inode of file1)
        !verify with
        ls -li
        find . -inum 1282        #find files/dirs with inode number of 1282
        now rm file1 will not remove the file
        can't span FS


b,c
major/minor device number =
        modinfo                display information about loaded kernel modules
                -c        current status
                -w       
        devfsadm
               
       
********************************************************************************
********************module 3: local disk
********************************************************************************

bash-3.00# ls -l /dev/dsk/
total 32
lrwxrwxrwx   1 root     root          42 Dec 10 14:46 c0t0d0s0 -> ../../devices/pci@1e,600000/ide@d/sd@0,0:a
lrwxrwxrwx   1 root     root          42 Dec 10 14:46 c0t0d0s1 -> ../../devices/pci@1e,600000/ide@d/sd@0,0:b
lrwxrwxrwx   1 root     root          42 Dec 10 14:46 c0t0d0s2 -> ../../devices/pci@1e,600000/ide@d/sd@0,0:c
lrwxrwxrwx   1 root     root          42 Dec 10 14:46 c0t0d0s3 -> ../../devices/pci@1e,600000/ide@d/sd@0,0:d
lrwxrwxrwx   1 root     root          42 Dec 10 14:46 c0t0d0s4 -> ../../devices/pci@1e,600000/ide@d/sd@0,0:e
lrwxrwxrwx   1 root     root          42 Dec 10 14:46 c0t0d0s5 -> ../../devices/pci@1e,600000/ide@d/sd@0,0:f
lrwxrwxrwx   1 root     root          42 Dec 10 14:46 c0t0d0s6 -> ../../devices/pci@1e,600000/ide@d/sd@0,0:g
lrwxrwxrwx   1 root     root          42 Dec 10 14:46 c0t0d0s7 -> ../../devices/pci@1e,600000/ide@d/sd@0,0:h
lrwxrwxrwx   1 root     root          43 Dec 10 14:46 c1t0d0s0 -> ../../devices/pci@1c,600000/scsi@2/sd@0,0:a
lrwxrwxrwx   1 root     root          43 Dec 10 14:46 c1t0d0s1 -> ../../devices/pci@1c,600000/scsi@2/sd@0,0:b
lrwxrwxrwx   1 root     root          43 Dec 10 14:46 c1t0d0s2 -> ../../devices/pci@1c,600000/scsi@2/sd@0,0:c
lrwxrwxrwx   1 root     root          43 Dec 10 14:46 c1t0d0s3 -> ../../devices/pci@1c,600000/scsi@2/sd@0,0:d
lrwxrwxrwx   1 root     root          43 Dec 10 14:46 c1t0d0s4 -> ../../devices/pci@1c,600000/scsi@2/sd@0,0:e
lrwxrwxrwx   1 root     root          43 Dec 10 14:46 c1t0d0s5 -> ../../devices/pci@1c,600000/scsi@2/sd@0,0:f
lrwxrwxrwx   1 root     root          43 Dec 10 14:46 c1t0d0s6 -> ../../devices/pci@1c,600000/scsi@2/sd@0,0:g
lrwxrwxrwx   1 root     root          43 Dec 10 14:46 c1t0d0s7 -> ../../devices/pci@1c,600000/scsi@2/sd@0,0:h

bash-3.00# ls -l /dev/rdsk/
total 32
lrwxrwxrwx   1 root     root          46 Dec 10 14:46 c0t0d0s0 -> ../../devices/pci@1e,600000/ide@d/sd@0,0:a,raw
lrwxrwxrwx   1 root     root          46 Dec 10 14:46 c0t0d0s1 -> ../../devices/pci@1e,600000/ide@d/sd@0,0:b,raw
lrwxrwxrwx   1 root     root          46 Dec 10 14:46 c0t0d0s2 -> ../../devices/pci@1e,600000/ide@d/sd@0,0:c,raw
lrwxrwxrwx   1 root     root          46 Dec 10 14:46 c0t0d0s3 -> ../../devices/pci@1e,600000/ide@d/sd@0,0:d,raw
lrwxrwxrwx   1 root     root          46 Dec 10 14:46 c0t0d0s4 -> ../../devices/pci@1e,600000/ide@d/sd@0,0:e,raw
lrwxrwxrwx   1 root     root          46 Dec 10 14:46 c0t0d0s5 -> ../../devices/pci@1e,600000/ide@d/sd@0,0:f,raw
lrwxrwxrwx   1 root     root          46 Dec 10 14:46 c0t0d0s6 -> ../../devices/pci@1e,600000/ide@d/sd@0,0:g,raw
lrwxrwxrwx   1 root     root          46 Dec 10 14:46 c0t0d0s7 -> ../../devices/pci@1e,600000/ide@d/sd@0,0:h,raw
lrwxrwxrwx   1 root     root          47 Dec 10 14:46 c1t0d0s0 -> ../../devices/pci@1c,600000/scsi@2/sd@0,0:a,raw
lrwxrwxrwx   1 root     root          47 Dec 10 14:46 c1t0d0s1 -> ../../devices/pci@1c,600000/scsi@2/sd@0,0:b,raw
lrwxrwxrwx   1 root     root          47 Dec 10 14:46 c1t0d0s2 -> ../../devices/pci@1c,600000/scsi@2/sd@0,0:c,raw
lrwxrwxrwx   1 root     root          47 Dec 10 14:46 c1t0d0s3 -> ../../devices/pci@1c,600000/scsi@2/sd@0,0:d,raw
lrwxrwxrwx   1 root     root          47 Dec 10 14:46 c1t0d0s4 -> ../../devices/pci@1c,600000/scsi@2/sd@0,0:e,raw
lrwxrwxrwx   1 root     root          47 Dec 10 14:46 c1t0d0s5 -> ../../devices/pci@1c,600000/scsi@2/sd@0,0:f,raw
lrwxrwxrwx   1 root     root          47 Dec 10 14:46 c1t0d0s6 -> ../../devices/pci@1c,600000/scsi@2/sd@0,0:g,raw
lrwxrwxrwx   1 root     root          47 Dec 10 14:46 c1t0d0s7 -> ../../devices/pci@1c,600000/scsi@2/sd@0,0:h,raw


list device:
        cat /etc/path_to_inst
        prtconf                        !all dev
        prtconf | grep -v not        !only attached dev
        format

reconf device:
    #reconfiguraton reboot
        touch /reconfigure
        init 5
        #verify
        prtconf           or
        format
       
    #detect all attached disks online
        devfsadm
        devfsadm -c DEVICE-CLASS(disk|tape|port|audio|pseudo)
        devfsadm -i DRIVER-NAME(dad|sd|st|..)
        devfsadm -v (verbose)
        devfsadm -C

##################an example of bad disk###################
1) only 1 disk available
        a)ls -l /dev/dsk
        ##some 'fake' info? no IDE exist
        lrwxrwxrwx   1 root     root          42 Dec 10 14:46 c0t0d0s0 -> ../../devices/pci@1e,600000/ide@d/sd@0,0:a

        ##the real disk
        lrwxrwxrwx   1 root     root          43 Dec 10 14:46 c1t0d0s0 -> ../../devices/pci@1c,600000/scsi@2/sd@0,0:a

        b)format
        AVAILABLE DISK SELECTIONS:
               0. c1t0d0 <SUN36G cyl 24620 alt 2 hd 27 sec 107>
                  /pci@1c,600000/scsi@2/sd@0,0

        c)bash-3.00# cat /etc/path_to_inst | grep sd
        "/pci@1e,600000/ide@d/sd@0,0" 0 "sd"        ##real disk
        "/pci@1c,600000/scsi@2/sd@0,0" 3 "sd"        ##
        "/pci@1c,600000/scsi@2/sd@1,0" 1 "sd"   ##      

        d)prtconf | grep -v not | grep sd        ?
       
        #should be sth like this:
        "/pci@1e,600000/ide@d/sd@0,0" 3 "sd"
        "/pci@1c,600000/scsi@2/sd@1,0" 0 "sd"
       
2) now add 1 more disk

        a)
        ls -l /dev/dsk
        ##new disk appear
        ls -l /dev/dsk
        lrwxrwxrwx   1 root     root          43 Dec 22 22:27 c1t1d0s0 -> ../../devices/pci@1c,600000/scsi@2/sd@1,0:a
       
        b)
        format
        ##new disk appear
        AVAILABLE DISK SELECTIONS:
               0. c1t0d0 <SUN36G cyl 24620 alt 2 hd 27 sec 107>
                  /pci@1c,600000/scsi@2/sd@0,0
               1. c1t1d0 <drive not available>
                  /pci@1c,600000/scsi@2/sd@1,0
        Specify disk (enter its number): ^C
       
        ##console message:
        Dec 23 00:02:16 V2102 genunix: WARNING: Device /pci@1c,600000/scsi@2/sd@1,0 failed to power up.
        Dec 23 00:02:36 V2102 scsi: WARNING: /pci@1c,600000/scsi@2/sd@1,0 (sd1):
        Dec 23 00:02:36 V2102   offline or reservation conflict



partitioning HD:
wasted space vs. overlapping slides

partition a disk:
    disk label=VTOC:
            1st disk sector(512B block)
        only 1st disk slice contains,all slices reserve 1st sector for its use.
       
        contains: partition table/etc.
       
        prtvtoc /dev/dsk/c#t#d#s#
                bash-3.00# prtvtoc /dev/dsk/c1t1d0s0
                * /dev/dsk/c1t1d0s0 partition map
                *
                * Dimensions:
                *     512 bytes/sector
                *     107 sectors/track
                *      27 tracks/cylinder
                *    2889 sectors/cylinder
                *   24622 cylinders
                *   24620 accessible cylinders
                *
                * Flags:
                *   1: unmountable
                *  10: read-only
                *
                *                          First     Sector    Last
                * Partition  Tag  Flags    Sector     Count    Sector  Mount Directory
                       0      2    00   16386408  20480121  36866528   /
                       1      3    01          0  16386408  16386407
                       2      5    00          0  71127180  71127179
                       5      0    00   36866529  20480121  57346649   /u02
               7      8    00   57346650  13780530  71127179   /export/home

        format->verify
                Primary label contents:

                Volume name = <        >
                ascii name  = <SUN36G  cyl 24620 alt 2 hd 27 sec 107>
                pcyl        = 24622
                ncyl        = 24620
                acyl        =    2
                nhead       =   27
                nsect       =  107
                Part      Tag    Flag     Cylinders         Size            Blocks
                  0       root    wm    5672 - 12760        9.77GB    (7089/0/0)  20480121
                  1       swap    wu       0 -  5671        7.81GB    (5672/0/0)  16386408
                  2     backup    wm       0 - 24619       33.92GB    (24620/0/0) 71127180
                  3 unassigned    wm       0                0         (0/0/0)            0
                  4 unassigned    wm       0                0         (0/0/0)            0
                  5 unassigned    wm   12761 - 19849        9.77GB    (7089/0/0)  20480121
                  6 unassigned    wm       0                0         (0/0/0)            0
                  7       home    wm   19850 - 24619        6.57GB    (4770/0/0)  13780530
        fmthard
       
        ##relabel a disk (also a vtoc backup/restore method)
        #backup vtoc
        prtvtoc /dev/dsk > /var/tmp/c1t1d0s0.vtoc
        #restore vtoc per the backup file
        fmthard -s /var/tmp/c1t1d0s0.vtoc /dev/dsk/cxtxdxsx
        ##clear a vtoc
        fmthard -s /dev/null /dev/dsk/cxtxdxsx
            ##destroy a vtoc
            dd if=/dev/zero of=/dev/rdsk/c#t#d#s# bs=512 count=1
           
    format utility:
            # Data file for the 'format' program.  This file defines the known disks, disk types, and partition maps.
        /etc/format.dat
           
    SMC:
        /etc/init.d/init.wbem start|stop|status
        smc&

********************************************************************************
********************module 4: FS
********************************************************************************
disk based
        ufs: based on berkeley ffs
        pcfs: unix implementation of DOS FAT32 FS. can be used to access PC FS
        hsfs/ufs: for DVD/CD-ROM
       
distributed
        NFS
pseudo
        tmpfs
        swapfs
        ..
        procfs
        mntfs

UFS:
disk:
                                                       
sector------------->track---->cylinder-->cyl grp------->slice(partition)------------>FS
(=blk:512B)                                (>16cyl/grp)       
|                                                        device name:
v                                                           logical name:
fragment(1KB)                                                c#t#d#s# (logical name: /dev/dsk/...;/dev/rdsk/...)
|                                                        ls -l /dev/dsk/c#t#d#s#
v                                                format
data blk(8K)                                                |
                                                        |ln -s
                                                        |                                        LUN(logical Unit#, disk#)
                                                        v                                                 |
                                                        physical name: /devices/pci@1e,600000/ide@d/sd@0,0:a,raw
                                                                                                       |   |
                                                                                                  target# slide#
                                                format
                                                        |
                                                        |shorten,assigned by kernel
                                                        |
                                                        v
                                                        instance name: sd#, dad#, st#
                                                cat /etc/path_to_inst

disk map:
                name:                        sectors                PrROM program
=================================================================================
                disk-label/vtoc                0(1st 512B-blk in 1st slide)
                                                        POST
                                                        boot boot-device
                bootblk(by installboot)        1-15                boot-> bootblk->mem
                (contain a UFS reader)                        bootblk->usfboot->mem
                                                        ufsboot->2kernels->mem
                                                                static core:/platform/`uname -m`/kernel/sparcv9/
                                                                |genunix(plat-indep)        (sun4u)
                                                                |        => kernel
                                                                |unix(plat-specific)
                                                               
                                                                    (dynamic)modules:
                                                                    |drvs,fs,streams...
                                                                    |/platform/`uname -m`/kernel/
                                                                    |        (sun4u)
                                                                    |/platform/`uname -i`/kernel
                                                                        (SUNW,Ultra-Enterprise)
                                                                       
                                                        kernal read conffile:/etc/system
                                                        kernal->ufsboot->load modules->

                                                        kernel-boot->/etc/init-ln->/sbin/init->svc.startd
                                                                                        /etc/inittab
                                                                                       

1st cylinder group:                                16 cylinders
                primary superblock        16-31
                backup superblock        32-47
                cylinder group block        48
                inode table                ?
                data blocks                xxx
                                                16 cylinders
2nd cylinder group:
                backup superblock       
                cylinder group block       
                inode table               
                data blocks                xxx
......
==============================================================================================
newfs
    front-end of mkfs
    destructive
   
    newfs /dev/rdsk/c#t#d#s#                #repeat for every slides
                                            #create lost+found dir
                                           
    fstyp -v /dev/dsk/c#t#d#s# | head        #check minfree
    newfs -m 2 /dev/dsk/c#t#d#s#        #specify a minfree: 2%
    tunefs -m 1 /dev/dsk/c#t#d#s#        #change the minfree
   
fsck
    check data consistency of a FS, attempt to correct/repair
    don't run it when mounted
    can run while under single-user mode

df/du/quot: monitor FS use
    df         -k                #report space in kbytes
            -h                #more readable format
            [option]        #FS: /export/home; or device: /dev/dsk/c#t#d#s#
                                                    (need to already newfs)
    du        -k                #report #of blocks used by dir/files
            -h                #more (human) readable format
                [option]        #a dir
                
    quot-a                #report space usage by each user on all mounted FS
            -f                #report also file numbers
                [option]        #a FS or the corresponding dev file
                
                bash-3.00# quot -f /export/home
            /dev/rdsk/c0d0s7:
            5537110 43489   root   
               56       4   uucp   
                4       4   daemon  
                    3       5   adm     
            
            

......
超出帖子限制,完整见附件。

solaris-tips.rar

34.3 KB, 下载次数: 41

评分

参与人数 1可用积分 +3 收起 理由
yuhuohu + 3 我很赞同

查看全部评分

论坛徽章:
0
2 [报告]
发表于 2009-02-23 10:42 |只看该作者
哦 感谢分享
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP