Wednesday 8 March 2017

VCAP-DCV :: Configuring ESXi to use central syslog server on CentOS 7

Prepare the CentOS 7 as a syslog server.

0.) SSH to CentOS 7 server and login as a root user.

1.) Open port 514 on CentOS 7.(We will use udp for syslog)

# firewall-cmd --add-port=514/udp
# firewall-cmd --add-port=514/udp --permanent

2.) Edit /etc/rsyslog.conf uncommenting following 2 lines:

# vim /etc/rsyslog.conf

# Provides UDP syslog reception
$ModLoad imudp
$UDPServerRun 514

3.) Restart rsyslogd service

# systemctl restart rsyslogd

4.) SSH to ESXi server with root credentials

5.) Check if syslog is enabled in firewall ruleset

# esxcli network firewall ruleset list | grep syslog

syslog                      false

6.) If syslog is disabled run:

# esxcli network firewall ruleset set --ruleset-id=syslog --enabled=true

# esxcli network firewall refresh

# esxcli network firewall ruleset list | grep syslog
syslog                      true

7.) Configure the central syslog server IP address

esxcli system syslog config set --loghost='udp://172.30.0.40:514'
esxcli system syslog reload

8.) Send the message to the vmkernel log to check if it received by central syslog server:

# esxcli system syslog mark -s "VMware LOG !!"

9.) On CentOS 7 server you can check message log if the message was received.

# tailf /var/log/message

10.) To troubleshoot potential isssue you can use tcpdump tool

On ESXi run : # tcpdump-uw -vv -i vmk0 dst 172.30.0.40

On CentOS 7 run : # tcpdump -n -i eno33557248 port 514

You can monitor if the messages are sent and received.

The end.





Sunday 5 March 2017

VCAP-DCV :: Scratch partition configuration CLI

This procedure describe how to configure the Scratch partition using command line. This is fast and efficient - you need just login via SSH to your ESXi host.

1.) Login over SSH to ESXi host using e.g. Putty client or your terminal

2.) List your datastores 

# ls -l /vmfs/volumes/
total 3853
drwxr-xr-x    2 root     root             2 Jan 25 14:11 261b69b6-ffae9bb2
drwxr-xr-x    1 root     root             8 Jan  1  1970 5702fb79-60862c63-10b0-00505686d3de
drwxr-xr-t    1 root     root          2240 Feb  3 22:00 586410df-c23471a2-3d4a-0050568d2637
drwxr-xr-t    1 root     root          2240 Jan 28 14:29 586ac78b-5cf531fa-ca96-0050568d14b3
drwxr-xr-t    1 root     root          1680 Jan 30 21:35 588fb028-72e8890a-70ec-0050568d14b3
drwxr-xr-x    1 root     root             8 Jan  1  1970 9f691e7f-5aef34de-7c69-e495051b6cfd
lrwxr-xr-x    1 root     root            35 Mar  5 12:18 Datastore -> 588fb028-72e8890a-70ec-0050568d14b3
lrwxr-xr-x    1 root     root            17 Mar  5 12:18 NFS1 -> 261b69b6-ffae9bb2
lrwxr-xr-x    1 root     root            17 Mar  5 12:18 NFS2 -> a0e23f58-ef2c88ee
lrwxr-xr-x    1 root     root            17 Mar  5 12:18 NFS3 -> f4efbfa1-5ca3209a
drwxr-xr-x    4 root     root             9 Jan 26 14:07 a0e23f58-ef2c88ee
drwxr-xr-x    1 root     root             8 Jan  1  1970 bba0137d-45163325-50f6-9fce85fbd663
drwxr-xr-x    8 root     root            10 Jan 30 20:40 f4efbfa1-5ca3209a
lrwxr-xr-x    1 root     root            35 Mar  5 12:18 vmfs_lun01 -> 586410df-c23471a2-3d4a-0050568d2637
lrwxr-xr-x    1 root     root            35 Mar  5 12:18 vmfs_lun02 -> 586ac78b-5cf531fa-ca96-0050568d14b3
drwxr-xr-x    1 root     root           512 Mar  5 12:18 vsan:52825487009e5756-95ec4b21262a513d

lrwxr-xr-x    1 root     root            38 Mar  5 12:18 vsanDatastore -> vsan:52825487009e5756-95ec4b21262a513d

3.) We want to set Scratch partition on vmfs_lun01

# ls -la /vmfs/volumes/vmfs_lun01
lrwxr-xr-x    1 root     root            35 Mar  5 12:22 /vmfs/volumes/vmfs_lun01 -> 586410df-c23471a2-3d4a-0050568d2637

4.) We need to create the .locker directory on the vmfs_lun01

# mkdir /vmfs/volumes/vmfs_lun01/.locker-$(hostname)

5.) Check if the directory was created:

# ls -lad /vmfs/volumes/vmfs_lun01/.locker*
drwxr-xr-x    1 root     root           280 Mar  5 12:28 /vmfs/volumes/vmfs_lun01/.locker-vesxi60-2

6.) Check the current Scratch Partition settings (in this case there is no Scratch partition configured)

[root@vesxi60-2:~] vim-cmd hostsvc/advopt/view ScratchConfig.ConfiguredScratchLocation
(vim.option.OptionValue) [
   (vim.option.OptionValue) {
      key = "ScratchConfig.ConfiguredScratchLocation",
      value = ""
   }
]

7.) Set the new Scratch partition on vmfs_lun01

# /bin/vim-cmd hostsvc/advopt/update ScratchConfig.ConfiguredScratchLocation string /vmfs/volumes/vmfs_lun01/.locker-vesxi60-2

# vim-cmd hostsvc/advopt/view ScratchConfig
(vim.option.OptionValue) [
   (vim.option.OptionValue) {
      key = "ScratchConfig.ConfiguredScratchLocation",
      value = "/vmfs/volumes/586410df-c23471a2-3d4a-0050568d2637/.locker-vesxi60-2"
   }
]

8.) Put host into Maintenance Mode and Reboot

# esxcli system maintenanceMode get
Disabled

# esxcli system maintenanceMode set -e 1

# esxcli system shutdown reboot -r "Scratch partition set"


More methods to set scratch partition you can find in VMware KB :