ELK学习记录 - Linux elasticsearch 7.9.1安装
说明:以7.9.1版本为例,运行环境 Rocky Linux release 9.3
elasticsearch下载:https://mirrors.huaweicloud.com/elasticsearch/7.9.1/elasticsearch-7.9.1-linux-x86_64.tar.gz
解压:$ tar -xf elasticsearch-7.9.1-linux-x86_64.tar.gz
修改配置文件:
$ cd elasticsearch-7.9.1/ $ vi config/elasticsearch.yml
cluster.name: my-es
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
$ vi config/jvm.options
-Xms128m
-Xmx128m
验证安装成功
#前台运行 ./elk/elasticsearch-7.9.1/bin/elasticsearch #后台运行 $ ./elk/elasticsearch-7.9.1/bin/elasticsearch -d #验证 $ curl http://127.0.0.1:9200 { "name" : "node-1", "cluster_name" : "my-es", "cluster_uuid" : "EJoRMPWrQt-vYB88Xe9h7Q", "version" : { "number" : "7.9.1", "build_flavor" : "default", "build_type" : "tar", "build_hash" : "083627f112ba94dffc1232e8b42b73492789ef91", "build_date" : "2020-09-01T21:22:21.964974Z", "build_snapshot" : false, "lucene_version" : "8.6.2", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" }
常遇问题1:使用自带JDK
备份:bin]$ cp elasticsearch-env elasticsearch-env-bak vi elasticsearch-env # now set the path to java if [ ! -z "$JAVA_HOME" ]; then JAVA="$JAVA_HOME/bin/java" JAVA_TYPE="JAVA_HOME" else if [ "$(uname -s)" = "Darwin" ]; then # macOS has a different structure JAVA="$ES_HOME/jdk.app/Contents/Home/bin/java" else JAVA="$ES_HOME/jdk/bin/java" fi JAVA_TYPE="bundled jdk" fi 改为 # now set the path to java # use the bundled JDK (default) if [ "$(uname -s)" = "Darwin" ]; then # macOS has a different structure JAVA="$ES_HOME/jdk.app/Contents/Home/bin/java" else JAVA="$ES_HOME/jdk/bin/java" fi JAVA_TYPE="bundled JDK"
常遇问题2:启动是报虚拟内存异常使用自带JDK
$ ./bin/elasticsearch [2024-03-24T19:51:16,861][INFO ][o.e.b.BootstrapChecks ] [node-1] bound or publishing to a non-loopback address, enforcing bootstrap checks 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 ERROR: Elasticsearch did not exit normally - check the logs at /usr/dog/elk/elasticsearch-7.9.1/logs/my-es.log [2024-03-24T19:51:16,869][INFO ][o.e.n.Node ] [node-1] stopping ... [2024-03-24T19:51:16,881][INFO ][o.e.n.Node ] [node-1] stopped [2024-03-24T19:51:16,882][INFO ][o.e.n.Node ] [node-1] closing ... [2024-03-24T19:51:16,902][INFO ][o.e.n.Node ] [node-1] closed [2024-03-24T19:51:16,904][INFO ][o.e.x.m.p.NativeController] [node-1] Native controller process has stopped - no new native processes can be started #使用root修改主机虚拟内存最大映射数 # vi /etc/sysctl.conf # 增加如下配置 vm.max_map_count = 262144 # 重新加载配置/etc/sysctl.conf # sysctl -p