启动elasticsearch
- 下载Elasticsearch
7.17.5
的docker镜像:
docker pull elasticsearch:7.17.5
- 修改虚拟内存区域大小,否则会因为过小而无法启动:
sysctl -w vm.max_map_count=262144
- 使用如下命令启动Elasticsearch服务,内存小的服务器可以通过
ES_JAVA_OPTS
来设置占用内存大小:
docker run -p 9200:9200 -p 9300:9300 --name elasticsearch \
-e "discovery.type=single-node" \
-e "cluster.name=elasticsearch" \
-e "ES_JAVA_OPTS=-Xms512m -Xmx1024m" \
-v /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-v /mydata/elasticsearch/data:/usr/share/elasticsearch/data \
-d elasticsearch:7.17.5
docker run -p 9200:9200 -p 9300:9300 --name es \
-e "discovery.type=single-node" \
-e "cluster.name=elasticsearch" \
-e "ES_JAVA_OPTS=-Xms512m -Xmx1024m" \
-e "ingest.geoip.downloader.enabled=false" \
-v /Users/eternity/tool/elastic/plugins:/usr/share/elasticsearch/plugins \
-v /Users/eternity/tool/elastic/data:/usr/share/elasticsearch/data \
-d elasticsearch:7.17.5
- 启动报错,
"stacktrace": ["org.elasticsearch.ElasticsearchException: not all primary shards of [.geoip_databases] index are active"
,是因为启动时会去更新地图的一些数据库,这里直接禁掉即可,ingest.geoip.downloader.enabled=false`` - 启动时会发现
/usr/share/elasticsearch/data
目录没有访问权限,只需要修改/mydata/elasticsearch/data
目录的权限,再重新启动即可;
chmod 777 /mydata/elasticsearch/data/
-
安装中文分词器IKAnalyzer,注意下载与Elasticsearch对应的版本,下载地址:https://github.com/medcl/elasticsearch-analysis-ik/releases
-
下载完成后解压到Elasticsearch的
/mydata/elasticsearch/plugins
目录下; -
重新启动服务:
docker restart elasticsearch
- 开启防火墙:
firewall-cmd --zone=public --add-port=9200/tcp --permanent
firewall-cmd --reload
- 访问会返回版本信息:http://127.0.0.1:9200
{
"name": "4739231e3c6a",
"cluster_name": "elasticsearch",
"cluster_uuid": "NybOghB6RkW0etsn7WFvRA",
"version": {
"number": "7.17.5",
"build_flavor": "default",
"build_type": "docker",
"build_hash": "8d61b4f7ddf931f219e3745f295ed2bbc50c8e84",
"build_date": "2022-06-23T21:57:28.736740635Z",
"build_snapshot": false,
"lucene_version": "8.11.1",
"minimum_wire_compatibility_version": "6.8.0",
"minimum_index_compatibility_version": "6.0.0-beta1"
},
"tagline": "You Know, for Search"
}
标签:9200,--,data,elasticsearch,docker,安装,name
From: https://www.cnblogs.com/eternityz/p/17040105.html