下载安装,环境配置
因为项目需求将solr替换成es,于是便被逼上一条不归路(刚好用上了mac,mac操作方面也是个新手,所以一起也做了记录)
操作系统: macOS 10.13
JDK版本: jdk 1.8设置jdk环境变量步骤:
1⃣️创建文件:touch .bash_profile
2⃣️打开文件:open -e .bash_profile
3⃣️输入配置:
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home
PATH=$JAVA_HOME/bin:$PATH:.
CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:. export
JAVA_HOME export PATH export CLASSPATH
(关于在macOS系统中配置jdk环境变量具体步骤请参照MAC安装JDK及环境变量配置)
下载Homebrew & Elasticsearch: mac上安装es好像比win更为简单,首先安装一个Homebrew,Homebrew是一个包管理器,安装之后通过brew运行命令即可下载es。
1⃣️打开终端:command+空格 输入ter回车
2⃣️安装Homebrew:/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
3⃣️下载es:brew install elasticsearch
4⃣️启动es: $brew services start elasticsearch
在执行步骤三时发现报了一个错:-bash: brew: command not found 多方查找资料后找到解决办法,执行命令:sudo vim .bash_profile 将刚刚创建的文件中PATH的值修改为“/usr/local/bin:$PATH”,保存退出后输入“source .bash_profile”使配置文件生效,此时再次输入elasticsearch回车,就能看到启动es的日志了!(下载好的elasticsearch在/usr/local/Cellar/目录下,其他路径如下:
elasticsearch: /usr/local/Cellar/elasticsearch/6.4.3
Config: /usr/local/etc/elasticsearch/ )
下载Kibana
Kibana是一个开源的分析与可视化平台,可以用kibana搜索、查看、交互存放在Elasticsearch索引里的数据。同样,使用brew命令下载:
brew install Kibana
下载head
head提供了友好的web界面,实现基本信息的查看和数据的基本检索。
下载插件之前需要先下载一个node,使用brew命令:brew install node 再安装插件
git clone git://github.com/mobz/elasticsearch-head.git下载完成后进入elasticsearch-head目录:
cd elasticsearch-head
npm install
node是npm的一个包安装工具
这个是github上的项目地址,其实是克隆了一个head项目,安装完成后在elasticsearch-head/node_modules目录下会出现grunt文件。
如果没有grunt二进制程序,需要执行
cd elasticsearch-head
npm install grunt --save
执行结束后输入:npm run start 启动成功后访问:http://localhost:9100 就能看到web界面了!但是当前显示是未连接状态,这时候需要修改两个状态,因为es和head插件本身是两个独立的进程,需要进行跨域之间的配置修改:
vim $ ES_HOME$/config/elasticsearch.yml (这里 $ 不需要空格,我是因为这个编辑器不空格会被转译)
添加:
http.cors.enabled: true
http.cors.allow-origin: “*”
然后重启es