September 13, 2016

Cleanly shutdown ESXi 6.0 / 6.5 and Synology NAS with APCUPSD and ESXCLI

I have this working now:

You will need the NAS' to be set to startup on power failure and have wakeonlan enabled.

1. Setup autologins for the root user to:
Generate Key on master - ssh-keygen -t rsa
Access the ESXi Host via SSH
/etc/ssh/keys-root/authorized_keys
Access the Synology NAS via SSH
/root/.ssh/authorized_keys

More info here: Login-to-synology-nas-with-ssh-keys

2. Create a script on the Linux host that:
Gets a list of all "Running VM's"
Creates a script on the ESXHost containing the commands to shutdown the VM's
Execute the ESX Script via SSH
Shutdown the Synology NAS

  VM Shutdown Script

3. Setup APCUPSD to:
Run the script on the local linux host to create the ESX Script
Shutdown the ESX Host via SSH (local VM will shutdown as part of this)

First of all we need a linux host with APCUPSD

Edit /etc/apcupsd/onbattery

Add:

#Shutdown running VM's
/usr/local/bin/ESX-shutdown-running.pl
#Shutdown NAS1
ssh -p 9999 192.168.1.24 shutdown -h
#Shutdown NAS2
ssh -p 9999 192.168.1.14 shutdown -h

Also to get things going again if it comes off battery:

Edit /etc/apcupsd/offbattery

# ssh -p 9999 192.168.1.24 shutdown -h
wakeonlan 00:11:32:39:87:25
# ssh -p 9999 192.168.1.14 shutdown -h
wakeonlan 00:11:32:38:E8:EF
# Reboot ESX Host, for me this is better than just autostarting the shutdown
# VM's as the storage doesnt always reconnect correctly.
ssh 192.168.1.26 reboot


-----------------

Notes..

esxcli --sessionfile /root/esxhost  network ip interface list
esxcli --sessionfile /root/esxhost vm process list

esxcli vm process kill -t [soft,hard,force] -w WorldNumber


September 11, 2016

Installing VMware CLI Tools on Linux

Download the 6.0 CLI tools from:

https://my.vmware.com/web/vmware/details?downloadGroup=VCLI600&productId=491

Download Apache 1.3.0 Source for SOAP

wget https://www.apache.org/dist/etch/1.3.0/apache-etch-1.3.0-src.tar.gz

tar -xvf apache-etch-1.3.0-src.tar.gz

Install the following via CPAN:

SOAP-Lite, Version 1.20 - install PHRED/SOAP-Lite-1.20.tar.gz
ExtUtils::MakeMaker, Version: 6.96 - install BINGOS/ExtUtils-MakeMaker-6.96.tar.gz
Module::Build, Version: 0.4205 - install LEONT/Module-Build-0.4205.tar.gz
Net::FTP, Version: 2.77 - install GBARR/libnet-1.22.tar.gz
LWP, Version: 5.837 - install GAAS/libwww-perl-5.837.tar.gz
LWP::Protocol::https 5.805 or newer - install MSCHILLI/LWP-Protocol-https-6.06.tar.gz
Socket6  0.23 or newer - install UMEMOTO/Socket6-0.28.tar.gz


August 18, 2016

ESXi 6.0 / Synology / iSCSI & NFS Notes

https://miketabor.com/setup-nfs-on-synology-nas-for-vmware-esxi-lab/

https://www.synology.com/en-global/knowledgebase/DSM/tutorial/Virtualization/How_to_set_up_Synology_NAS_as_VMware_server_datastore

https://www.synology.com/en-us/support/download/DS1515+

esxcli software vib install -v /vmfs/volumes/3c3e0416-6b44bd28-1208-001b211b1f56/patch/esx-nfsplugin.vib --no-sig-check

reboot
esxcli software vib list | more


https://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1014165

ESXi 6.0 / Synology / iSCSI & NFS Notes

https://miketabor.com/setup-nfs-on-synology-nas-for-vmware-esxi-lab/

https://www.synology.com/en-global/knowledgebase/DSM/tutorial/Virtualization/How_to_set_up_Synology_NAS_as_VMware_server_datastore

https://www.synology.com/en-us/support/download/DS1515+

esxcli software vib install -v /vmfs/volumes/3c3e0416-6b44bd28-1208-001b211b1f56/patch/esx-nfsplugin.vib --no-sig-check

reboot
esxcli software vib list | more


https://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1014165

ESXi 6 does not mount iSCSI VMFS datastore after reboot

First reboot after upgrading to ESXi6.0 from 5.5 caused my iSCSI datastore to fail.

Storage adapter was still there

The device was still mounted under "Storage"

Errors in the logs showed:

2016-08-17T05:25:54.411Z cpu1:34670 opID=ca3ef949)WARNING: FSAts: 1498: Denying reservation access on an ATS-only vol 'NAS-ESX-VM-DATA'
2016-08-17T05:25:54.411Z cpu1:34670 opID=ca3ef949)WARNING: HBX: 2227: ATS-Only VMFS volume 'NAS-ESX-VM-DATA' is not mounted. This host does not support ATS, or ATS initialization failed.
2016-08-17T05:25:54.411Z cpu1:34670 opID=ca3ef949)WARNING: HBX: 2240: Failed to initialize VMFS distributed locking on volume 577dfaa1-39238aee-2aa5-f46d0475f288: Not supported

