我的舊mac電腦安裝ElasticSearch的過(guò)程,電腦系統(tǒng)版本是10.13.6 ,僅供參考。
1、安裝方法
Version: 7.17.4版本的elasticsearch
brew install elastic/tap/elasticsearch-full
注意:brew install elasticsearch已棄用
安裝完成后查看版本號(hào):elasticsearch --version
Version: 7.17.4, Build: default/tar/79878662c54c886ae89206c685d9f1051a9d6411/2022-05-18T18:04:20.964345128Z, JVM: 18.0.1.1
2、啟動(dòng)
elasticsearch
3、設(shè)置局域網(wǎng)訪問(wèn)
elasticsearch.yml 配置 局域網(wǎng)可訪問(wèn)
默認(rèn)配置只可本機(jī)訪問(wèn)
cluster.name: my-application
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
discovery.seed_hosts: ["127.0.0.1", "[::1]"]
cluster.initial_master_nodes: ["node-1"]
http.cors.allow-origin: "*"
http.cors.enabled: true
http.cors.allow-headers : X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization
http.cors.allow-credentials: true
注意:修改配置后要重新啟動(dòng)elasticsearch
4、默認(rèn)配置
Data: /usr/local/var/lib/elasticsearch/elasticsearch_charles/
Logs: /usr/local/var/log/elasticsearch/elasticsearch_charles.log
Plugins: /usr/local/var/elasticsearch/plugins/
Config: /usr/local/etc/elasticsearch/
5、安裝elasticsearch-head
github地址:https://github.com/mobz/elasticsearch-head
文檔上有說(shuō)明如何安裝
git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
若電腦尚未安裝node,則需先安裝
https://nodejs.org/en/ 使用brew安裝nodejs出現(xiàn)問(wèn)題,索性去官網(wǎng)下載pkg安裝。
安裝nodejs成功后,安裝所需依賴(lài)庫(kù)
npm install
然后安裝下運(yùn)行所需插件grunt
sudo npm install -g grunt-cli 沒(méi)有加sudo的話報(bào)錯(cuò)了,要加上sudo才行
安裝成功后,運(yùn)行
npm run start
地址欄訪問(wèn)http://localhost:9100/
另外也可以去瀏覽器插件市場(chǎng)找elasticsearch-head安裝擴(kuò)展,就不用安裝elasticsearch-head了。
其他
brew services list # 查看使用brew安裝的服務(wù)列表
brew services run formula|--all # 啟動(dòng)服務(wù)(僅啟動(dòng)不注冊(cè))
brew services start formula|--all # 啟動(dòng)服務(wù),并注冊(cè)
brew services stop formula|--all # 停止服務(wù),并取消注冊(cè)
brew services restart formula|--all # 重啟服務(wù),并注冊(cè)
brew services cleanup # 清除已卸載應(yīng)用的無(wú)用的配置