elasticsearch7.6 安装 并且开启外网访问,真的好累。
下载
下载页面
https://www.elastic.co/cn/downloads/elasticsearch
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.1-linux-x86_64.tar.gz
写在前面 因为es7.6 已经内置了jdk,所以机器不需要有java环境。如果机器有java环境,务必保持和es版本匹配的java环境
es 默认不能已root 用户启动
所以新建 es用户
adduser es
passwd es
把es包移动到es用户的工作目录
mv elasticsearch-7.6.1-linux-x86_64.tar.gz /home/es
切换es 用户
su es
解压
tar -zxvf elasticsearch-7.6.1-linux-x86_64.tar.gz
启动 es
./elasticsearch-7.6.1/bin/elasticsearch
配置外网可访问
vim elasticsearch-7.6.1/config/elasticsearch.yml 修改 # ---------------------------------- Network ----------------------------------- # # Set the bind address to a specific IP (IPv4 or IPv6): # ip 地址填写 ip addr 出现的静态IP network.host: 172.17.0.15 #
重新启动
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
解决
切换到root用户 su root echo "vm.max_map_count=262144" > /etc/sysctl.conf sysctl -p
重新启动
./elasticsearch-7.6.1/bin/elasticsearch
出现错误,要疯了
[1]: 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
解决办法
vim elasticsearch。yml cluster.name: my-es node.name: node-1 cluster.initial_master_nodes: ["node-1"]
重点是 node。name和cluster.initial_master_nodes 要设置
浏览器访问ip:9200
{ "name" : "node-1", "cluster_name" : "my-es", "cluster_uuid" : "hd06lHxERYqnq0hnN7eQSw", "version" : { "number" : "7.6.1", "build_flavor" : "default", "build_type" : "tar", "build_hash" : "aa751e09be0a5072e8570670309b1f12348f023b", "build_date" : "2020-02-29T00:15:25.529771Z", "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" }
公网终于可以了。
安装插件
./elasticsearch-plugin install analysis-icu
访问 ip:9200/_cat/plugins
node-1 analysis-icu 7.6.1
_cat api 提供了一些es 集群信息的接口。可以访问 ip:9200/_cat来获取查看
http://11111:9200/_cat =^.^= /_cat/allocation /_cat/shards /_cat/shards/{index} /_cat/master /_cat/nodes /_cat/tasks /_cat/indices /_cat/indices/{index} /_cat/segments /_cat/segments/{index} /_cat/count /_cat/count/{index} /_cat/recovery /_cat/recovery/{index} /_cat/health /_cat/pending_tasks /_cat/aliases /_cat/aliases/{alias} /_cat/thread_pool /_cat/thread_pool/{thread_pools} /_cat/plugins /_cat/fielddata /_cat/fielddata/{fields} /_cat/nodeattrs /_cat/repositories /_cat/snapshots/{repository} /_cat/templates
一台机器 多节点启动
./elasticsearch-7.6.1/bin/elasticsearch -E node.name=node1 -E cluster.name=es-cluster -E path.data=node1_data -d ./elasticsearch-7.6.1/bin/elasticsearch -E node.name=node2 -E cluster.name=es-cluster -E path.data=node2_data -d ./elasticsearch-7.6.1/bin/elasticsearch -E node.name=node2 -E cluster.name=es-cluster -E path.data=node2_data -d 如果出现 OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c5330000, 986513408, 0) failed; error='Not enough space' (errno=12) at org.elasticsearch.tools.launchers.JvmErgonomics.flagsFinal(JvmErgonomics.java:123) at org.elasticsearch.tools.launchers.JvmErgonomics.finalJvmOptions(JvmErgonomics.java:88) 需要去jvm.options,修改es启动所需要的最大最小堆内存或者增大机器内存