一、安装elasticserch
1.elasticsearch的安装直接下载解压,elasticsearch-6.0.1,该版本及以上需要在jdk1.8以上运行
你可以选择在线安装,我是下载解压后上传进行的安装
2.进入elasticsearch-6.0.1/config/ 目录下
vi elasticsearch.yml(es的核心配置文件),
开启network.host: 你的ip http.port: 9200 注意冒号后要有空格,编辑后ctrl+c :wq 保存退出即可
进去elasticsearch-6.0.1的bin目录启动es
提示没有权限,此处没有给用户操作权限,赋权限后也会是查看日志也会是 can not run elasticsearch as root
es高版本,root用户不能直接启动,创建新用户启动es服务,root用户下执行一下操作:
adduser esuser 创建esuser
chown -R esuser /opt/apps/elasticsearch-6.0.1/ 将文件夹权限赋给esuser
chmod 777 /opt/apps/elasticsearch-6.0.1/ 在esuser用户下执行该操作,对该路径下文件权限做变更
chmod a+x * 在esuser用户下执行该操作,使esuser具有执行权限
提示:因为服务器上项目较多,有些项目依赖于jdk7,所以我采用的是指定jdk8方式,当然你也可以采用设置环境变量的方式
cd elasticsearch-6.0.1/config
vi elasticsearch-env
添加jdk8的环境,在调用JAVA_HOME之前添加
现在启动es,浏览器访问!查看进程已经存在
访问成功
二、安装head插件
1.下载head插件,我采用的是解压上传的方式,当然你可以选择在线安装,以下我将head和ik一并下载上传到es目录下
https://github.com/mobz/elasticsearch-head
(在线下载方式:wget https://github.com/mobz/elasticsearch-head/archive/1.x.zip )
2.因为head插件是用node.js开发的所以需要此环境,官网下载
tar -Jvxf node-v8.11.1-linux-x64.tar.xz es目录下执行解压缩,本人下载的是xz格式的
(在线下载方式: wget https://nodejs.org/dist/v8.11.1/node-v8.11.1-linux-x64.tar.xz)
vi /etc/profile 配置环境变量(以下操作在root用户下执行,因为没有给esuser赋其它文件夹操作
权限)
source /etc/profile 执行
3.进入head目录下,执行 npm install ,此过程会下载phantomjs
4.修改head插件配置
修改服务器监听地址:Gruntfile.js (注意true后不要少写“,”)
可在_site/app.js 中配置默认连接ip
6.grunt server & 后台启动head插件 (加&设置为后台启动,不加ctrl+c退出时则关闭)
因为没有设置head插件的默认连接ip,所以为localhost,可以手动修改,也可以修改head插件添加
三、安装ik分词器
方式一:在线安装,复制文件路径,执行elasticsearch-plugin install 路径
在es目录下执行:bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.0.1/elasticsearch-analysis-ik-6.0.1.zip
方式二:下载后安装