在 macOS 上通过 Homwbrew 安装 Elasticsearch 非常简单,首先通过 brew tap 命令关联 Elastic Homebrew 存储库:

1
brew tap elastic/tap

接下来就可以使用 brew install 命令安装最新发布的 Elasticsearch 的默认发行版:

1
brew install elastic/tap/elasticsearch-full

如果你看到类似以下的输出内容,就表示安装成功:

1
Pruned 0 symbolic links and 3 directories from /usr/local

通过 brew 安装的 Elasticsearch,其配置文件,日志和数据目录存储在以下位置:

HOME(主目录),位于 /usr/local/Cellar/elasticsearch-full/7.8.1/

bin (可执行文件所在目录)位于 ll /usr/local/Cellar/elasticsearch-full/7.8.1/bin

config(配置文件)位于 /usr/local/etc/elasticsearch

data(数据存储目录)位于 /usr/local/var/lib/elasticsearch

log(日志文件)位于 /usr/local/var/log/elasticsearch

plugins(插件存放目录)位于 /usr/local/var/elasticsearch/plugins

具体执行输出如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
➜  ~ brew tap elastic/tap
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
act chart-testing dnsprobe golangci-lint kubie never reg termcolor
apidoc chrony dosbox-staging gradle-profiler ldpl ngs rqlite thanos
arb clair duckscript gulp-cli litecli notmuch-mutt scw@1 vgrep
argo cloudformation-cli eksctl hy logcli oci-cli sdns wgcf
argocd coconut fennel jimtcl loki omake simdjson yj
arrayfire colfer folderify jinx lunchy ory-hydra smlpkg z.lua
awsweeper copilot functionalplus jsonnet-bundler lunchy-go osi so
bond cortex gateway-go k9s marked pipgrip solidity
cadence croaring gcc@9 kona naabu promtail standardese
chalk-cli cubejs-cli git-hooks-go ksync nanorc python@3.7 subfinder
==> Updated Formulae
Updated 3971 formulae.
==> Renamed Formulae
elasticsearch@6.8 -> elasticsearch@6 kibana@6.8 -> kibana@6
==> Deleted Formulae
cargo-completion elasticsearch@2.4 i386-elf-grub python tomee-jax-rs
cryptopp elasticsearch@5.6 kibana@5.6 sflowtool

==> Tapping elastic/tap
Cloning into '/usr/local/Homebrew/Library/Taps/elastic/homebrew-tap'...
remote: Enumerating objects: 44, done.
remote: Counting objects: 100% (44/44), done.
remote: Compressing objects: 100% (26/26), done.
remote: Total 530 (delta 28), reused 24 (delta 18), pack-reused 486
Receiving objects: 100% (530/530), 133.37 KiB | 31.00 KiB/s, done.
Resolving deltas: 100% (398/398), done.
Tapped 19 formulae (44 files, 234.2KB).
➜ ~ brew install elastic/tap/elasticsearch-full
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
Updated 8 formulae.

==> Installing elasticsearch-full from elastic/tap
==> Downloading https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.8.1-darwin-x86_64.tar.gz?tap=elastic/homebrew-tap
######################################################################## 100.0%
Warning: tried to install empty array to /usr/local/etc/elasticsearch/jvm.options.d
==> codesign -f -s - /usr/local/Cellar/elasticsearch-full/7.8.1/libexec/modules/x-pack-ml/platform/darwin-x86_64/controller.app --deep
==> find /usr/local/Cellar/elasticsearch-full/7.8.1/libexec/jdk.app/Contents/Home/bin -type f -exec codesign -f -s - {} ;
==> Caveats
Data: /usr/local/var/lib/elasticsearch/elasticsearch_bobotang/
Logs: /usr/local/var/log/elasticsearch/elasticsearch_bobotang.log
Plugins: /usr/local/var/elasticsearch/plugins/
Config: /usr/local/etc/elasticsearch/

To have launchd start elastic/tap/elasticsearch-full now and restart at login:
brew services start elastic/tap/elasticsearch-full
Or, if you don't want/need a background service you can just run:
elasticsearch
==> Summary
🍺 /usr/local/Cellar/elasticsearch-full/7.8.1: 901 files, 473.6MB, built in 15 seconds
==> `brew cleanup` has not been run in 30 days, running now...
Removing: /Users/bobotang/Library/Caches/Homebrew/gettext--0.20.2_1.catalina.bottle.tar.gz... (8.4MB)
Removing: /Users/bobotang/Library/Caches/Homebrew/gnupg--2.2.20.catalina.bottle.tar.gz... (4.3MB)
Removing: /Users/bobotang/Library/Caches/Homebrew/libevent--2.1.11_1.catalina.bottle.tar.gz... (1.2MB)
Removing: /Users/bobotang/Library/Caches/Homebrew/libgcrypt--1.8.5.catalina.bottle.tar.gz... (1MB)
Removing: /Users/bobotang/Library/Caches/Homebrew/redis--6.0.5.catalina.bottle.tar.gz... (1.8MB)
Removing: /Users/bobotang/Library/Caches/Homebrew/unbound--1.10.1.catalina.bottle.tar.gz... (2.5MB)
Removing: /Users/bobotang/Library/Logs/Homebrew/gmp... (64B)
Removing: /Users/bobotang/Library/Logs/Homebrew/pinentry... (64B)
Removing: /Users/bobotang/Library/Logs/Homebrew/libidn2... (64B)
Removing: /Users/bobotang/Library/Logs/Homebrew/libksba... (64B)
Removing: /Users/bobotang/Library/Logs/Homebrew/autojump... (64B)
Removing: /Users/bobotang/Library/Logs/Homebrew/ncurses... (64B)
Removing: /Users/bobotang/Library/Logs/Homebrew/nettle... (64B)
Removing: /Users/bobotang/Library/Logs/Homebrew/libunistring... (64B)
Removing: /Users/bobotang/Library/Logs/Homebrew/utf8proc... (64B)
Removing: /Users/bobotang/Library/Logs/Homebrew/libassuan... (64B)
Removing: /Users/bobotang/Library/Logs/Homebrew/libgpg-error... (64B)
Removing: /Users/bobotang/Library/Logs/Homebrew/libgcrypt... (64B)
Removing: /Users/bobotang/Library/Logs/Homebrew/gettext... (64B)
Removing: /Users/bobotang/Library/Logs/Homebrew/pwgen... (64B)
Removing: /Users/bobotang/Library/Logs/Homebrew/tmux... (64B)
Removing: /Users/bobotang/Library/Logs/Homebrew/libtasn1... (64B)
Removing: /Users/bobotang/Library/Logs/Homebrew/libevent... (64B)
Removing: /Users/bobotang/Library/Logs/Homebrew/openssl@1.1... (64B)
Removing: /Users/bobotang/Library/Logs/Homebrew/unbound... (64B)
Removing: /Users/bobotang/Library/Logs/Homebrew/libusb... (64B)
Removing: /Users/bobotang/Library/Logs/Homebrew/gnupg... (64B)
Removing: /Users/bobotang/Library/Logs/Homebrew/p11-kit... (64B)
Removing: /Users/bobotang/Library/Logs/Homebrew/libffi... (64B)
Removing: /Users/bobotang/Library/Logs/Homebrew/telnet... (64B)
Removing: /Users/bobotang/Library/Logs/Homebrew/gnutls... (64B)
Removing: /Users/bobotang/Library/Logs/Homebrew/npth... (64B)
Removing: /Users/bobotang/Library/Logs/Homebrew/adns... (64B)
Pruned 0 symbolic links and 3 directories from /usr/local
➜ ~

(END)