服务管理
# svcs - report service status
## 显示所有服务状态
svcs -a 或 svcs
## 显示所有异常的服务
svcs -x
## 显示<服务>的依赖列表
svcs -d <服务>
## 显示依赖<服务>的其他服务列表
svcs -D <服务>
## 显示<服务>的PID
svcs -p <服务>
## 显示<服务>的所有可用信息
svcs -l <服务>
## 显示<服务>的日志目录
svcs -L <服务>
## 显示<服务>的日志信息,Solaris11+支持
svcs -L -v ssh
## 查看服务依赖的关系
svcs -d [ssh]
## 查看被依赖的服务
svcs -D [ssh]
## 查看服务的详细信息
svcs -l [ssh]
常见的状态: disabled 禁用状态。Offline 启用状态,未启用。Online 运行状态。Maintenance 错误状态。
# svcadm - manipulate service instances
svcadm enable|disable|restart|refresh|clear|mark|delegate|milestone <服务>
# inetd服务管理的服务
inetadm
包管理
# 在线升级系统
pkg update --accept --licenses
# 查看已安装软件列表
pkginfo |grep -i ftp
system SUNWftpr FTP Server, (Root)
# 获取已安装文件的包属性
pkgchk -l -p /usr/bin/mydir
# 删除软件包
pkgrm pkginst
# 同时删除多个包
pkgrm pkginst1 pkginst2
# Solaris11+
查看已安装的软件包列表:
pkg list
查找特定软件包:
pkg search <package-name>
查看特定软件包的详细信息:
pkg info <package-name>
列出已安装的所有包含特定文件的软件包:
pkg search -l <file-path>
设备管理
# iostat - report I/O statistics
# 查看所有块设备
iostat -x
extended device statistics
device r/s w/s kr/s kw/s wait actv svc_t %w %b
sd0 3.7 2.0 93.0 49.1 0.0 0.0 1.2 0 0
sd1 0.1 0.0 0.2 0.0 0.0 0.0 0.1 0 0
sd2 0.2 0.0 1.0 0.0 0.0 0.0 2.1 0 0
iostat -E
sd0 Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Vendor: VMware, Product: VMware Virtual S Revision: 1.0 Serial No:
Size: 17.18GB <17179869184 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 8 Predictive Failure Analysis: 0 Non-Aligned Writes: 0
sd1 Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Vendor: NECVMWar Product: VMware IDE CDR10 Revision: 1.00 Serial No:
Size: 0.77GB <771753984 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 21 Predictive Failure Analysis: 0 Non-Aligned Writes: 0
sd2 Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Vendor: Generic Product: Flash Disk Revision: 8.07 Serial No:
Size: 1.99GB <1992294400 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 69 Predictive Failure Analysis: 0 Non-Aligned Writes: 0
# rmmount, rmumount - mounts and unmounts removable media
# 可以看到可移动设备有一个U盘和光盘
rmmount -l
/dev/dsk/c3t0d0p0:1 rmdisk,rmdisk0,EFI,/media/EFI
/dev/dsk/c1t0d0s2 cdrom,cdrom0,cd,cd0,sr,sr0,Oracle_Solaris-11_3-Text-X86,/media/Oracle_Solaris-11_3-Text-X86
# 查看移动设备详细信息
rmformat -l
Looking for devices...
1. Logical Node: /dev/rdsk/c1t0d0p0
Physical Node: /pci@0,0/pci-ide@7,1/ide@1/sd@0,0
Connected Device: NECVMWar VMware IDE CDR10 1.00
Device Type: DVD Reader/Writer
Bus: IDE
Size: 736.0 MB
Label: <None>
Access permissions: Medium is not write protected.
2. Logical Node: /dev/rdsk/c3t0d0p0
Physical Node: /pci@0,0/pci15ad,790@11/pci15ad,1976@0/hub@2/storage@1/disk@0,0
Connected Device: Generic Flash Disk 8.07
Device Type: Removable
Bus: USB
Size: 1.9 GB
Label: <Unknown>
Access permissions: Medium is not write protected.
网络配置
# 查看tcp监听和端口占用
netstat -an -P tcp |grep -i listen
# 查看ip地址
ifconfig -a
# 查看ip地址(solaris10没有)
ipadm show-addr
# 启停接口:将IP地址栈和interface绑定(plumb:一般自动进行,无需手动)和解绑
ifconfig <interface> plumb [up]
ifconfig <interface> [down] unplumb
# 同ip link show
dladm show-link
# 配置默认路由
# Solaris10
vi /etc/defaultrouter
192.168.11.1
# Solaris11(defaultrouter文件在Solaris11中被弃用了,只能通过route命令配置路由)
# -p参数:持久化该路由项
route -p add default ip-address
# 配置其他路由
route -p add -net 203.0.113.0/24 -gateway 203.0.113.150
# 查看路由表项
netstat -rn
# 查看静态路由
route -p show
# 如下三个文件其实是一个文件,前两个都是最后一个的软连接
/etc/inet/ipnodes
/etc/hosts
/etc/inet/hosts
Solaris10和Solaris11网络管理比较
Task Information | Oracle Solaris 10 Command or Method | Oracle Solaris 11 Command or Method |
---|---|---|
Datalink configuration | dladm | dladm |
IP interface and IP address configuration | ifconfig Edit /etc/hostname* | ipadm |
DHCP server configuration | SMF service: svc:/network/dhcp-server: and default DHCP management commands: dhcpmgr, dhtadm, and pntadm | (Sun Legacy) SMF service: svc:/network/dhcp-server: SMF service and default DHCP management commands: dhcpmgr, dhtadm, and pntadm (ISC) SMF services: svc:/network/dhcp/server:ipv4 svc:/network/dhcp/server:ipv6 svc:/network/dhcp/relay:ipv4 svc:/network/dhcp/relay:ipv6 Configuration files: /etc/inet/dhcpd4.conf /etc/inet/dhcpd6.conf |
DHCP client configuration | ifconfig Edit /etc/dhcp* and /etc/default/dhcpagent | ipadm Edit /etc/default/dhcpagent |
Name services switch configuration | SMF service: svc:/system/name-service/switch:default and /etc/nsswitch.conf | SMF service: svc:/system/name-service/switch:default. Modify with svccfg; view with svcprop -p config svc:/system/name-service/switch:default |
System host name configuration | Edit /etc/nodename | hostname |
TCP/IP host name configuration | Edit /etc/inet/hosts . | Edit /etc/inet/hosts |
Network parameter administration (tunables) | ndd | ipadm |
Wireless network configuration | wificonfig | dladm |