Uninstall elasticsearch from /usr/local/var and install another version on MacOSX - elasticsearch

I was trying to downgrade elasticsearch from 6.8.4 to 5.6 on my Mac machine. But somehow I mess with the existing installation of 6.8.4 and now neither I am able to fix the current installed version nor I am able to install 5.6
Details:
I had 6.8.4 installed correctly on my system and I was successfully able to hit http://localhost:9200/ port and see the version info and every other details. But due to a dependency, I had to downgrade the version to 5.6
I followed this guide https://gist.github.com/govindpatel/0660b33a343b807664972b53c3b12ca0 and messed with the installation of 6.8.4 by removing plist entry and other details. Now when I try to start elasticsearch service by typing $ elasticsearch I get: -bash: elasticsearch: command not found and $ brew service restart elasticsearch gives me Error: Unknown command: service
However, I can still see 6.8.4 when I fire this command:
$ brew info elasticsearch
elasticsearch: stable 6.8.4, HEAD
Distributed search & analytics engine
https://www.elastic.co/products/elasticsearch
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/elasticsearch.rb
==> Requirements
Required: java = 1.8 ✔
==> Options
--HEAD
Install HEAD version
==> Caveats
Data: /usr/local/var/lib/elasticsearch/
Logs: /usr/local/var/log/elasticsearch/elasticsearch_Puneet.log
Plugins: /usr/local/var/elasticsearch/plugins/
Config: /usr/local/etc/elasticsearch/
To have launchd start elasticsearch now and restart at login:
brew services start elasticsearch
Or, if you don't want/need a background service you can just run:
elasticsearch
==> Analytics
install: 8,690 (30 days), 23,748 (90 days), 122,267 (365 days)
install_on_request: 8,233 (30 days), 22,565 (90 days), 114,157 (365 days)
build_error: 0 (30 days)
I've even tried installing 5.6 (via Homebrew) - brew install elasticsearch#5.6 and set the PATH at first place in ~/.bash_profile but no luck! :(
Please help and advise on:
How can I fix the existing 6.8.4 version, and
How can I downgrade it systematically (because existing conf, data lies under /usr/local folder)
Current details: to see if elasticsearch is running: $ launchctl list | grep elasticsearch, I am getting: - 1 homebrew.mxcl.elasticsearch#5.6 and I do not have this currently installed (o/p attached) - $ brew uninstall elasticsearch#5.6 ~> Error: No such keg: /usr/local/Cellar/elasticsearch#5.6
[UPDATE-1]
After posting this, I tried running the ES installation command again: brew install elasticsearch
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core and homebrew/cask).
No changes to formulae.
==> Downloading
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-oss-6.8.4.tar.gz
Already downloaded: /Library/Caches/Homebrew/downloads/elasticsearch-oss-6.8.4.tar.gz
==> Caveats
Data: /usr/local/var/lib/elasticsearch/
Logs: /usr/local/var/log/elasticsearch/elasticsearch_Puneet.log
Plugins: /usr/local/var/elasticsearch/plugins/
Config: /usr/local/etc/elasticsearch/
To have launchd start elasticsearch now and restart at login:
brew services start elasticsearch
Or, if you don't want/need a background service you can just run:
elasticsearch
==> Summary
🍺 /usr/local/Cellar/elasticsearch/6.8.4: 133 files, 103.2MB, built in 6 seconds
and then started the service $ brew services start elasticsearch ~> ==> Successfully startedelasticsearch(label: homebrew.mxcl.elasticsearch). Now when I tried accessing the port: http://localhost:9200 -- it's working (install from 0 fixed this though!)
{
"name" : "DwQRyf7",
"cluster_name" : "elasticsearch_Puneet",
"cluster_uuid" : "hLAu9onQSiuQHOpm_e9IKw",
"version" : {
"number" : "6.8.4",
"build_flavor" : "oss",
"build_type" : "tar",
"build_hash" : "bca0c8d",
"build_date" : "2019-10-16T06:19:49.319352Z",
"build_snapshot" : false,
"lucene_version" : "7.7.2",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
The only question remains now is, how can I downgrade it systematically?
[UPDATE-2]
Now that I have 6.8.4 with me, I've checked for other versions with: brew search elasticsearch and got 5.6. Then I installed 5.6 with brew install elasticsearch#5.6
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).
No changes to formulae.
==> Downloading https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.16.tar.gz
Already downloaded: /Library/Caches/Homebrew/downloads/3d7cc028f605699065bd403b0a2383db8d7413c570df57e26fc87a735126c96c--elasticsearch-5.6.16.tar.gz
==> Caveats
Data: /usr/local/var/elasticsearch/elasticsearch_Puneet/
Logs: /usr/local/var/log/elasticsearch/elasticsearch_Puneet.log
Plugins: /usr/local/opt/elasticsearch#5.6/libexec/plugins/
Config: /usr/local/etc/elasticsearch/
plugin script: /usr/local/opt/elasticsearch#5.6/libexec/bin/elasticsearch-plugin
elasticsearch#5.6 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have elasticsearch#5.6 first in your PATH run:
echo 'export PATH="/usr/local/opt/elasticsearch#5.6/bin:$PATH"' >> ~/.bash_profile
To have launchd start elasticsearch#5.6 now and restart at login:
brew services start elasticsearch#5.6
Or, if you don't want/need a background service you can just run:
/usr/local/opt/elasticsearch#5.6/bin/elasticsearch
==> Summary
🍺 /usr/local/Cellar/elasticsearch#5.6/5.6.16: 106 files, 36.0MB, built in 6 seconds
Then I added 5.6 to $PATH. Now, when I am trying to switch elasticsearch version using brew switch elasticsearch 5.6 I am getting:
Error: elasticsearch does not have a version "5.6" in the Cellar.
elasticsearch installed versions: 6.8.4
Any idea what I am missing here?

Looks like I found the solution after troubleshooting for a while.
In order to maintain multiple versions of elasticsearch on your development machine, here's what you need to do:
Let's say I have 6.8.4 installed and I want another version as well. In order to maintain both, first check what all versions your system (mac) has by typing: brew search elasticsearch and my system have 3 versions supported for ES:
elasticsearch - Latest and stable (already installed)
elasticsearch#2.4
elasticsearch#5.6
In order to have 2.4, here's what you'll have to do:
$ brew install elasticsearch#2.4
# After installation type:
$ brew services stop elasticsearch
# above command will stop elasticsearch (lastest stable) service
# add 2.4 to $PATH
$ echo 'export PATH="/usr/local/opt/elasticsearch#2.4/bin:$PATH"' >> ~/.bash_profile
# start the service of 2.4
$ brew services start elasticsearch#2.4
# check for the service/installation
$ launchctl list | grep elasticsearch
# above command should show you a port
Now you can hit http://localhost:9200 in browser and it should show you 2.4
To switch back to latest stable version:
$ brew services stop elasticsearch
# remove entry from $PATH variable
$ brew services start elasticsearch
It seems to me that brew switch elasticsearch [VERSION] does not work

Related

How can I install brew httpd on MacOS 11 Big Sur?

I've upgraded macOS version to 11 Big Sur and unable to use brew's apache instead of build in version.
What I did:
sudo apachectl stop
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
brew intall httpd
When I'm trying to start the installed httpd it says that apache is started
==> Successfully started httpd (label: homebrew.mxcl.httpd)
but when I run brew services command I see that httpd is not started (and http://localhost:8080 is not working).
sergeylyskov#MacBook-Pro-Sergey ~ % brew services
Name Status User Plist
httpd error sergeylyskov /Users/sergeylyskov/Library/LaunchAgents/homebrew.mxcl.httpd.plist
php#7.3 stopped
php#7.4 stopped
postgresql#12 stopped
P.S. I want to use brew's version because seems like build in apache is not properly work with php modules (it don't show xdebug and imagick extensions in phpinfo())
Any advice?
I tried uninstalling and then reinstalling httpd, but that didn't work initially. When you uninstall, brew does NOT remove the /usr/local/etc/httpd config directory (which is sensible because you might have a lot of things configured in there and not backed up). However, these configuration files might well be outdated (or customized) in a way that makes them incompatible with the latest version of httpd, causing it to fail. So I did the following:
brew services stop httpd
brew uninstall httpd
mv /usr/local/etc/httpd /usr/local/etc/httpd-old
brew install httpd
brew services start httpd
This got it running again with fresh config files; I can now copy over any specific configuration details from httpd-old into the new httpd dir.
Also note: by default, httpd serves from /usr/local/var/www. This dir is not affected by the uninstall-reinstall process, so only your config files need re-doing.

How to upgrade elastic stack in mac osx from 6.8.7 to 7.x (latest)

I followed the elastic search doc for rolling upgrade in mac osx, Link
After taking snapshot and disabling the services, on upgrade using brew
I am getting: Warning: elasticsearch 6.8.7 already installed when doing brew upgrade elasticsearch.
brew tap elastic/tap and. brew install elastic/tap/elasticsearch-full is showing
elastic/tap/elasticsearch-full because conflicting formulae are installed.
elasticsearch
Is brew unlink elasticsearch a safe practice to do?
Manual Download: I downloaded the elasticsearch 7.6 as tar file.
$ brew info elasticsearch
Data: /usr/local/var/lib/elasticsearch/
Logs: /usr/local/var/log/elasticsearch/elasticsearch_user.log
Plugins: /usr/local/var/elasticsearch/plugins/
Config: /usr/local/etc/elasticsearch/
where should I install the downloaded elasticsearch tar file and how can I restore my previous data?
Took snapshot,

kubectl kudo plugin not working after install using brew in linux?

I have installed the kudo plugin on my Linux machine following the instructions in the Kudo CLI page using brew. But it throws error on execution,
user#factotum:~$ kubectl kudo
Error: unknown command "kudo" for "kubectl"
Run 'kubectl --help' for usage.
I tried to list the available plugins, but doesn't have any,
user#factotum:~$ kubectl plugin list
error: unable to find any kubectl plugins
Just installed to reproduce and seems works fine. Have you init it with kubectl kudo init as it mentioned in Install KUDO into your cluster?
My steps(Ubuntu 16.04, 4.15.0-1033-gcp):
$sudo apt install linuxbrew-wrapper
$brew update
$brew vendor-install ruby
$brew update
==> Migrating from Linuxbrew/brew to Homebrew/brew
Linuxbrew/brew has been merged into Homebrew/brew!
Linuxbrew/brew will no longer be updated.
Your git remote has been changed from
https://github.com/Linuxbrew/brew.git
to https://github.com/Homebrew/brew
See the blog post at https://brew.sh/2019/02/02/homebrew-2.0.0/
Already up-to-date.
$brew tap kudobuilder/tap
brew install kudo-cli
==> Downloading https://linuxbrew.bintray.com/bottles-portable-ruby/portable-ruby-2.6.3.x86_64_linux.bottle.tar.gz
######################################################################## 100.0%
....
....
....
....
🍺 /home/bla/.linuxbrew/Cellar/kudo-cli/0.10.1: 5 files, 38.2MB, built in 6 seconds
==> `brew cleanup` has not been run in 30 days, running now...
==> Caveats
==> kubernetes-cli
Bash completion has been installed to:
/home/bla/.linuxbrew/etc/bash_completion.d
$ kubectl kudo init
$KUDO_HOME has been configured at /home/bla/.kudo
✅ installed crds
✅ installed service accounts and other requirements for controller to run
✅ installed kudo controller
Test:
$ kubectl kudo get instances
List of current installed instances in namespace "default":
.
$ kubectl kudo install redis
operator.kudo.dev/v1beta1/redis created
operatorversion.kudo.dev/v1beta1/redis-0.2.0 created
instance.kudo.dev/v1beta1/redis-instance created
$ kubectl plugin list
The following compatible plugins are available:
/home/bla/.linuxbrew/bin/kubectl-kudo
Hope it helps
Can you execute kubectl-kudo? A kubectl plugin is basically just a binary that starts with kubectl-.
So, check where brew installed the kudo binary and check your $PATH.
And you can use kubectl-kudo instead of kubectl kudo if the plugin mechanism doesn't work for some reason.
Did you remember to add the brew environment variables to your shell?
As pr https://brew.sh/ and their install-script https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh you need to add brew to your PATH among others.
OP is tagging bash here so adding this to your shell configuration file.
There will be slight variations based on what shell the user is running, bash, ksh, csh, tcsh.
# At the bottom of .bashrc or .bash_profile
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"

Fixing homebrew on Mac OSX 10.13.2

Just wondering if anyone can help fix homebrew for me. It was working a minute ago...
I am trying to install new packages using Homebrew on my 2 Macbooks. Both are running High Sierra, which I suspect might be the problem due to Apple borking root permissions...
Anyway, my issue goes a little something like this:
❯❯❯ brew install git
Error: git 2.14.2 is already installed
To upgrade to 2.15.1, run `brew upgrade git`
Okay. Lets upgrade Git.
❯❯❯ brew upgrade git
==> Upgrading 1 outdated package, with result:
git 2.15.1
==> Upgrading git
==> Downloading https://homebrew.bintray.com/bottles/git-2.15.1.high_sierra.bottle.tar.gz
Error: curl is not executable
Warning: Bottle installation failed: building from source.
==> Downloading https://www.kernel.org/pub/software/scm/git/git-2.15.1.tar.xz
Error: curl is not executable
Strange. I use curl daily...
❯❯❯ curl
curl: try 'curl --help' or 'curl --manual' for more information
❯❯❯ which curl
/usr/bin/curl
❯❯❯ ls -al /usr/bin/curl
-rwxr-xr-x 1 root wheel 185104 Dec 1 15:45 /usr/bin/curl
So it exists and looks executable. Maybe the homebrew links got messed up? I will re-install curl using brew
❯❯❯ brew install curl
==> Downloading https://homebrew.bintray.com/bottles/curl-7.57.0.high_sierra.bottle.tar.gz
Error: curl is not executable
Warning: Bottle installation failed: building from source.
==> Downloading https://curl.haxx.se/download/curl-7.57.0.tar.bz2
Error: curl is not executable
So basically homebrew is not working for me. On TWO different machines running the same Mac OS version 10.13.2
NOTE: This is not limited in any way to installing git. The problem started trying to install minikube.
UPDATE
I checked my setup via brew config and noticed that although I DO have curl installed, homebrew does not see it: Curl: N/A
HOMEBREW_VERSION: 1.4.1
ORIGIN: https://github.com/Homebrew/brew
HEAD: b4d43e950fd45c24e48d6ebfd3013357abcd21a9
Last commit: 10 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 809322678d0fb7ab034348f86f0e452eff203b49
Core tap last commit: 73 minutes ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_VISUAL: nano
CPU: octa-core 64-bit haswell
Homebrew Ruby: 2.3.3 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/bin/ruby
Clang: 9.0 build 900
Git: 2.14.3 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: N/A
Perl: /usr/bin/perl
Python: /usr/local/opt/python/libexec/bin/python => /usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Ruby: /usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Java: 1.8.0_31
macOS: 10.13.2-x86_64
Xcode: 9.2
CLT: 9.2.0.0.1.1510905681
X11: 2.7.9 => /opt/X11
The OS already has curl installed, but homebrew does not see it.
I cannot install curl using homebrew (see above).
So now the problem becomes "How do I fix homebrew so it sees curl"?
I was running into the same issue yesterday. For me it was caused by a file called curl left over from a botched command in the same directory where I was running brew. Deleting that file resolved the issue.
I had same problem and I have no idea how but I fixed it. First I uninstalled any brew-version of curl that was installed. Then, when that didn't work, I navigated to \bin\usr\curl to make sure it was still there. I then ran curl in terminal (just literally `curl' and then which curl to make sure it was using right one), and then reran brew and it seemed to work. I think what happens is that for some reason in new Mac files sometimes don't appear locally until you open them for the first time when using iCloud. Its happened before with other dependencies, where I had to navigate to file and physically open it before it would be locally downloaded and be recognized as a dependency. Not sure if Mac does same thing with curl. If so, quite dumb.
I had this same issue, also on Mac OS High Sierra. I ended up running brew uninstall curl. This gave me an error, but then when I installed Homebrew curl again, it worked and I could install git and others.
if you have tried everything and nothing helps, if you're facing permissions issues - try to re-install the Homebrew:
uninstall:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
and then install it again:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
helped in my case

