Linux centos7 以tar包方式安装elasticsearch 7.8
Linux centos7 以tar包方式安装elasticsearch 7.8
1. 官网下载 elasticsearch https://www.elastic.co/cn/downloads/elasticsearch
我下载的是最新稳定版本7.0.0 wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-linux-x86_64.tar.gz
2. 解压文件, 拷贝到安装目录 tar -xzvf elasticsearch 解压缩,并将解压缩的文件剪切到/usr/local/目录下 3. 进入config文件夹下编辑elasticsearch.yml 集群模式下,放开cluster.name注释,单机模式下,放开node.name 数据存储和日志存储路径放开注释 网络设置 设置ip限制,端口设置,跨越设置i 4. 配置完成后进入bin目录执行启动脚本elasticsearch 前台启动 ./elasticsearch 后台启动 ./elasticsearch -d
5. 启动过程中遇到的坑 1) root启动时,elasticsearch不能以root用户启动 org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root 处理方法,创建非root用户,使用非root用户启动 a) adduser es 创建用户es b) passwd es 设置es密码, c) 设置文件权限 chown -R es /opt/supp_app/elasticsearch-6.4.0 d) visudo.设置用户对命令的执行权限 配置同root
2) JDK版本要求最低版本1.8,在elasticsearch中设置JAVA_HOME CATALINA_HOME和PATH等信息
3) elasticsearch.yml配置有问题,保证配置的文件的key后面直接跟着冒号,冒号后空格一位,再输入对应的value 4) elasticsearch用户拥有的可创建文件描述的权限太低,至少需要65536, 处理办法: #切换到root用户修改 vim /etc/security/limits.conf # 在最后面追加下面内容 *** hard nofile 65536 *** soft nofile 65536 #*** 是启动ES的用户 5) max_map_count文件包含限制一个进程可以拥有的VMA(虚拟内存区域)的数量 处理办法: #切换到root用户修改 vim /etc/sysctl.conf # 在最后面追加下面内容 vm.max_map_count=262144 执行 sysctl -p
五、 启动ES
[root@localhost bin]# ./elasticsearchfuture versions of Elasticsearch will require Java 11; your Java version from [/usr/local/java/jdk1.8.0_201/jre] does not meet this requirement[2019-07-11T22:47:02,963][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [node-1] uncaught exception in thread [main]org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-7.2.0.jar:7.2.0] at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-7.2.0.jar:7.2.0] at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.2.0.jar:7.2.0] at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-7.2.0.jar:7.2.0] at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.2.0.jar:7.2.0] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.2.0.jar:7.2.0] at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.2.0.jar:7.2.0]Caused by: java.lang.RuntimeException: can not run elasticsearch as root at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:105) ~[elasticsearch-7.2.0.jar:7.2.0] at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:172) ~[elasticsearch-7.2.0.jar:7.2.0] at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:349) ~[elasticsearch-7.2.0.jar:7.2.0] at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-7.2.0.jar:7.2.0] ... 6 more
创建一个esroot用户并设置初始密码useradd -c 'ES user' -d /home/esroot esrootpasswd esroot将es安装目录属主权限改为esroot用户chown -R esroot <es安装目录>切换用户到esrootsu esroot
ERROR: [2] bootstrap checks failed[1]: initial heap size [268435456] not equal to maximum heap size [524288000]; this can cause resize pauses and prevents mlockall from locking the entire heap[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
查看vm.max_map_count属性值,如果没有添加则在/etc/sysctl.conf文件添加vm.max_map_count = 262144grep vm.max_map_count /etc/sysctl.conf或者执行添加临时变量sysctl -w vm.max_map_count=262144 六、 再次启动ES,然后测试一下,访问http://localhost:9200/ [root@localhost ~]# ./elasticsearch[root@localhost ~]# curl http://localhost:9200/{ "name" : "node-1", "cluster_name" : "my-application", "cluster_uuid" : "QqRQ8cMCTAexMVKTTY4PpA", "version" : { "number" : "7.2.0", "build_flavor" : "default", "build_type" : "tar", "build_hash" : "508c38a", "build_date" : "2019-06-20T15:54:18.811730Z", "build_snapshot" : false, "lucene_version" : "8.0.0", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search"} 后台启动方式加-d,如:./elasticsearch -d 七、 祝学习愉快! 作者:单名一个冲 链接:https://www.jianshu.com/p/2071ddf57996 来源:简书 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。 |