Ubuntu ElactisSearch 服务搭建
2020-12-10 本文已影响0人
Lrxc
环境
-
linux: ubuntu 18.4
-
elactissearch: 6.5.3
-
jdk: open jdk 1.8
一 服务搭建(压缩包)
-
下载elastic服务端
官网下载地址:https://www.elastic.co/cn/downloads/elasticsearch
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.3.tar.gz tar -xzf elasticsearch-6.5.3.tar.gz cd elasticsearch-6.5.3/
-
启动服务
需要新建一个非root账号,elastic不支持root账号启动(参照后面常见问题2)
./bin/elasticsearch ./bin/elasticsearch -d #后台启动
-
测试成功
curl localhost:9200
二 服务搭建(Docker)
-
下载镜像
docker pull elasticsearch:6.5.3
-
运行容器
docker run -d -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" --name elasticsearch-6.5.3 elasticsearch:6.5.3
-
进入容器
docker exec -it elasticsearch-6.5.3 /bin/bash
-
安装ik分词器
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.5.3/elasticsearch-analysis-ik-6.5.3.zip
-
修改es配置文件:vim ./config/elasticsearch.yml
cluster.name: "docker-cluster" network.host: 0.0.0.0 # minimum_master_nodes need to be explicitly set when bound on a public IP # set to 1 to allow single node clusters # Details: https://github.com/elastic/elasticsearch/pull/17288 discovery.zen.minimum_master_nodes: 1 # just for elasticsearch-head plugin http.cors.enabled: true http.cors.allow-origin: "*"
-
退出容器
exit
-
重启容器
#先停止 docker stop elasticsearch-6.5.3 docker start elasticsearch-6.5.3
二 常见问题
-
默认情况下,Elastic 只允许本机访问,如果需要远程访问,可以修改 Elastic 安装目录的
config/elasticsearch.yml
文件,去掉network.host
的注释,将它的值改成0.0.0.0
,然后重新启动 Elasticnetwork.host: 0.0.0.0 discovery.type: single-node
关闭防火墙!!!
-
不允许root启动
useradd esuser #新建一个用户 passwd esuser #设置密码 su esuser #切换用户 #赋值es文件夹权限 chown -R esuser elasticsearch-6.5.3
-
Native controller process has stopped - no new native processes can be started
-
压缩包形式
# 指定单节点模式 discovery.type: single-node
-
docker形式
-
运行时添加 -e "discovery.type=single-node"
docker run -d -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" --name elasticsearch-6.5.3 elasticsearch:6.5.3
```
-
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
指定单节点模式即可,解决方案同上3
参考:
官方:https://www.elastic.co/guide/en/elasticsearch/reference/current/targz.html