solaris 运维命令
记录自己学习的一些solaris常见命令和运维命令
1、常见查看命令
a. 查看系统运行模式
xxx:~# isainfo -v
#64位模式输出
64-bit amd64 applications
avx2 fma bmi2 bmi1 rdrand f16c vmx avx xsave pclmulqdq aes movbe
sse4.2 sse4.1 ssse3 popcnt tscp cx16 sse3 sse2 sse fxsr mmx cmov
amd_sysc cx8 tsc fpu
32-bit i386 applications
avx2 fma bmi2 bmi1 rdrand f16c vmx avx xsave pclmulqdq aes movbe
sse4.2 sse4.1 ssse3 popcnt tscp ahf cx16 sse3 sse2 sse fxsr mmx
cmov sep cx8 tsc fpu
#32位模式输出
32-bit i386 applications
avx2 fma bmi2 bmi1 rdrand f16c vmx avx xsave pclmulqdq aes movbe
sse4.2 sse4.1 ssse3 popcnt tscp ahf cx16 sse3 sse2 sse fxsr mmx
cmov sep cx8 tsc fpu
b.cpu状态检查
命令可以查看到对应的CPU插槽的CPU状态如下都为on-line 4U 运行频率是3093 MHz
xxx:~# psrinfo -v
Status of virtual processor 0 as of: 06/17/2024 10:25:03
on-line since 06/11/2024 14:32:56.
The i386 processor operates at 3093 MHz,
and has an i387 compatible floating point processor.
Status of virtual processor 1 as of: 06/17/2024 10:25:03
on-line since 06/11/2024 14:32:58.
The i386 processor operates at 3093 MHz,
and has an i387 compatible floating point processor.
Status of virtual processor 2 as of: 06/17/2024 10:25:03
on-line since 06/11/2024 14:32:58.
The i386 processor operates at 3093 MHz,
and has an i387 compatible floating point processor.
Status of virtual processor 3 as of: 06/17/2024 10:25:03
on-line since 06/11/2024 14:32:58.
The i386 processor operates at 3093 MHz,
and has an i387 compatible floating point processor.
#CPU和终端设备使用情况(判断CPU的负载情况和使用效率)
xxx:~# iostat –En
tty cpu
tin tout us sy dt id
0 5 0 1 0 99
c.多cpu负载的状态
xxx:~# mpstat
CPU minf mjf xcal intr ithr csw icsw migr smtx srw syscl usr sys wt idl
0 98 0 0 543 175 541 3 74 59 0 277 0 1 0 99
1 110 0 0 434 154 526 4 73 59 0 291 0 1 0 99
2 107 0 0 407 120 522 4 73 56 0 284 0 1 0 99
3 100 0 0 436 152 527 4 72 57 0 276 0 1 0 99
--------------------------------------------------------------------------------------------------------
列信息介绍: CPU : 对应槽位的输出 minf :分钟计数器
mjf : 主时钟 xcal :精确的周期计数
intr :中断数 ithr :线程创建
csw:上下文切换 icsw:进程交换
migr:CPU迁移数 smtx:内存事务
syscl:系统调用 srw:同步读取等待
usr :用户模式消耗CPU百分比
sys :系统模式消耗CPU百分比
wt : 等待I/O消耗CPU百分比
idl : 空闲消耗的百分比
d. 内存大小 (如下为16G)
xxx:~# prtconf | grep 'Memory'
Memory size: 16114 Megabytes
e.显示硬件信息 (处理器、内存、板载设备和可升级插槽的信息)
xxx:~# prtdiag -v
System Configuration: Intel Corporation S1200RP
BIOS Configuration: Intel Corp. S1200RP.86B.02.02.0005.102320140911 10/23/2014
BMC Configuration: IPMI 2.0 (KCS: Keyboard Controller Style)
==== Processor Sockets ====================================
Version Location Tag
-------------------------------- --------------------------
Intel(R) Xeon(R) CPU E3-1220 v3 @ 3.10GHz CPU 1
==== Memory Device Sockets ================================
Type Status Set Device Locator Bank Locator
----------- ------ --- ------------------- ----------------
DDR3 in use 0 ChannelA-DIMM1 BANK 1
unknown empty 0 ChannelA-DIMM2 BANK 0
DDR3 in use 0 ChannelB-DIMM1 BANK 3
unknown empty 0 ChannelB-DIMM2 BANK 2
==== On-Board Devices =====================================
ServerEngines Pilot III
Intel i210
Intel i210
PCH Integrated SATA Controller
==== Upgradeable Slots ====================================
ID Status Type Description
--- --------- ---------------- ----------------------------
7 available PCI Exp. Gen 2 x1 Slot 7
6 available PCI Exp. Gen 2 x16 Slot 6
5 available PCI Exp. Gen 2 x8 Slot 5
4 available PCI Exp. Gen 2 x4 Slot 4
f.查看系统盘出厂时间(列出系统中所有备份元素(BE)的命令)
显示了每个BE的数据集和快照信息,包括它们的状态、挂载点、空间使用情况、策略和创建时间等。
xxx:~# beadm list -a
BE/Dataset/Snapshot Active Mountpoint Space Policy Created
sys
syspool/ROOT/sys NR / 3.81G static 2012-01-01 00:28
sys@factory - - 180M static 2012-01-01 00:31
g.查看系统相关信息
xxxr:~# uname -a
SunOS xxx 5.11 xxx i86pc i386 i86pc
系统内核 主机名 内核发布版和微版本号 系统架构 处理器类型 系统类型/平台
2、运维命令
a. 服务相关
- 查看服务
xxx:~# svcs tomcat
STATE STIME FMRI
online Jun_11 svc:/network/http:tomcat
- 开启服务
xxx:~# svcadm enable tomcat
- 关闭服务
xxx:~# svcadm disable tomcat
- 通过关键字查找服务
xxx:~# svcs | grep tom
online Jun_11 svc:/network/http:tomcat
b.磁盘命令
- 拷贝磁盘
将sda磁盘拷贝到sdc磁盘内
xxx:~# dd if=/dev/sda of=/dev/sdc
# if表示输入文件,of表示输出文件
- 测试磁盘读写速度
写入速度测试:第一个命令用于测试硬盘的写入速度。这个命令从/dev/zero(一个产生无限零的设备)读取数据,并将这些数据写入到/mbapool/heng.txt文件中。块大小设置为1024k字节,计数为10000,意味着总共写入的数据量为1024k*10000=10240MB,即10GB。执行此命令时,系统会输出整个过程所用的时间以及平均写入速度。
读取速度测试:第二个命令用于测试硬盘的读取速度。这里从/mbapool/heng.txt文件读取数据,然后将数据写入到/dev/null(一个丢弃所有输入数据的设备)。块大小设置为64k字节。执行此命令同样会输出整个过程所用的时间以及平均读取速度。
计算读写速度:为了得到读写速度,需要记录每个dd命令的输出中显示的总时间(通常以秒为单位),然后将写入或读取的数据总量(以字节为单位)除以总时间,得到的结果就是平均每秒传输的字节数,即硬盘的读写速度。
dd if=/dev/zero of=/test.txt bs=1024k count=10000
dd if=/test.txt of=/dev/null bs=64k
# bs=1024k 以1M 为单位进行读写
# count =10000 即读写的次数为10000次 为10GB数据
扩展
/dev/zero 的作用:内容全为0
- 清空文件或设备 eg:dd if=/dev/zero of=/path/to/file可以将指定文件清空。cat /dev/null > /path/to/file 清空文件
- 生成随机数据 dd if=/dev/zero bs=1024k count=10000 > random_data.txt 即生成10G 数据的文件
- 测试磁盘性能 如本文介绍
c.网络命令
- 查看网卡名称
查看网卡名称且状态都为开启
xxx:~# dladm show-link
LINK CLASS MTU STATE BRIDGE OVER
igb0 phys 1500 up -- --
igb1 phys 1500 up -- --
- 激活网卡
xxx:~# ifconfig igb0 plumb up 激活网卡
xxx:~# ifconfig igb0 up #开启网卡
- 关闭网卡
xxx:~# ifconfig igb0 unplumb down #卸载网卡,再次激活需重新配置ip地址
xxx:~# ifconfig igb0 down #关闭网卡
- 临时配置网卡
# ifconfig igb0 192.168.1.76 netmask 255.255.255.0 up
- 使用DHCP 分配IP
# ifconfig igb0 dhcp
- 永久配置IP地址
xxx :~# vim /etc/hosts
#在最后添加一行 ip地址 主机名
192.168.1.21 xxx
xxx :~# vim /etc/hostname.igb0 #文件名不一样后缀为网卡名
#在最后一行添加 ip地址 netmask 网络掩码
192.168.1.21 netmask 255.255.255.0
xxx :~# vim /etc/netmasks
#在最后一行添加 ip地址 netmask 网络掩码
192.168.1.21 netmask 255.255.255.0
xxx :~# vim /etc/defaultrouter # 编辑或创建
#设置默认网关
192.168.1.1
xxx :~# vim /etc/resolv.conf
# 设置DNS服务器
domain xxx.local
nameserver 202.99.96.68
xxx :~# cat /etc/nsswitch.conf | grep hosts #编辑使域名解析首先使用本地文件(如下即可)
# "hosts:" and "services:" in this file are used only if the
hosts: files dns
编辑重启机器 #reboot
solaris 11配置网络,适用命令ipadm 和route
确认手动配置模式:
netadm list
netadm enable -p ncp DefaultFixed
创建和管理IP地址:
ipadm create-addr -T static -a <新IP地址>/<子网前缀长度> <接口>/v4命令创建静态IP地址
ipadm create-addr -T static -a 192.168.1.200/24 net0/v4。
配置默认网关:
route -p add default <网关IP>命令设置默认网关
route -p add default 192.168.1.1