ES 学习笔记(1-1) 安装
2020-02-16 本文已影响0人
天高s
直接安装
系统: centos7
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.0-linux-x86_64.tar.gz
sha512sum elasticsearch-7.6.0-linux-x86_64.tar.gz
#378322ed2b6782f98e2e22c80e82b1f483bdeb3c28f3f52c897cbd0e8e78848460865c9adedf21e59922aa03ecb28ac44c1fb3dcab4f1904ba58497bc40e1278 elasticsearch-7.6.0-linux-x86_64.tar.gz
cat elasticsearch-7.6.0-linux-x86_64.tar.gz.sha512
#378322ed2b6782f98e2e22c80e82b1f483bdeb3c28f3f52c897cbd0e8e78848460865c9adedf21e59922aa03ecb28ac44c1fb3dcab4f1904ba58497bc40e1278 elasticsearch-7.6.0-linux-x86_64.tar.gz
启动报错
java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:105)
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:172)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:349)
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170)
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161)
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:125)
at org.elasticsearch.cli.Command.main(Command.java:90)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)
For complete error details, refer to the log at /root/es/elasticsearch-7.6.0/logs/elasticsearch.log
创建用户
[root@VM_0_8_centos elasticsearch-7.6.0]# adduser es
[root@VM_0_8_centos elasticsearch-7.6.0]# passwd es
更改用户 es 的密码 。
新的 密码:
无效的密码: 密码少于 7 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@VM_0_8_centos elasticsearch-7.6.0]# passwd es
更改用户 es 的密码 。
新的 密码:
无效的密码: 密码未通过字典检查 - 过于简单化/系统化
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@VM_0_8_centos elasticsearch-7.6.0]# passwd es
更改用户 es 的密码 。
新的 密码:
无效的密码: 密码包含用户名在某些地方
重新输入新的 密码:
抱歉,密码不匹配。
新的 密码:
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
# soCool!!
再启动又报错
ERROR: [2] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
执行
sudo sysctl -w vm.max_map_count=262144
在配置一下这两个就可以正常启动了
discovery.seed_hosts: ["127.0.0.1"]
cluster.initial_master_nodes: ["node-1"]
测试
[es@VM_0_8_centos elasticsearch-7.6.0]$ curl localhost:53200
{
"name" : "VM_0_8_centos",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "sNQeHKoLQu6MB4olvQR2bw",
"version" : {
"number" : "7.6.0",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "7f634e9f44834fbc12724506cc1da681b0c3b1e3",
"build_date" : "2020-02-06T00:09:00.449973Z",
"build_snapshot" : false,
"lucene_version" : "8.4.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
[es@VM_0_8_centos elasticsearch-7.6.0]$ curl localhost:53200/_cat/nodes
10.1.30.0 15 97 8 0.35 0.62 0.54 dilm * VM_0_8_centos
docker 部署
这个就简单了,下面是我本机测试可以跑的配置
version: '2.2'
services:
es01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.0
container_name: es01
environment:
- node.name=es01
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es02,es03
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- data01:/usr/share/elasticsearch/data
ports:
- 9200:9200
networks:
- elastic
es02:
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.0
container_name: es02
environment:
- node.name=es02
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es01,es03
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- data02:/usr/share/elasticsearch/data
networks:
- elastic
es03:
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.0
container_name: es03
links:
- es01
- es02
environment:
- node.name=es03
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es01,es02
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- data03:/usr/share/elasticsearch/data
networks:
- elastic
kibana:
image: kibana:7.6.0
container_name: kibana
depends_on:
- es01
links:
- es01:elasticsearch
ports:
- 5601:5601
networks:
- elastic
cerebro:
image: lmenezes/cerebro:0.8.5
container_name: cerebro
depends_on:
- es01
ports:
- "9000:9000"
command:
-Dhosts.0.host=http://es01:9200
networks:
- elastic
volumes:
data01:
driver: local
data02:
driver: local
data03:
driver: local
networks:
elastic:
driver: bridge
这个适合用于本地学习测试, 访问 http://localhost:9000/
这个就友好多了