可以从 elastic 的官网 elastic.co/downloads/elasticsearch 获取最新版本的 Elasticsearch。
adduser elasticsearch
passwd elasticsearch
chown -R elasticsearch elasticsearch-7.8.0 给es用户赋权
./elasticsearch -d
http://localhost:9200
问题1:
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
每个进程同时打开文件数太小ulimit -Hn ulimit -Sn 命令查看
修改/etc/security/limits.conf文件,增加配置,用户退出后重新登录生效
soft nofile 65536
hard nofile 65536
问题2:
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
修改/etc/sysctl.conf文件,增加配置vm.max_map_count=262144
vi /etc/sysctl.conf
sysctl -p
1、安装node.js
下载地址:https://nodejs.org/en/download/
tar -xJf node-v10.16.3-linux-x64.tar.xz
vi /etc/profile
export NODE_HOME=/usr/local/node-v10.16.3-linux-x64
export PATH=$NODE_HOME/bin:$PATH
source /etc/profile
2、配置elasticsearch,允许head插件远程访问
cd /opt/es/elasticsearch-7.8.0/config
vi elasticearch.yml
在配置文件末尾添加如下内容,重新启动elasticsearch服务
http.cors.enabled: true
http.cors.allow-origin: "*"
安装grunt
npm install -g grunt
3、启动elastic-search-master
npm install
npm run start
nohup npm run start & # 后端运行
curl -X GET http://localhost:9100/
下载地址:
https://github.com/medcl/elasticsearch-analysis-ik
在plugins下创建文件夹
mkdir ik
解压到plugins/ik中 重启es
curl -X GET -H "Content-Type: application/json" "http://localhost:9200/_analyze?pretty=true" -d'{"text":"中华五千年华夏"}';
效果:
{
"tokens" : [
{
"token" : "中",
"start_offset" : 0,
"end_offset" : 1,
"type" : "" ,
"position" : 0
},
{
"token" : "华",
"start_offset" : 1,
"end_offset" : 2,
"type" : "" ,
"position" : 1
},
{
"token" : "五",
"start_offset" : 2,
"end_offset" : 3,
"type" : "" ,
"position" : 2
},
{
"token" : "千",
"start_offset" : 3,
"end_offset" : 4,
"type" : "" ,
"position" : 3
},
{
"token" : "年",
"start_offset" : 4,
"end_offset" : 5,
"type" : "" ,
"position" : 4
},
{
"token" : "华",
"start_offset" : 5,
"end_offset" : 6,
"type" : "" ,
"position" : 5
},
{
"token" : "夏",
"start_offset" : 6,
"end_offset" : 7,
"type" : "" ,
"position" : 6
}
]
}