目录
1.下载安装包,注意高版本的elasticsearch要求的jdk版本也高,因为它是用java语言写的。
5.浏览器打开http://xx.x.xx.xxx:9200/
1.下载安装包,注意高版本的elasticsearch要求的jdk版本也高,因为它是用java语言写的。
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.6.2.tar.gz
2.解压
3.vi config/elasticsearch.yml
添加以下配置:
xpack.ml.enabled: false
network.host: 0.0.0.0
http.port: 9200
#内存
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
#允许跨域
http.cors.enabled: true
http.cors.allow-origin: "*"
#集群和节点
cluster.name: test-cluster
node.name: master
node.master: true
4.启动 ./elasticsearch
新建es账户
groupadd elasticsearch //新建一个elasticsearch的用户组
useradd -g elasticsearch elasticsearch //在elasticsearch用户组下面建立一个elasticsearch的用户
chown -R elasticsearch:elasticsearch elasticsearch-6.6.2/
su elasticsearch
启动报错信息1: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
root 用户:vi /etc/sysctl.conf 添加 vm.max_map_count=262144:保存退出之后,执行命令 sysctl -p
启动报错信息2:max number of threads is too low
root 用户:vi /etc/security/limits.conf 在文件最后添加
* soft nofile 65536
* hard nofile 65536
* soft nproc 4096
* hard nproc 4096
启动报错信息3: max number of threads [1024] for user [elasticsearch] is too low, increase to at least [4096]
vi /etc/security/limits.d/90-nproc.conf 改为4096
修改完记得退出elasticsearch 用户再进
5.浏览器打开http://xx.x.xx.xxx:9200/
6.后台启动 ./elasticsearch -d
7.head插件的运行需要node环境
https://nodejs.org/dist/v10.15.3/node-v10.15.3-linux-x64.tar.xz
wget https://nodejs.org/dist/v10.15.3/node-v10.15.3-linux-x64.tar.xz //下载
xz -d node-v10.15.3-linux-x64.tar.xz //解压xz格式
tar -xf node-v10.15.3-linux-x64.tar //最终解压
分别给他们设置个软连方便全局使用node和npm命令
ln -sf /home/node-v10.15.3-linux-x64/bin/node /usr/local/bin/
ln -sf /home/node-v10.15.3-linux-x64/bin/npm /usr/local/bin/
8.安装head插件
git clone git://github.com/mobz/elasticsearch-head.git (现在本地用git工具拉下来再上传会快点)
npm install
进入elasticsearch-head文件夹下执行 npm install
报错信息
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! phantomjs-prebuilt@2.1.16 install: `node install.js`
npm ERR! Exit status 1
解决:
1.node_modules目录下已经有的扩展全部删除了
2.执行 npm install phantomjs-prebuilt@2.1.16 --ignore-scripts
安装好以后修改 vi Gruntfile.js
修改监听端口
connect: {
server: {
options: {
port: 9101,
base: '.',
keepalive: true
}
}
}
修改 vi _site/app.js
修改访问端口,这个端口和es的端口一致(如果es的端口也是默认的,这里就不用修改了)
npm run start
报错:
sh: grunt: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! elasticsearch-head@0.0.0 start: `grunt server`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the elasticsearch-head@0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-11-24T10_16_10_606Z-debug.log
解决:
- 安装grunt-cli npm install -g grunt-cli
- npm install (要重新编译一下)
- 编译 npm install grunt --save-dev
- 查看版本 grunt -version
- 如果提示找不到 grunt 命令 vi ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/home/java/bin
PATH=$PATH:$HOME/bin:/home/node-v10.15.3-linux-x64/bin
export PATH
~
添加完以后 source ~/.bash_profile
后台启动head grunt server &
9. IK分词插件的安装
https://github.com/medcl/elasticsearch-analysis-ik
https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.6.2/elasticsearch-analysis-ik-6.6.2.zip
要在es的账户下安装
命令安装 (需要es版本大于5.5.1)
./elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.6.2/elasticsearch-analysis-ik-6.6.2.zip
启动加载: 进入es的plugins目录,创建ik目录,下载ik分词插件,解压将里面的文件复制进ik 文件夹
10.测试 IK分词
1.连接
2.默认的standard
3.ik分词器
11.使用
启动elasticsearch,使用elasticsearch 的账户
启动elasticsearch-header 连接 elasticsearch服务