Ubuntu系统下安装elasticsearch

Ubuntu系统下安装elasticsearch

elasticsearch 运行需要至少jdk1.8以上。

1.下载安装elasticsearch

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.1.tar.gz

tar -zxvf elasticsearch-6.2.1.tar.gz
mv elasticsearch-6.2.1 /usr/local  #移动 需要root

2.修改配置文件

2.1.elasticsearch.yml

cluster.name: xuecheng
node.name: xc_node_1
network.host: 0.0.0.0
http.port: 9200
transport.tcp.port: 9300
node.master: true
node.data: true
discovery.zen.ping.unicast.hosts: ["0.0.0.0:9300", "0.0.0.0:9301"]
discovery.zen.minimum_master_nodes: 1
node.ingest: true
bootstrap.memory_lock: false
bootstrap.system_call_filter: false #注意
node.max_local_storage_nodes: 2

path.data:  /usr/local/elasticsearch-6.2.1/data
path.logs: /usr/local/elasticsearch-6.2.1/logs

http.cors.enabled: true
http.cors.allow-origin: /.*/

常用的配置项如下:
cluster.name: 配置elasticsearch的集群名称,默认是elasticsearch。建议修改成一个有意义的名称。
node.name:节点名,通常一台物理服务器就是一个节点,es会默认随机指定一个名字,建议指定一个有意义的名称,方便管 理一个或多个节点组成一个cluster集群,集群是一个逻辑的概念,节点是物理概念.
path.conf: 设置配置文件的存储路径,tar或zip包安装默认在es根目录下的config文件夹,rpm安装默认在/etc/ elasticsearch path.data: 设置索引数据的存储路径,默认是es根目录下的data文件夹,可以设置多个存储路径, 用逗号隔开。
path.logs: 设置日志文件的存储路径,默认是es根目录下的logs文件夹
path.plugins: 设置插件的存 放路径,默认是es根目录下的plugins文件夹
bootstrap.memory_lock: true 设置为true可以锁住ES使用的内存,避免内存与swap分区交换数据。
network.host: 设置绑定主机的ip地址,设置为0.0.0.0表示绑定任何ip,允许外网访问,生产环境建议设置为具体 的ip。 http.port: 9200 设置对外服务的http端口,默认为9200。
transport.tcp.port: 9300 集群结点之间通信端口
node.master: 指定该节点是否有资格被选举成为master结点,默认是true,如果原来的master宕机会重新选举新 的master。
node.data: 指定该节点是否存储索引数据,默认为true。
discovery.zen.ping.unicast.hosts: [“host1:port”, “host2:port”, “…”] 设置集群中master节点的初始列表。
discovery.zen.ping.timeout: 3s 设置ES自动发现节点连接超时的时间,默认为3秒,如果网络延迟高可设置大些。discovery.zen.minimum_master_nodes: 主结点数量的最少值 ,此值的公式为:(master_eligible_nodes / 2) + 1 ,比如:有3个符合要求的主结点,么这 里要设置为2。
node.max_local_storage_nodes: 单机允许的最大存储结点数,通常单机启动一个结点建议设置为1,开发环境如果单机启动多个节点可设置大于1.

2.2. jvm.options

设置最小及最大的JVM堆内存大小:
在jvm.options中设置 -Xms和-Xmx:
1) 两个值设置为相等
2) 将 Xmx 设置为不超过物理内存的一半。

2.3.log4j2.properties

日志文件设置,ES使用log4j,注意日志级别的配置。

3.启动elasticsearch

== 启动elasticsearch不能在root下 Ctrl+D 退出root==

/usr/local/elasticsearch-6.2.1/bin/elasticsearch
nohup /usr/elasticsearch-6.2.1/bin/elasticsearch & #后台启动运行



发布了57 篇原创文章 · 获赞 52 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/qq_40495860/article/details/98470676