ESXI SSH下命令使用(未經整理)

在/sbin下主要有如下的命令
~ # cd /sbin
/sbin # ls esxcfg*
esxcfg-advcfg     esxcfg-init-eesx  esxcfg-nas        esxcfg-swiscsi
esxcfg-dhcp       esxcfg-locker     esxcfg-nics       esxcfg-vmhbadevs
esxcfg-dumppart   esxcfg-loglevel   esxcfg-rescan     esxcfg-vmknic
esxcfg-hwiscsi    esxcfg-module     esxcfg-resgrp     esxcfg-vswitch
esxcfg-info       esxcfg-mpath      esxcfg-route

查看vmknic信息
/sbin # esxcfg-vmknic -l
Interface  Port Group          IP Address      Netmask         Broadcast       MAC Address       MTU     TSO MSS   Enabled 
vmk4       Management Network  192.168.100.120 255.255.255.0   192.168.100.255 00:1e:c9:ff:3c:cd 1500    40960     true    

修改vmknic的IP地址等
/sbin # esxcfg-vmknic -i 192.168.100.120 -n 255.255.255.0 "Management Network"

修改網關
/sbin # esxcfg-route 192.168.100.1

修改馬上生效,不用重啓network


以上各命令均可加-h參數顯示幫助信息,另外說下查看物理網卡信息的命令
/sbin # esxcfg-nics -l
Name    PCI      Driver      Link Speed    Duplex MTU    Description                   
vmnic1  05:00.00 tg3         Down 0Mbps    Half   1500   Broadcom Corporation NetXtreme BCM5721 Gigabit Ethernet
vmnic0  04:00.00 tg3         Up   100Mbps  Full   1500   Broadcom Corporation NetXtreme BCM5721 Gigabit Ethernet

經過以上設置,可以用infrastructure client連接了。


copy以上介紹那篇文章的內容:

  今天安裝了另外一臺esx 3.5 測試,安裝完成後,發覺設置錯了網段,本來想用修改linux網卡Ip的方法操作,後來,上網找了下,有專用的命令可用,很簡單,如下:
列出當前網卡信息
esxcfg-vswif -l
 
刪除原來的配置vswif0, 沒有修改的命令,該文件應該在:/etc/sysconfig/network-scripts/ifcfg-vswif0
esxcfg-vswif -d vswif0
 
新增配置
esxcfg-vswif -a vswif0 -p "Service Console" -i 172.28.2.2 -n 255.255.255.0 -b 172.28.2.255
(也可使用-i命令直接修改,沒測試過)
 
檢查修改後配置是否正確
esxcfg-vswif -l
 
修改原來hosts的IP, 及網關
vi /etc/hosts
vi /etc/sysconfig/network
 
附:vmware esx 上的命令行
http://leesun.blog.51cto.com/58664/60092
esx上特有的命令很多,有些是很方便,就用這個來記錄我平時在esx上用到的命令
1:看你的esx版本。
vmware -v
2:列出esx裏知道的服務
esxcfg-firewall -s
3:查看具體服務的情況
esxcfg-firewall -q sshclinet
4:重新啓動vmware服務
service mgmt-vmware restart
5: 修改root的密碼
passwd root
6:列出你當前的虛擬交換機
esxcfg-vswitch -l
7:查看控制檯的設置
esxcfg-vswif -l
8:列出系統的網卡
esxcfg-nics -l
9:添加一個虛擬交換機,名字叫(internal)連接到兩塊物理網卡,(重新啓動服務,vi就能看見了)
esxcfg-vswitch -a vSwitch1
esxcfg-vswitch -A internal vSwitch1
esxcfg-vswitch -L vmnic1 vSwitch1
esxcfg-vswitch -L vmnic2 vSwitch1
10:刪除交換機,(注意,別把控制檯的交換機也刪了)
esxcfg-vswitch -D vSwitch1
11:刪除交換機上的網卡
esxcfg-vswitch -u vmnic1 vswitch2
12:刪除portgroup
esxcfg-vswitch -D internel vswitch1
13:創建 vmkernel switch ,如果你希望使用vmotion,iscsi的這些功能,你必須創建( 通常是不需要添加網關的)
esxcfg-vswitch -l
esxcfg-vswitch -a vswitch2
esxcfg-vswitch -A "vm kernel" vswitch2
esxcfg-vswitch -L vmnic3 vswitch2
esxcfg-vmknic -a "vm kernel" -i 172.16.1.141 -n 255.255.252.0
esxcfg-route 172.16.0.254
14:打開防火牆ssh端口
esxcfg-firewall -e sshclient
esxcfg-firewall -d sshclient
15: 創建控制檯
esxcfg-vswitch -a vSwitch0
esxcfg-vswitch -A "service console" vSwitch0
esxcfg-vswitch -L vmnic0 vSwitch0
esxcfg-vswif -a vswif0 -p "service console" -i 172.16.1.140 -n 255.255.252.0
16: 添加nas設備(a 添加標籤,-o,是nas服務器的名字或ip,-s 是nas輸入的共享名字)
esxcfg-nas -a isos -o nas.vmwar.cn -s isos
17:列出nas連接
esxcfg-nas -l
18: 強迫esx去連接nas服務器(用esxcfg-nas -l 來看看結果)
esxcfg-nas -r
esxcfg-nas -l
19:連接iscsi 設備(e:enable q:查詢 d:disable s:強迫搜索)
esxcfg-swiscsi -e
20:設置targetip
vmkiscsi-tool -D -a 172.16.1.133 vmhba40
21:列出和target的連接
vmkiscsi-tool -l -T vmhba40
22:列出當前的磁盤
ls -l /vmfs/devices/disks

http://itil.org.cn/thread-1336-1-1.html
There are two ways you can change the IP address: 
From the VI Client
Or, from the Physcial Console Connection
See the following sections for details on each method.

From the VI Client

Using the Virtual Infrastructure Client, the DNS information (Configuration tab > DNS and Routing) can be changed on the fly. Similarly, the gateway address (routing subtab of the DNS and Routing window) and the hostname (DNS Configuration subtab of DNS and Routing) can be changed through the user interface. Hostname and domain changes through the VI Client do not take place until the ESX host is rebooted.

From the Physical Console Connection

Changing the IP for the service console must be done from a physical console connection, either at the host, through a KVM or other remote console connection. If you make changes through a network connection such as SSH, network connectivity to the service console will disconnect because the service console's network interface will change.
For this example, it is assumed that vswif0 is the service console adapter that is the interface to which to apply the IP address change. Running the command 

esxcfg-vswif -i x.x.x.x vswif0 

will set the IP address to the value substituted for x.x.x.x in the command. You will need to edit the /etc/hosts file and change it so that it reflects the new IP address in use for the service console.
The gateway address and hostname are in /etc/sysconfig/network.

After you edit these files, you must reboot the host or restart the network service using the following command:

service network restart 

Note: This command breaks any current network connections to the service console.

You can also dynamically change the host name using the command:

hostname newname

Note: This command creates a temporary host name change. This change is lost when the system is rebooted.

To change the DNS server settings, edit the /etc/resolv.conf file and update the nameserver IPs and search domain if applicable.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章