Vmware: Difference between revisions
Jump to navigation
Jump to search
(→Names) |
|||
(12 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
DCUI Direct Console User Interface | DCUI Direct Console User Interface | ||
drs Distributed Resource Scheduler | drs Distributed Resource Scheduler | ||
fcd First Class Disk (storage life-cycle management on virtual disks as a disk-as-a service) | |||
fsvm vSAN file service Node | fsvm vSAN file service Node | ||
hci hyper-converged infrastructure | hci hyper-converged infrastructure | ||
Line 19: | Line 20: | ||
vim-cmd vmsvc/power.on Start vm. | vim-cmd vmsvc/power.on Start vm. | ||
vim-cmd vmsvc/power.off Stop vm. | vim-cmd vmsvc/power.off Stop vm. | ||
vim-cmd hostsvc/hosthardware Get info about underlying hardware. | grep numCpu (to get number of cpu:s. | |||
vim-cmd vmsvc/destroy 1948 Delete vm | |||
=get info about vim and if it is powered on= | |||
vim-cmd vmsvc/getallvms | grep -v Vmid | while read ID NAME ; do echo $(vim-cmd vmsvc/power.getstate $ID| grep -v ^Retrieved) $NAME ; done | cut -c -180 | |||
==To power on a virtual machine from the command line:== | ==To power on a virtual machine from the command line:== | ||
Line 97: | Line 103: | ||
=list virtual machines= | =list virtual machines= | ||
esxcli vm process list | esxcli vm process list | ||
vim-cmd vmsvc/getallvms | |||
=show ip address of esxi host= | =show ip address of esxi host= | ||
esxcli network ip interface ipv4 get | esxcli network ip interface ipv4 get | ||
Line 170: | Line 178: | ||
=ping= | =ping= | ||
vmkping 172.19.12.13 | vmkping 172.19.12.13 | ||
=vm-support= | |||
Collect logfiles. | |||
=connect to postgres= | |||
psql -d VCDB -U postgres | |||
pg_dump -U postgres VCDB --file=/tmp/postgres_backup | |||
=enable shell= | |||
shell.set --enabled true | |||
=curl= | |||
Function to get command. | |||
curl_vmware_url_username_password(){ | |||
local VMWARE_URL VMWARE_USER VMWARE_PASS | |||
if [ ${#} -lt 3 ]; then | |||
echo "${FUNCNAME} vsphere_url username password." | |||
return 1 | |||
fi | |||
VMWARE_URL="${1}" | |||
VMWARE_USER="${2}" | |||
VMWARE_PASS="${3}" | |||
VMWARE_KEY=$(curl -s -k -X POST https://${VMWARE_URL}/rest/com/vmware/cis/session -u "${VMWARE_USER}:${VMWARE_PASS}" | awk -F \" '{print $4}') | |||
curl -s -k -X GET -H "vmware-api-session-id: ${VMWARE_KEY}" https://${VMWARE_URL}/rest/vcenter/vm | |||
echo -e "\nExample command to use:" | |||
echo "curl -s -k -X GET -H \"vmware-api-session-id: ${VMWARE_KEY}\" https://${VMWARE_URL}/rest/vcenter/vm" | |||
} | |||
Login with cookie | |||
curl -k -b /tmp/cookie-jar.txt https://vsphere.inter.net/api/vcenter/lcm/update/pending | |||
curl -k -i -u 'administrator@vsphere.local:P@ssw0rd' -X POST -c /tmp/cookie-jar.txt https://vsphere.inter.net/rest/com/vmware/cis/session | |||
==Get vm:s== | |||
curl -k -X GET -H "vmware-api-session-id: $ID" https://<VCENTERIP>/rest/vcenter/vm | |||
==Datastores== | |||
curl -k -X GET -H "vmware-api-session-id: $ID" https://<VCENTERIP>/rest/vcenter/datastore | |||
=vmware vsphere commands= | |||
# list the vCenter Server Appliance services: | |||
service-control --list | |||
# start vmware service. | |||
service-control --start wcp | |||
# status of vmware services. | |||
service-control --status | |||
service-control --status | sed -r 's/ +/\n/g' | |||
# envoy listen to web requests. | |||
Config file | |||
# where are request proxied. | |||
root@vsphere [ ~ ]# grep -r "^/sdk " /etc/vmware-rhttpproxy/ | |||
/etc/vmware-rhttpproxy/endpoints.conf.d/vpxd-rhttpproxy-endpoint.conf:/sdk local 8085 redirect allow |
Latest revision as of 15:12, 18 December 2023
Names
DCUI Direct Console User Interface drs Distributed Resource Scheduler fcd First Class Disk (storage life-cycle management on virtual disks as a disk-as-a service) fsvm vSAN file service Node hci hyper-converged infrastructure vCLS vSphere Cluster Services vmk VMkernel port vDFS vSAN Distributed File System vpxa vCenter Server Agent, also referred to as vpxa VSS VMware Distributed Switch VSS VMware Standard Switch
Reload vmx file
vim-cmd vmsvc/reload Vmid
vim-cmd
vim-cmd vmsvc/getallvms Get all vm:s. vim-cmd vmsvc/get.config 1835 Get info about vm. vim-cmd vmsvc/power.on Start vm. vim-cmd vmsvc/power.off Stop vm. vim-cmd hostsvc/hosthardware Get info about underlying hardware. | grep numCpu (to get number of cpu:s. vim-cmd vmsvc/destroy 1948 Delete vm
get info about vim and if it is powered on
vim-cmd vmsvc/getallvms | grep -v Vmid | while read ID NAME ; do echo $(vim-cmd vmsvc/power.getstate $ID| grep -v ^Retrieved) $NAME ; done | cut -c -180
To power on a virtual machine from the command line:
- List the inventory ID of the virtual machine with the command:
vim-cmd vmsvc/getallvms
- Check the power state of the virtual machine with the command:
vim-cmd vmsvc/power.getstate <vmid>
- Power-on the virtual machine with the command:
vim-cmd vmsvc/power.on <vmid>
deploy vmware machine on cli
Look at image.
/vmfs/volumes/datastore1/ipmon_images/vmware-ovftool/ovftool /vmfs/volumes/datastore1/Test_image.ova OVF version: 1.0 VirtualApp: false Name: test Annotation: Test image. Virtual Machine Version: 8 CPU: 4vCPU Memory: 8G HD: 50G [ Optimal Performance = Thick Provision Eager Zeroed ] Download Size: 1.69 GB Deployment Sizes: Flat disks: 50.00 GB Sparse disks: 3.86 GB Networks: Name: vmware Description: vmware description Virtual Machines: Name: Test-SL-6.6-NovAPP Operating System: rhel6_64 Virtual Hardware: Families: vmx-08 Number of CPUs: 4 Cores per socket: 1 Memory: 8.00 GB Disks: Index: 0 Instance ID: 9 Capacity: 50.00 GB Disk Types: SCSI-VirtualSCSI NICs: Adapter Type: VmxNet3 Connection: dvpg-VM Linux-820
Setup machine from image.
/vmfs/volumes/datastore1/vmware-ovftool/ovftool -dm=thick -ds=datastore1 "--net:vmware=VM Network" '/vmfs/volumes/datastore1/ipmon_images/Test_image.ova' 'vi://root:password@localhost' Opening OVA source: /vmfs/volumes/datastore1/Test_image.ova Opening VI target: vi://root@10.151.105.131:443/ Deploying to VI: vi://root@10.151.105.131:443/ Transfer Completed The manifest validates Warning: - No manifest entry found for: 'SL-6.6-NovAPP-05092015-disk1.vmdk'. Completed successfully
which version of esxi
# vmware -vl VMware ESXi 4.1.0 build-260247 VMware ESXi 4.1.0 GA
backup
Backing up a running virtual machine. Run the following command to create a snapshot:
vmware-cmd <path to vmx file> createsnapshot <name of snapshot> <snapshotdescription> 1 1
Run the following command to make a clone:
vmkfstools -i
Run the following command to remove all snapshots:
vmware-cmd <path to vmx file> removesnpshots
Backup the cloned VMDK file using NetBackup.
list virtual machines
esxcli vm process list vim-cmd vmsvc/getallvms
show ip address of esxi host
esxcli network ip interface ipv4 get esxcli network ip interface list esxcfg-nics -l
show routes
esxcli network ip route ipv4 list
create vmdk file that point to flat file.
Rename to flat
mv IPcenter-CIS-SL69-20170801.vmdk IPcenter-CIS-SL69-20170801-flat.vmdk
List size of file.
ls -la -rw------- 1 root root 80530636800 Jan 4 10:22 IPcenter-CIS-SL69-20170801-flat.vmdk
Create think file matching criteria.
vmkfstools -c 80530636800 -a lsilogic -d thin temp.vmdk
Rename file to matching name.
mv temp.vmdk IPcenter-CIS-SL69-20170801.vmdk
Edit file to contain reference to right file and remove thin option.
vim IPcenter-CIS-SL69-20170801.vmdk # Change name to *flat.vmdk file. RW 8388608 VMFS "vmdisk0-flat.vmdk" # Remove this line. ddb.thinProvisioned = "1"
Test that file work.
vmkfstools --fix check /vmfs/volumes/4e0cdac0-bbcd2986-39a2-b8ac6f88f9f9/shehbab.se2.ipsoft.com/IPcenter-CIS-SL69-20170801.vmdk
ssh password less login
esxi -4
/.ssh/authorized_keys
esxi 5+
/etc/ssh/keys-<username>/authorized_keys /etc/ssh/keys-root/authorized_keys
vmdk file not seen when finding uploaded vmdk file
mv machine1.vmdk machine1.vmdk.uploaded vmkfstools -c $(ls -la machine1.vmdk.uploaded | grep size) -d zeroedthick machine1.vmdk mv machine1.vmdk.uploaded machine1.vmdk.uploaded machine1-flat.vmdk
view syslog settings
esxcli system syslog config get
set syslog server
esxcli system syslog config set --loghost=udp://rb-fluentd01.int.redbridge.se:5140
reload config
esxcli system syslog reload
disable firewall
esxcli network firewall set --default-action true
enable firewall
esxcli network firewall set --default-action false
list firewall rules
esxcli network firewall ruleset list
netstat
esxcli network ip connection list
mount
esxcli storage filesystem list
list of the physical drive paths to the controller installed in the system
esxcli storage core path list
list disks
esxcfg-scsidevs -c
read logfiles
ls -alrt /scratch/log/ | tail -20
top
esxtop
vib
List installed vibs.
esxcli software vib list
manage certs
Manage VMware Certificate Store (VECS) instances. Use these commands together with dir-cli and certool to manage your certificate infrastructure.
vecs-cli
vCenter Server Management
https://172.30.32.36:5480/#/ui/summary
arp list
esxcli network ip neighbor list
ping
vmkping 172.19.12.13
vm-support
Collect logfiles.
connect to postgres
psql -d VCDB -U postgres pg_dump -U postgres VCDB --file=/tmp/postgres_backup
enable shell
shell.set --enabled true
curl
Function to get command.
curl_vmware_url_username_password(){ local VMWARE_URL VMWARE_USER VMWARE_PASS if [ ${#} -lt 3 ]; then echo "${FUNCNAME} vsphere_url username password." return 1 fi VMWARE_URL="${1}" VMWARE_USER="${2}" VMWARE_PASS="${3}" VMWARE_KEY=$(curl -s -k -X POST https://${VMWARE_URL}/rest/com/vmware/cis/session -u "${VMWARE_USER}:${VMWARE_PASS}" | awk -F \" '{print $4}') curl -s -k -X GET -H "vmware-api-session-id: ${VMWARE_KEY}" https://${VMWARE_URL}/rest/vcenter/vm echo -e "\nExample command to use:" echo "curl -s -k -X GET -H \"vmware-api-session-id: ${VMWARE_KEY}\" https://${VMWARE_URL}/rest/vcenter/vm" }
Login with cookie
curl -k -b /tmp/cookie-jar.txt https://vsphere.inter.net/api/vcenter/lcm/update/pending curl -k -i -u 'administrator@vsphere.local:P@ssw0rd' -X POST -c /tmp/cookie-jar.txt https://vsphere.inter.net/rest/com/vmware/cis/session
Get vm:s
curl -k -X GET -H "vmware-api-session-id: $ID" https://<VCENTERIP>/rest/vcenter/vm
Datastores
curl -k -X GET -H "vmware-api-session-id: $ID" https://<VCENTERIP>/rest/vcenter/datastore
vmware vsphere commands
# list the vCenter Server Appliance services: service-control --list # start vmware service. service-control --start wcp # status of vmware services. service-control --status service-control --status | sed -r 's/ +/\n/g' # envoy listen to web requests. Config file # where are request proxied. root@vsphere [ ~ ]# grep -r "^/sdk " /etc/vmware-rhttpproxy/ /etc/vmware-rhttpproxy/endpoints.conf.d/vpxd-rhttpproxy-endpoint.conf:/sdk local 8085 redirect allow