Linux上安装配置Elasticsearch
1.官网下载好Elasticsearch的包
2.上传Linux服务器,解包到/usr/local/目录下
tar -xf elasticsearch-7.5.1-linux-x86_64.tar.gz -C /usr/local
3.Elasticsearch目录介绍
[root@es elasticsearch-7.5.1]# ls
bin config data jdk lib LICENSE.txt logs modules NOTICE.txt plugins README.textile
[root@es elasticsearch-7.5.1]# pwd
/usr/local/elasticsearch-7.5.1
4.修改elasticsearch.yml核心配置文件
vim elasticsearch.yml
修改内容:
17:cluster.name: "elasticsearch
23:node.name: es-node0
34:path.data: /usr/local/elasticsearch-7.5.1/data
38:path.logs: /usr/local/elasticsearch-7.5.1/data
56:network.host: 0.0.0.0
60:http.port: 9200
73:cluster.initial_master_nodes: ["es-node0"]
注意冒号后面一定要有空格
然后修改 jvm.options 配置文件
把
-Xms1g Xms128m
-Xmx1g修改为 Xms128m
因为是在虚拟机进行安装的ES,所以内存不是很大建议修改一下。若是生产环境不用修改也可。
注意:ES启动不能以ROOT用户来进行,所以需要创建一个用户
创建用户授权:
useradd user-es
chown -R user-es:user-es /usr/local/elasticsearch-7.6.2
切换到user-es 用户进入bin启动elasticsearch
su user-es
cd /usr/local/elasticsearch-7.6.2/bin
./elasticsearch
出现报错信息
ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决办法:
1.在vi /etc/security/limits.conf文件里面加上下面四行
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
2.切换到root用户配置 vi /etc/sysctl.conf文件
里面添加配置 vm.max_map_count=655360
3.执行sysctl -p命令
4.切换用户,重新启动es
搭建完es,最终访问可以出现以下画面,就是搭建的es是成功的
[root@es ~]# curl http://192.168.4.5:9200
{
"name" : "es-node0",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "noSbdzERQbGhI2ysYoI5LA",
"version" : {
"number" : "7.5.1",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "3ae9ac9a93c95bd0cdc054951cf95d88e1e18d96",
"build_date" : "2019-12-16T22:57:37.835892Z",
"build_snapshot" : false,
"lucene_version" : "8.3.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
关闭elasticsearch
可以直接Ctrl+C 因为目前是前台运行的。
让elasticsearch 后台运行,使用如下命令:
./elasticsearch -d 使es后台启动
jps,查看es进程号
kill ‘进程号’ 杀掉es进程
ps -ef | grep elasticsearch 检查es是否运行