After a lot of googling, changing the following advanced settings

DataMover.HardwareAcceleratedMove = 0  
DataMover.HardwareAcceleratedInit = 0
VMFS3.HardwareAcceleratedLocking = 0
and then rebooting the host resolved the issue

May 12, 2016

Azure - Connect ExpressRoute from a different subscription

  1. Login-AzureRmAccount
  2. Select-AzureRmSubscription -SubscriptionId SUB_THAT_HAS_THE_EXPRESSROUTE_CIRCUIT
  3. $circuit = Get-AzureRmExpressRouteCircuit -Name "ExpressRoute-Sydney-ARM-Private" -ResourceGroupName "Azure-rgrp-ProdPrivate"
  4. Add-AzureRmExpressRouteCircuitAuthorization -ExpressRouteCircuit $circuit -Name "ClientConnect-AustraliaEast-Internal-Auth"
  5. Set-AzureRmExpressRouteCircuit -ExpressRouteCircuit $circuit

  1. select-azurermsubscription -SubscriptionId SUB_THAT_WANTS_TO_CONNECT
  2. $id = "/subscriptions/xxxxxxxx-8cd4-40ea-876c-be3bdf0a89af/resourceGroups/Azure-rgrp-ProdPrivate/providers/Microsoft.Network/expressRouteCircuits/ExpressRoute-Sydney-ARM-Private"  
  3. $gw = Get-AzureRmVirtualNetworkGateway -Name "CC-AustraliaEast-Internal-vnetgw" -ResourceGroupName "CC-Prod-Private"
  4. $connection = New-AzureRmVirtualNetworkGatewayConnection -Name "ExpressRoute-Sydney-Connection-CC-AE" -ResourceGroupName "CC-Prod-Private" -Location "AustraliaEast" -VirtualNetworkGateway1 $gw -PeerId $id -ConnectionType ExpressRoute -AuthorizationKey "xxxxxx-92a1-48b4-a520-ea02f8ec2acf"

Installing Powershell for use with Azure


  • Install Powershell Modules Preview from https://www.powershellgallery.com/
  • Run Powershell as Administrator
  • At the powershell command line:

# Install the Azure Resource Manager modules from the PowerShell Gallery
Install-Module AzureRM

# Install the Azure Service Management module from the PowerShell Gallery
Install-Module Azure  

References:

  • https://azure.microsoft.com/en-us/documentation/articles/powershell-install-configure/ 

May 10, 2016

Ripe Atlas Graph

May 02, 2016

Flexget iwth Systemd in Ubuntu 15 & 16

Assumptions:

Config & DB Location: /etc/flexget/
User: debian-deluged
Group: debian-deluged

chown -R debian-deluged:debian-deluged /etc/flexget

nano /etc/systemd/system/flexget.service

[Unit]
Description=Flexget Daemon
After=network.target
[Service]
Type=simple
User=debian-deluged
Group=debian-deluged
UMask=022
WorkingDirectory=/etc/flexget/
ExecStart=/usr/local/bin/flexget --logfile /var/log/flexget.log --loglevel verbose daemon start
ExecStop=/usr/local/bin/flexget daemon stop
Restart=Always
TimeoutStopSec=300
[Install]
WantedBy=multi-user.target

systemctl enable flexget.service
systemctl start flexget

April 26, 2016

Install StartSSL Cert on Postfix

Remove key from key file:

openssl rsa -in xxx-multihost.key -out /etc/ssl/xxx.xxx.xxx/xxx-multihost.key.unencrypted

copy 1_root_bundle from ApacheServer.zip to /etc/ssl/startssl-ca-bundle.pem
copy 2_blah from ApacheServer.zip to /etc/ssl/xxx.xxx.xxx/xxx-multihost.crt

in Main.cf

smtpd_tls_CAfile = /etc/ssl/startssl-ca-bundle.pem
smtpd_tls_cert_file = /etc/ssl/xxx.xxx.xxx/xxx-multihost.crt
smtpd_tls_key_file = /etc/ssl/xxx.xxx.xxx/xxx-multihost.key.unencrypted

restart postfix "service postfix restart"

test using:

http://www.checktls.com/perl/TestReceiver.pl?FULL

Install StartSSL Certificate on Dovecot IMAP Server

wget http://www.startssl.com/certs/sub.class1.server.ca.pem -O sub.class1.server.ca.pem

cat www_certificate.pem sub.class1.server.ca.pem > /etc/ssl/certs/dovecot.pem

cat www_privatekey.pem > /etc/ssl/private/dovecot.pem

chown root:ssl-cert /etc/ssl/private/dovecot.pem

chmod 644 /etc/ssl/private/dovecot.pem

chown root:root /etc/ssl/certs/dovecot.pem

chmod 444 /etc/ssl/certs/dovecot.pem

In /etc/dovecot/conf.d/10-ssl.conf

ssl_cert_file = /etc/ssl/certs/dovecot.pem

ssl_key_file = /etc/ssl/private/dovecot.pem

wget http://www.startssl.com/certs/ca.pem -O /tmp/ca.pem

openssl s_client -CAfile /tmp/ca.pem -connect mail.example.org:993

February 03, 2016

init.d check if mount point exists

# Exit if mount point does not exist
if [ ! -s "/media/media-dupe/freenas" ]; then
  echo "Mount Point not Found"
  exit 0
fi