Centos安装Elasticsearch环境
晨曦 发布于 阅读:204 Elasticsearch
由于Es是Java写的,安装ES的前提先安装好JDK。
Es环境搭建:
1.下载ES包上传到服务器,下载地址:
https://www.elastic.co/cn/downloads/elasticsearch
2.解压下载的Tar包
[root@chenxi software]# tar -zxvf elasticsearch-7.6.0-linux-x86_64.tar.gz
3.重命名文件夹名称
[root@chenxi software]# mv elasticsearch-7.6.0 elasticsearch
4.进入elasticsearch目录下
[root@chenxi software]# cd elasticsearch
5.根据自身条件调整JVM大小
[root@chenxi elasticsearch]# vim config/jvm.options
Xms 表示总堆空间的初始大小 --默认1G
Xmx 表示总堆空间的最大大小 --默认1G
-Xms1g
-Xmx1g
5.修改elasticsearch.yml配置
[root@chenxi elasticsearch]# vim config/elasticsearch.yml
------------------------------------ Node ------------------------------------
#
Use a descriptive name for the node:
打开注释,节点名称可自己定义,如果是集群部署,则节点名称必须不相同
node.name: node-1
Set the bind address to a specific IP (IPv4 or IPv6):
取消注释,服务器IP地址
network.host: 192.168.0.1
#
Set a custom port for HTTP:
取消注释,Restful 对外接口提供的端口
http.port: 9200
#
For more information, consult the network module documentation.
#
Bootstrap the cluster using an initial set of master-eligible nodes:
取消注释,目前单台机器部署,只需保留node-1节点即可
cluster.initial_master_nodes: ["node-1"]
6.由于elasticsearch安全性问题不能使用root启动,新建用户,并赋予文件夹权限或者启动命令后追加 –allow-root
[root@chenxi elasticsearch]# groupadd esgroup # "eschenxi" (组名)
[root@chenxi elasticsearch]# useradd esuser # "eschenxi" (用户名)
[root@chenxi elasticsearch]# chown -R eschenxi:esgroup /chenxi/software/elasticsearch #"/chenxi/software/elasticsearch" 为安装目录
7.切换用户
[root@chenxi elasticsearch]# su esuser
8.启动ES
[esuser@chenxi elasticsearch]# bin/elasticsearch
保持后台运行增加-d即可
[esuser@chenxi elasticsearch]# bin/elasticsearch -d
查看es日志
[esuser@chenxi elasticsearch]# tail -f logs/elasticsearch.log
注意防火墙开启9200端口
测试Es启动是否正常:
{
"name" : "chenxi",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "na",
"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启动常见问题:http://chenxitag.es.problem.com
ES集群搭建:http://chenxitag.es.cluster.com