1.安装
#下载
$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-linux-x86_64.tar.gz
#解压
$ tar -xzf elasticsearch-7.0.0-linux-x86_64.tar.gz
2.配置更改(后续补充,重要)
./config/elasticsearch.yml es配置
./config/jvm.options 内存配置
./config/log4j2.properties 日志配置
2.1.es集群配置(/config/elasticsearch.yml)
- node95
#集群名称
cluster.name: elasticsearch
#节点名称
node.name: node-a
#是不是有资格竞选主节点
node.master: true
#是否存储数据
node.data: true
#最大集群节点数
node.max_local_storage_nodes: 3
#网关地址
network.host: 192.168.10.95
#端口
http.port: 9200
#内部节点之间沟通端口
transport.tcp.port: 9300
#es7.x 之后新增的配置,写入候选主节点的设备地址,在开启服务后可以被选为主节点
discovery.seed_hosts: ["node95:9300","node94:9300","node93:9300"]
#es7.x 之后新增的配置,初始化一个新的集群时需要此配置来选举master
cluster.initial_master_nodes: ["node-a", "node-b","node-c"]
#数据存储路径
path.data: /home/bigdata/es/data
#日志存储路径
path.logs: /home/bigdata/es/logs
- node94
#集群名称
cluster.name: elasticsearch
#节点名称
node.name: node-b
#是不是有资格竞选主节点
node.master: true
#是否存储数据
node.data: true
#最大集群节点数
node.max_local_storage_nodes: 3
#网关地址
network.host: 192.168.10.94
#端口
http.port: 9200
#内部节点之间沟通端口
transport.tcp.port: 9300
#es7.x 之后新增的配置,写入候选主节点的设备地址,在开启服务后可以被选为主节点
discovery.seed_hosts: ["node95:9300","node94:9300","node93:9300"]
#es7.x 之后新增的配置,初始化一个新的集群时需要此配置来选举master
cluster.initial_master_nodes: ["node-a", "node-b","node-c"]
#数据存储路径
path.data: /home/bigdata/es/data
#日志存储路径
path.logs: /home/bigdata/es/logs
- node93
#集群名称
cluster.name: elasticsearch
#节点名称
node.name: node-c
#是不是有资格竞选主节点
node.master: true
#是否存储数据
node.data: true
#最大集群节点数
node.max_local_storage_nodes: 3
#网关地址
network.host: 192.168.10.93
#端口
http.port: 9200
#内部节点之间沟通端口
transport.tcp.port: 9300
#es7.x 之后新增的配置,写入候选主节点的设备地址,在开启服务后可以被选为主节点
discovery.seed_hosts: ["node95:9300","node94:9300","node93:9300"]
#es7.x 之后新增的配置,初始化一个新的集群时需要此配置来选举master
cluster.initial_master_nodes: ["node-a", "node-b","node-c"]
#数据存储路径
path.data: /home/bigdata/es/data
#日志存储路径
path.logs: /home/bigdata/es/logs
3.启动命令
$ nohup ./bin/elasticsearch &
4.节点验证
$ curl -XGET 'http://localhost:9200'
{
"name": "master-node95",
"cluster_name": "search7",
"cluster_uuid": "V7ZVyFNeRc29om2md1jU3A",
"version": {
"number": "7.0.0",
"build_flavor": "default",
"build_type": "tar",
"build_hash": "b7e28a7",
"build_date": "2019-04-05T22:55:32.697037Z",
"build_snapshot": false,
"lucene_version": "8.0.0",
"minimum_wire_compatibility_version": "6.7.0",
"minimum_index_compatibility_version": "6.0.0-beta1"
},
"tagline": "You Know, for Search"
}
5.检查集群
我配置的时候由于有台机器网卡不止一张,并且把network.host配置成了0.0.0.0,导致没有通信成功,没有加入集群
$ curl -XGET 'http://localhost:9200/_cluster/health?pretty=true'
{
"cluster_name" : "elasticsearch",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 2,
"number_of_data_nodes" : 2,
"active_primary_shards" : 0,
"active_shards" : 0,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 0,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 100.0
}
notes.
- 检查集群情况
- ES服务器搭建以及常遇问题处理
-
集群某个节点通信问题,导致只有2个节点
master not discovered or elected yet, an election requires 2
org.elasticsearch.transport.RemoteTransportException: [node-a]
检查网卡配置,network.host
参数不要配成0.0.0.0
-
max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
修改但对于已建好的用户不生效的解决方案- 首先切root账号,再执行
ulimit -SHn 65535 && echo "ulimit -SHn 65535" >> /etc/profile && source /etc/profile
- 然后切换至普通用户再执行启动命令
- 首先切root账号,再执行
网友评论