How to start Grafana on Mac?

I installed Grafana via brew:
brew install grafana
It seems that location of installation is here:
/usr/local/Cellar/grafana/4.3.2
How to start Graphana service now?
'service' command does not exist on Mac.
Tried with:
brew services start grafana
and got following error:
==> Tapping homebrew/services
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'...
fatal: unable to access 'https://github.com/Homebrew/homebrew-services/': The requested URL returned error: 403
Error: Failure while executing: git clone https://github.com/Homebrew/homebrew-services /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services --depth=1
Error: Failure while executing: /usr/local/bin/brew tap homebrew/services
What is the proper way to start Grafana on Mac?
Install grafana on Mac with Brew.
Install and download Docker from this link - https://docs.docker.com/v17.12/docker-for-mac/install/#download-docker-for-mac.
You can launch the your terminal.
Install latest stable:
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
$ brew install grafana
$ brew update
$ brew install grafana
To start Grafana using homebrew services first make sure homebrew/services is installed.
$ brew tap homebrew/services
Then start Grafana using:
$ brew services start grafana
Default login and password admin/ admin - http://localhost:3000
I think you might need to install Homebrew services:
brew tap homebrew/services
Otherwise the executable can be run directly at:
/usr/local/Cellar/grafana/4.3.2/bin/grafana-server

Resources