操作系統的版本:Solaris 1.x(sunos4.1.x), Solaris 2.x(sunos 5.x), Solaris 7, Solaris 8
特點: 多用戶, 多任務(or 多進程,多線程), 分佈式計算(處理)
應用: Client-Server方式中的服務器
o NFS Server,
o Name services Server,
o mail Server,
o Operating system Server,
o Database Server
o Application Server
2. SUN 服務器體系結構
硬件(Hardware) --> Solaris 系統內核(Kernel)-->指令 Shell-->應用軟件(Applications)
o SUN 服務器的體系結構發展(Kernel and Application Architecture):
[1] SPARC-->[2] SuperSPARC-->[3] UltraSPARC-->[4] sun4c-->[5] sun4m-->[6] sun4u
o 常見硬件組成
[1] 處理器 CUP,
[2] 內存 Memory,
[3] 系統總線 bus,
[4] 硬盤 disk,
[5] 顯示器 monitor,
[6] 鍵盤 keyboard,
[7] 光驅 cdrom,
[8] 磁帶機 tape,
[9] 網卡 net
......
3. Openboot(Prom) 常用命令 及 Solaris 操作系統的安裝
Openboot(Prom) 常用命令:
=========================
ok> help (幫助命令)
ok> banner (顯示系統hostid, memory, mac addr等nvrom配置信息)
ok> .version (顯示prom版本信息)
ok> devalias (系統設備別名)
例如
devalias cdrom1 /sbus/SUNW,fas@e8800000/sd@5,0
ok> nvalias (prom命令/信息別名)
ok> probe-scsi-all (顯示所有scsi設備)
ok> printenv (顯示prom系統環境變量)
ok> setenv (設置prom系統環境變量)
例如:
setenv auto-boot false
setenv boot-device disk net cdrom
ok> set-defaults (設置prom系統環境變量爲缺省值)
ok> reset
Solaris 操作系統的安裝:
=======================
o 從光盤啓動,並安裝操作系統命令:
ok> boot cdrom,
o 終止系統安裝/啓動:
stop+a--> sync--> reset
o 繼續安裝/啓動
ok> go,
o 安裝過程中須提供主要信息
[1]主機名host name,
[2]網絡network,ip地址,
[3]網絡服務器類型nis+/other/none/standlone,
[4]子網掩碼netmask,
[5]時區time zone,
[6]日期/時間date/time
[7]安裝方式:升級/初始安裝upgrade/initial,
[8]硬盤分區信息
例如:partition:0 /,
1 swap,
2 backup,
3,
4,
5,
6 /usr,
7 /export/home
o Solaris操作系統常見分區功能
[1] / 操作系統根目錄
[2] Swap 內存交換區
[3] /usr 存放系統應用軟件及命令
[4] /opt 安裝用戶應用軟件
[5] /var 系統信息存放區
[6] /export/home 用戶目錄區
o 一般Sun主機開機磁區預設是a,若該硬碟實際開機磁區不是a而是c,那就無法開機
請按stop + a,進入OK模式,下指令更改開機磁區代號:setenv boot-device disk:c
重開機看是否可以開機,若仍無法開機,請試著更改為其他開機磁區代號,例如:a, b, c, d...
setenv boot-device disk:a
boot
或
setenv boot-device disk:b
boot--------------------------------------------
開機後,可以下指令看partition table會更清楚原因
1. 下指令:format
會列出所有硬碟,例如:0. c0t0d0
2. 0
選代號0 硬碟
3. p
partition table
4. p
print partition table,
如下:0 swap → s0 (a)
1 home → s1 (b)
2 root → s2 (c)
5. q
quit一般Sun主機boot-device預設是s0 (即是a),若該硬碟實際boot-device不是a而是別的磁區,那就無法開機
由於我們的boot-device是s2 (即是c),所以才必須下指令更改設定:setenv boot-device disk:c
--------------------------------------------
Solaris 查看 boot-device 指令。
請先su到root
#eeprom boot-device
結果=>
boot-device=disk:c
--------------------------------------------
Sun主機更改hostname,IP,NIS等設定請下指令:sys-unconfig
重開機後,將會發現所有選項的設定值都會移除
需重新設定一次所有選項o 系統安裝信息日誌:
-------------------------------
/var/sadm/install/contents, install_log
4. 應用軟件常用安裝/刪除命令(add/delete software)
圖形工具命令
============
# admintool&
命令行工具
==========
# pkginfo, 例如: # pkginfo | grep ab
# pkgadd, 例如: # pkgadd -d . SUNWsprot SUNWabc
# pkgrm, 例如: # pkgrm SUNWsport SUNWabc
# pkgchk 例如: # pkgchk SUNWsport SUNWabc
查看patch: # showrev -p,
安裝patch: # ./installpatch .
備份patch: # ./backoutpatch 102972-01
patch安裝目錄: /var/sadm/patch
patch信息網站: http://sunsolve.sun.com
6. 操作系統啓動過程及運行級別
操作系統啓動過程
================
[1] prom (系統自檢selftest) ,
[2] bootblk, (系統引導盤啓動扇區),
[3] ufsboot (/platform/'uname -i'/ufsboot),
[4] kernel (initself, /kernel/genunix, /etc/system),
[5] init (/sbin/init, /etc/inittab, /sbin/rc*.d,
/etc/rc*.d, /etc/init.d)
操作系統自動配置過程
====================
[1] 內核上載入內存(kernel module are load to memory)
o 靜態內核static core:
/kernel/genunix, /platform/.../kernel/unix,
o 動態內核dynamically loaded module:
driver module, streams, ufs module, nfs module
/kernel/,/platform/.../kernel/unix, /usr/kernel
o /etc/system內容:
moddir,
exclude rootdev,
set pt_cnt=100
...............
[2] 設備配置(device configration )
o device tree: /devices, /dev
o /etc/path_to_install
查看操作系統配置
==================
# dmesg,
# printconf,
# sysdef
# /usr/platform/sun4u/sbin/prtdiag
# /usr/platform/sun43u/sbin/prtdiag
重新配置系統硬件
=================
# touch /reconfigure
# init 0
ok boot -r (重新啓動/配置系統硬件)
ok boot -ar
在系統運行情況下,如果不想重新啓動系統,
安裝硬盤/磁帶等熱插拔硬件,則:
# drvconfig
# devlinks
# disks
# tapes
查看配置情況:
# dmesg
# printconf
# sysdef
操作系統運行級別
==================
系統啓動時,進入/etc/inittab中initdefault所定義的運行級別(deafult 3)
各運行級別的定義:
run level:0, (halt, shotdown, stop+a,sync,go )
1, (single user, boot -s, init s )
2, (multiuser, unshare net)
3, (multiuser, deafult)
5, (halt, power off )
6, (reboot to level 3 )
S (init 1, boot -s)
改變系統運行級別命令
====================
# init 0, halt, shotdown, stop+a,sync,go
# init 1, single user, boot -s, init s
# init 2, multiuser, unshare net
# init 3, multiuser, deafult
# init 5, halt, power off
# init 6, reboot to level 3
# init s, init 1, boot -s
# init *,shotdown,halt,poweroff, reboot -- -r, reboot -- -s
ok> boot -s, boot -sra
啓動、關閉Solaris 操作系統
==========================
ok> boot -r (一般在安裝新設備如硬盤等後,重起機器,重建系統內核)。
ok> boot cdrom - brower (從CDROM啓動機器,重新安裝系統,界面爲瀏覽器方式)。
# sync (將內存中的內容寫入硬盤)。
# halt (或 /etc/init 0) (關閉系統)。
# reboot
7. 操作系統啓動/關閉時運行的腳本命令
Solaris操作系統會在系統啓動或關閉時自動運行腳本命令
例如: 有一個啓動/關閉數據庫的命令腳本/etc/init.d/rdbms,
想在系統啓動/停止時自動啓動/關閉數據庫:
# vi /etc/init.d/rdbms
# cd /etc/init3.d
# ln /etc/init.d/rdbms S22rdbms (在系統啓動時,運行命令腳本)
# cd /etc/init0.d
# ln /etc/init.d/rdbms K8822rdbms (在系統關閉時,運行命令腳本)
也可手動執行:
# /etc/init.d/rdbms stop
# /etc/init.d/rdbms start
要定時運行一個程序
====================
在/var/spool/cron/crontabs/root中加入
分_時_日_月_年 /運用程序
8. 硬盤分區及格式化(disk partition and format )
# foramt (可顯示硬盤類型, 大小, 分區情況. 可重新分區, 格式化等)
0 >partition>p>0>1>3>4>5>6>7>print>label>format>quit>quit
0 root wm 0 - 3514 3.62GB (3515/0/0) 7592400
1 swap wu 3515 - 3757 256.29MB (243/0/0) 524880
2 backup wm 0 - 3879 4.00GB (3880/0/0) 8380800
3 unassigned wm 3758 - 3879 128.67MB (122/0/0) 263520
4 unassigned wm 0 0 (0/0/0) 0
5 unassigned wm 0 0 (0/0/0) 0
6 unassigned wm 0 0 (0/0/0) 0
7 unassigned wm 0 0 (0/0/0) 0
#foramt
1>type
<SUN4.2G cyl 3880 alt 2 hd 16 sec 135>
>partition>print>0
root wm 0 1940c
>7
root wm 0 1940c
>p
0 root wm 0 -1939 2.00GB (1940/0/0) 4190400
2 backup wm 0 - 3879 4.00GB (3880/0/0) 8380800
7 home wm 1940-3879 2.00GB (1940/0/0) 4190400
>label>quit>quit
常見文件系統類型
================
[1]ufs,
[2]hsfs,
[3]pcfs,
[4]vxfs
....
設備名描述(硬盤)
==================
/dev/rdsk/c0t0d0s0,(裸設備/字符設備raw disk)
/dev/dsk/c0t0d0s0,(邏輯設備/塊設備logicl disk , block device)
存儲設備上建立文件系統
======================
# newfs /dev/rdsk/c0t1d0s7
系統文件系統記錄
=================
# vi /etc/vfstab
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 /cache ufs 2 yes -
/dev/dsk/c0t0d0s7 /dev/rdsk/c0t0d0s7 /export/home ufs 2 yes -
/dev/dsk/c0t1d0s7 /dev/rdsk/c0t1d0s7 /export/home1 ufs 2 yes -
swap - /tmp tmpfs - yes -
常用文件系統的操作命令
======================
示例:
# umount /export/home1
# mount /dev/dsk/c0t1d0s7 /export/home1
# umount /dev/dsk/c0t1d0s7
# mount -F pcfs /dev/diskette /floppy (mount 軟盤)
# mount -F hsfs -o ro /dev/rdsk/c0t6d0s0 /cdrom (mount 光驅)
# mountall -l
# umountall -l
# volcheck
# fdformat (軟盤格式化)
# eject cdrom (彈出光驅)
# eject floppy (彈出軟盤)
Swap區文件系統的管理
====================
# swap -l,-a,-d,-s
增加Swap區示例
# mkfile 20m /export/home1/swap
# swap -a /export/home1/swap
# swap -l
# swap -d /export/home1/swap
# vi /etc/vfstab
/dev/dsk/c0t0d0s1 - - swap - no -
/export/home1/swap - - swap - no -
swap - /tmp tmpfs - yes -
文件系統的維護/管理(maintain file system )
[1] fsck,sync,fslush deamon( 30 second)
stop+a
sync
[2] # umount /dev/dsk/c0t0d0s7
# fsck /dev/rdsk/c0t0d0s7
# fsck /export/home
# mount /dev/dsk/c0t0d0s7 /export/home
# ls /export/home/lost+found
10. 系統備份/恢復(backup and restore )
系統備份級別
============
[1] 共10級 level,
[2] 0 級爲全備份full,
[3] 2-9 級爲增量備份inc,
[4] /etc/dumpdates,
備份設備一般爲磁帶
==================
[1]tape,
[2]設備名 /dev/rmt/0lbn (l,m,h density; b BSD behavior, n no rewind)
系統系統備份/恢復命令
=====================
[1] ufsdump,
[2] ufsrestore,
例如:
# ufsdump 0uf /dev/rmt/0 /export/home
# cd /var/tmp
# ufsrestore tvf /dev/rmt/0
# ufsrestore xvf /dev/rmt/0 /export/home
恢復系統根目錄操作舉例(restore / file system )
ok> boot cdrom -s
系統啓動後,不進行安裝,打開一個命令窗口:
# newfs /dev/rdsk/c0t3d0s0
# fsck /dev/rdsk/c0t3d0s0
# mount /dev/dsk/c0t3d0s0 /a
# cd /a
# ufsdump rvf /dev/rmt/0
# rm restoresymtable
# cd /usr/platform/'uname -i'/libfs/ufs
# installboot bootblk /dev/rdsk/c0t3d0s0
# umount /a
# init 6
常用備份/恢復命令(dditional backup command )
============================================
[1] mt,
[2] tar,
[3] dd,
[4] cpio
軟盤操作
===========
# volcheck
# fdformat -U (unix格式化軟盤), fdformat -d (dos 系統格式化)
# newfs /vol/dev/aliases/floppy0(在軟盤上建UFS文件系統)
# mount -t pcfs /dev/fd0 /pcfs
# eject floppy
光驅操作
=========
# mount -F hsfs /dev/dsk/c0t6d0s0 /mnt/cdrom
# fuser -k /mnt/cdrom
# eject
磁帶機操作
============
# mt -f /dev/rmt/0 rew (到帶)
# mt -f /dev/rmt/0n status{eof | rewind | erase | offline | bsf n | fsf n}
(0n 表示磁帶操作完後不到帶,
status 表示查看磁帶狀態,
eof 表示到磁帶最後一個文件,
rewind 表示到帶到磁帶最前,
erase 摸掉,
offline 彈出磁帶,
bsf n 磁帶往回退n個文件,
fsf n 磁帶往前n個文件)
# tar xvf /dev/rmt/0
(從磁帶到硬盤,解開歸檔文件)
# tar tvf /dev/rmt/0
(查看磁帶內容,查看歸檔文件內容)
# tar cvf /dev/rmt/0 文件系統
(將文件系統考入磁帶,將多個文件、目錄建成歸檔文件)
11. 網絡管理(network)
相關配置文件
=============
[1] /etc/nodename
[2] /etc/hosts
[3] /etc/hostname.hme0
(qe0, le0, hme1, hme2, ..., hme0:1, hme0:2, ... )
[4] /etc/netmasks
[5] /etc/networks
[6] /etc/defaultrouter
[7] /etc/notrouter
[8] /etc/inetd.conf
[9] /etc/rpc
[10] /etc/services
相關進程deamon:
================
[1] in.tcpipd
[2] in.routed
[3] in.rdisc
......
常用網絡管理命令command:
========================
[1] ifconfig -a
[2] netstat -rn
[3] snoop -d hme0
[4] route
[5] arp -a
[6] /usr/sbin/ping
[7] /usr/bin/telnet
[8] /usr/bin/rlogin
[9] /usr/bin/ftp
[10] /usr/openwin/bin/xhost
配製網絡端口
============
# ifconfig
示例:
# ifconfig qe0 inet 10.10.10.1 netmask 255.255.255.0 broadcast 10.10.10.255 plumb
# ifconfig qe0 inet 10.10.10.1 netmask 255.255.255.0 broadcast 10.10.10.255 up
# ifconfig qe0 inet 10.10.10.1 netmask 255.255.255.0 broadcast 10.10.10.255 down
修改路由表
============
# netstat -r
# route add net 10.10.10.0 10.10.10.1 1
# route add default 10.10.10.1 1
o 增加靜態路由:
# vi /etc/defaultrouter
10.10.10.1 i1
# sync;sync;reboot
o 查看路由進程
# ps -ef |grep routed
重新關閉/啓動tcp/ip協議進程
=============================
#sh /etc/init.d/inetinit stop
#sh /etc/init.d/inetinit start
12. 路由服務器:
系統有兩個/或兩個以上的網口,可作爲路由器或防火牆
禁止兩個網口間路由ip
====================
# cd /etc
# touch notrouter
# sync
# sync
# reboot
查看路由進程
=============
# ps -ef |grep routed
# ps -ef |grep in.rdisc
相應配置文件
============
[1] /etc/named.boot
[2] /etc/named.conf (only for solaris 2.7)
[3] /var/named/db.*;
[4] /etc/nsswitch.conf
[5] /etc/resolv.conf
相應系統進程
============
[1] in.named;
[2] bind
相關命令
========
[1] /etc/init.d/inetsvc;
# /etc/init.d/inetsvc stop
# /etc/init.d/inetsvc start
[2] nslookup
域名服務client端配置示例
========================
# vi /etc/nsswitch.conf
hosts: files dns
# vi /etc/resolv.conf
domain leadcom.com
search leadcom.com
nameserver 192.168.0.100
# nslookup
14. NIS 服務器
相應配置文件
============
[1] /var/yp,
[2] /var/yp/Makefile
[3] /etc/defaultdomain
[4] /etc/nsswitch.conf
[5] /etc/hosts,
[6] /etc/networks, ...
相應系統進程
============
[1] ypserv;
[2] ypbind
相關命令
========
[1] domainname
[2] /etc/init.d/rpc (start/stop ypserv,ypbind)
[3] ypinit -m; ypinit -c
[4] yppush;
[5] ypcat
NIS 配置示例
========================
# vi /etc/defaultdomain
YP.sun.com
# domainname YP.sun.com
# cd /var/yp
# cp /etc/nsswitch.nis /etc/nsswitch.conf
# vi Makefile
#B=-b nis no dns
B=
B=-b nis also dns
#B=
# vi resolv.conf
# /usr/ccs/bin/make
# ypinit -m
# /etc/init.d/rpc start
# yppush
# ypcat hosts
# ypinit -c
client端配置
============
# vi /etc/defaultdomain
YP.sun.com
# domainname YP.sun.com
# cp /etc/nsswitch.nis /etc/nsswitch.conf
# ypinit -c
# /etc/init.d/rpc start
# ypcat hosts
15. NFS 文件系統(nfs file system )
相應配置文件
============
[1] /etc/dfs/dfstab;(nfs server)
例如:
# vi /etc/dfs/dfstab
share -F nfs -o rw=engineering -d "home dirs" /export/home
share -F nfs -o ro -d "app dirs" /export/app
share -F nfs -o ro -d "man dirs" /usr/share/man
[2] /etc/vfstab;(nfs client)
# vi /etc/vfstab
i2:/export/home - /export/home nfs - yes soft,bg
i2:/export/app - /export/app nfs - yes soft,bg
i2:/usr/share/man - /usr/share/man nfs - yes soft,bg
rw|ro,bg|fg, soft|hard, intr|nointr,suid|nosuid, timeo=n
default=11x.1sec, retry=n 1k.
相應系統進程
============
[1] mountd
[2] nfsd
[3] statd
[4] lockd
相關命令
========
[1] share,
例如:
# share -F nfs /export/home
# share -F nfs -o ro /usr/share/man
[2] unshare,
[3] shareall,
[4] unshareall;
[5] mount
例如:
# mount nfsserver:/export/home /export/home
# mount nfsserver:/export/app /export/app
# mount nfsserver:/usr/share/man /usr/share/man
[6] umount,
[7] mountall,
[8] umountall,
[9] dfshares host,
[10] dfmounts
[11] /etc/init.d/nfs.server; /etc/init.d/nfs.client
例如:
# /etc/init.d/nfs.server start