Last active
January 13, 2020 17:39
-
-
Save watson/1d1e5755a7878e5754c8430fb8a1ad5d to your computer and use it in GitHub Desktop.
Install and run Elasticsearch in Windows PowerShell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write-Host "Preparing to download and install Elasticsearch..." -ForegroundColor Cyan | |
$esVersion = "6.1.2" | |
$downloadUrl = "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-$($esVersion).zip" | |
$zipPath = "$($env:USERPROFILE)\elasticsearch-$esVersion.zip" | |
$extractRoot = "$env:SYSTEMDRIVE\Elasticsearch" | |
$esRoot = "$extractRoot\elasticsearch-$esVersion" | |
Write-Host "Downloading Elasticsearch..." | |
(New-Object Net.WebClient).DownloadFile($downloadUrl, $zipPath) | |
7z x $zipPath -y -o"$extractRoot" | Out-Null | |
del $zipPath | |
Write-Host "Installing Elasticsearch as a Windows service..." | |
& "$esRoot\bin\elasticsearch-service.bat" install | |
Write-Host "Starting Elasticsearch service..." | |
& "$esRoot\bin\elasticsearch-service.bat" start | |
do { | |
Write-Host "Waiting for Elasticsearch service to bootstrap..." | |
sleep 1 | |
} until(Test-NetConnection localhost -Port 9200 | ? { $_.TcpTestSucceeded } ) | |
Write-Host "Elasticsearch installed" -ForegroundColor Green |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment