elasticsearch集群

2018-04-25 16:19:08 浏览数 (1)

安装elasticsearch集群

hostname

ip

port

es-1

128.0.0.101

9200

es-2

128.0.0.102

9200

安装jdk

[root@es1 ~]# java -version java version "1.8.0151" Java(TM) SE Runtime Environment (build 1.8.0151-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

安装es软件

见上一篇文章

#修改es的配置文件
代码语言:javascript复制
root@es1 elasticsearch-5.4.1]# cat config/elasticsearch.yml | grep -v "#"
cluster.name: es-log
node.name: log-1
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 128.0.0.101
http.port: 9200
discovery.zen.ping.unicast.hosts: ["128.0.0.101", "128.0.0.102"]
discovery.zen.minimum_master_nodes: 1
[root@es2 elasticsearch-5.4.1]# cat config/elasticsearch.yml | grep -v "#"
cluster.name: es-log
node.name: log-2
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 128.0.0.102
http.port: 9200
discovery.zen.ping.unicast.hosts: ["128.0.0.101", "128.0.0.102"]
discovery.zen.minimum_master_nodes: 1
切换用户启动
代码语言:javascript复制
[root@es1 elk]# su - elk
[elk@es1 elasticsearch-5.4.1]$ bin/elasticsearch
[root@es2 elk]# su - elk
[elk@es2 elasticsearch-5.4.1]$ bin/elasticsearch
插入数据
代码语言:javascript复制
[root@es1 ~]# curl -XPOST '128.0.0.101:9200/test/name/1' -d '
{
  "name": "ceshi"
}'
{"_index":"test","_type":"name","_id":"1","_version":1,"result":"created","_shards":{"total":2,"successful":2,"failed":0},"create
检查集群
代码语言:javascript复制
[root@es1 ~]# curl  -XGET '128.0.0.101:9200/_cluster/health?pretty'
{
  "cluster_name" : "es-log",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 2,
  "number_of_data_nodes" : 2,
  "active_primary_shards" : 10,
  "active_shards" : 20,
  "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
}
#状态为green集群正常
[root@es1 ~]# curl -XGET '128.0.0.101:9200/_cat/nodes?v&pretty'
ip          heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
128.0.0.101            6          94   0    0.03    0.01     0.00 mdi       *      log-1
128.0.0.102            4          82   0    0.00    0.00     0.00 mdi       -      log-2

0 人点赞