此文章主要讲解5.x版本的配置文件信息
elasticsearch.yml文件详解
[root@CentOS7_node1 ~]# cat /usr/local/elasticsearch-5.6.16/config/elasticsearch.yml
cluster.name: elasticsearch_dockerc
#ES集群名称,同一个集群内的所有节点集群名称必须保持一致
node.name: elasticsearch-node3
#当前节点名称,集群内的各个节点名称必须要唯一
node.master: true
#允许节点是否可以成为一个master节点,ES是默认集群中的第一台机器成为master,如果这台机器停止就会重新选举
node.data: true
#允许该节点存储索引数据(默认开启)
path.data: /data/dockerc/data1,/data/dockerc/data2,/data/dockerc/data3
#ES是搜索引擎,会创建文档,建立索引,此路径是索引的存放目录,如果我们的日志数据较为庞大,那么索引所占用的磁盘空间也是不可小觑的
#这个路径建议是专门的存储系统,如果不是存储系统,最好也要有冗余能力的磁盘,此目录还要对elasticsearch的运行用户有写入权限
#path可以指定多个存储位置,分散存储,有助于性能提升,以至于怎么分散存储请看详解https://www.dockerc.com/elk-theory-elasticsearch/
path.logs: /data/docker/logs
#elasticsearch专门的日志存储位置,生产环境中建议elasticsearch配置文件与elasticsearch日志分开存储
bootstrap.memory_lock: true
#在ES运行起来后锁定ES所能使用的堆内存大小,锁定内存大小一般为可用内存的一半左右;锁定内存后就不会使用交换分区
#如果不打开此项,当系统物理内存空间不足,ES将使用交换分区,ES如果使用交换分区,那么ES的性能将会变得很差
network.host: 10.211.55.10
#es绑定地址,支持IPv4及IPv6,默认绑定127.0.0.1;es的HTTP端口和集群通信端口就会监听在此地址上
network.tcp.no_delay: true
#是否启用tcp无延迟,true为启用tcp不延迟,默认为false启用tcp延迟
network.tcp.keep_alive: true
#是否启用TCP保持活动状态,默认为true
network.tcp.reuse_address: true
#是否应该重复使用地址。默认true,在Windows机器上默认为false
network.tcp.send_buffer_size: 64mb
#tcp发送缓冲区大小,默认不设置
network.tcp.receive_buffer_size: 64mb
#tcp接收缓冲区大小,默认不设置
transport.tcp.port: 9301
#设置集群节点通信的TCP端口,默认就是9300
transport.tcp.compress: true
#设置是否压缩TCP传输时的数据,默认为false
http.max_content_length: 100mb
#设置http请求内容的最大容量,默认是100mb
http.enabled: true
#使用http协议对外提供服务,默认为true,如果为false,则不会监听下面的http.port
http.port: 9201
#定义ES对外调用的http端口,默认是9200
discovery.zen.ping.unicast.hosts: ["10.211.55.7:9301", "10.211.55.8:9301", "10.211.55.9:9301"]
#我们规划ES集群中有好多台主机,我们在这里先把其它集群的主机名称写进入,等其它ES集群节点启动后,在本机中自动添加他们到此集群
#默认主机列表只有127.0.0.1和IPV6的本机回环地址
#上面是书写格式,discover意思为发现,zen是判定集群成员的协议,unicast是单播的意思,ES5.0版本之后只支持单播的方式来进行集群间的通信,hosts为主机
#总结下来就是:使用zen协议通过单播方式去发现集群成员主机,在此建议将所有成员的节点名称都写进来,这样就不用仅靠集群名称cluster.name来判别集群关系了
discovery.zen.minimum_master_nodes: 2
#为了避免脑裂,集群的最少节点数量为,集群的总节点数量除以2加一
#假如我们的总节点数量是4,那就那4除2加一;在此我们的节点数量为3,那么久那三除2然后加1为2.5,按道理来讲四舍五入,但是为了保险起见,我们写为2
discovery.zen.fd.ping_timeout: 90s
#探测超时时间,默认是3秒,我们这里填90秒是为了防止网络不好的时候ES集群发生脑裂现象
discovery.zen.fd.ping_retries: 6
#探测次数,如果每次探测90秒,连续探测超过六次,则认为节点该节点已脱离集群,默认为3次
discovery.zen.fd.ping_interval: 15s
#节点每隔15秒向master发送一次心跳,证明自己和master还存活,默认为1秒太频繁
cluster.routing.allocation.cluster_concurrent_rebalance: 16
#集群内同时启动的数据任务个数,默认是2个
cluster.routing.allocation.node_concurrent_recoveries: 16
#添加或删除节点及负载均衡时并发恢复的线程个数,默认4个
cluster.routing.allocation.node_initial_primaries_recoveries: 16
#初始化数据恢复时,并发恢复线程的个数,默认4个
jvm.options文件详解
#堆内存
-Xms3g #Xms表示ES堆内存初始大小
-Xmx3g #Xmx表示ES堆内存的最大可用空间
#我这是测试环境,因内存空间不足,所以才分配较少的内存空间,ES是很耗内存的,如果在生产环境资源充足的情况下建议给到32G
#过多的内存会导致用于缓存的内存越多,最终导致内存回收的时间也加长
#在生产中,设置的内存建议不要超过物理内存50%,以保证有足够内存留给操作系统
#不要将内存设置超过32GB,xuwl公司的现网ES集群有100多台,每台的设备起两个ES实例,每个实例的最大可用内存给到32G
#GC配置
-XX:+UseConcMarkSweepGC
#使用CMS内存收集
-XX:CMSInitiatingOccupancyFraction=75
#使用CMS作为垃圾回收使用,75%后开始CMS收集
-XX:+UseCMSInitiatingOccupancyOnly
#使用手动定义初始化开始CMS收集
log4j2.propertie文件详解
elasticsearch需要使用log4j2来进行日志记录,默认日志配置已经满足我们日常所需,如需进行二次自定日志格式等,请看官方文档:https://www.elastic.co/guide/en/elasticsearch/reference/6.3/logging.html
创建数据目录
[root@CentOS7_node1 ~]# mkdir -pv /data/dockerc/{data1,data2,data3,logs}
mkdir: created directory ‘/data’
mkdir: created directory ‘/data/dockerc’
mkdir: created directory ‘/data/dockerc/data1’
mkdir: created directory ‘/data/dockerc/data2’
mkdir: created directory ‘/data/dockerc/data3’
mkdir: created directory ‘/data/dockerc/logs’
[root@CentOS7_node1 ~]# chown -Rf elasticsearch /data
[root@CentOS7_node1 ~]# ll /data/dockerc/
total 16
drwxr-xr-x 2 elasticsearch root 4096 May 10 00:13 data1
drwxr-xr-x 2 elasticsearch root 4096 May 10 00:13 data2
drwxr-xr-x 2 elasticsearch root 4096 May 10 00:13 data3
drwxr-xr-x 2 elasticsearch root 4096 May 10 00:13 logs
启动Elasticsearch
配置文件中,我之所以配置discovery自动加入集群参数,是因为我真配置了另外两台主机,我等会会启动,如果你没配置其它主机,就注释掉discovery参数。
节点一启动信息
root@CentOS7_node1 ~]# su elasticsearch /usr/local/elasticsearch-5.6.16/bin/elasticsearch
[2019-05-10T00:17:43,452][INFO ][o.e.n.Node ] [elasticsearch-node1] initializing ...
[2019-05-10T00:17:43,536][INFO ][o.e.e.NodeEnvironment ] [elasticsearch-node1] using [3] data paths, mounts [[/ (rootfs)]], net usable_space [18.1gb], net total_space [24.5gb], spins? [unknown], types [rootfs]
[2019-05-10T00:17:43,536][INFO ][o.e.e.NodeEnvironment ] [elasticsearch-node1] heap size [1007.3mb], compressed ordinary object pointers [true]
[2019-05-10T00:17:43,538][INFO ][o.e.n.Node ] [elasticsearch-node1] node name [elasticsearch-node1], node ID [Zwvq1z3TQZK-oPALgixXEw]
[2019-05-10T00:17:43,538][INFO ][o.e.n.Node ] [elasticsearch-node1] version[5.6.16], pid[4408], build[3a740d1/2019-03-13T15:33:36.565Z], OS[Linux/3.10.0-957.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_161/25.161-b12]
[2019-05-10T00:17:43,538][INFO ][o.e.n.Node ] [elasticsearch-node1] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -Djdk.io.permissionsUseCanonicalPath=true, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Dlog4j.skipJansi=true, -XX:+HeapDumpOnOutOfMemoryError, -Des.path.home=/usr/local/elasticsearch-5.6.16]
[2019-05-10T00:17:44,446][INFO ][o.e.p.PluginsService ] [elasticsearch-node1] loaded module [aggs-matrix-stats]
[2019-05-10T00:17:44,447][INFO ][o.e.p.PluginsService ] [elasticsearch-node1] loaded module [ingest-common]
[2019-05-10T00:17:44,447][INFO ][o.e.p.PluginsService ] [elasticsearch-node1] loaded module [lang-expression]
[2019-05-10T00:17:44,447][INFO ][o.e.p.PluginsService ] [elasticsearch-node1] loaded module [lang-groovy]
[2019-05-10T00:17:44,447][INFO ][o.e.p.PluginsService ] [elasticsearch-node1] loaded module [lang-mustache]
[2019-05-10T00:17:44,447][INFO ][o.e.p.PluginsService ] [elasticsearch-node1] loaded module [lang-painless]
[2019-05-10T00:17:44,447][INFO ][o.e.p.PluginsService ] [elasticsearch-node1] loaded module [parent-join]
[2019-05-10T00:17:44,447][INFO ][o.e.p.PluginsService ] [elasticsearch-node1] loaded module [percolator]
[2019-05-10T00:17:44,447][INFO ][o.e.p.PluginsService ] [elasticsearch-node1] loaded module [reindex]
[2019-05-10T00:17:44,447][INFO ][o.e.p.PluginsService ] [elasticsearch-node1] loaded module [transport-netty3]
[2019-05-10T00:17:44,447][INFO ][o.e.p.PluginsService ] [elasticsearch-node1] loaded module [transport-netty4]
[2019-05-10T00:17:44,447][INFO ][o.e.p.PluginsService ] [elasticsearch-node1] no plugins loaded
[2019-05-10T00:17:46,855][INFO ][o.e.d.DiscoveryModule ] [elasticsearch-node1] using discovery type [zen]
[2019-05-10T00:17:47,716][INFO ][o.e.n.Node ] [elasticsearch-node1] initialized
[2019-05-10T00:17:47,716][INFO ][o.e.n.Node ] [elasticsearch-node1] starting ...
[2019-05-10T00:17:47,993][INFO ][o.e.t.TransportService ] [elasticsearch-node1] publish_address {10.211.55.7:9301}, bound_addresses {10.211.55.7:9301}
[2019-05-10T00:17:48,014][INFO ][o.e.b.BootstrapChecks ] [elasticsearch-node1] bound or publishing to a non-loopback address, enforcing bootstrap checks
[2019-05-10T00:17:51,097][WARN ][o.e.d.z.ZenDiscovery ] [elasticsearch-node1] not enough master nodes discovered during pinging (found [[Candidate{node={elasticsearch-node1}{Zwvq1z3TQZK-oPALgixXEw}{Eu1dFZSbRX6tYMwiOtqeZg}{10.211.55.7}{10.211.55.7:9301}, clusterStateVersion=-1}]], but needed [2]), pinging again
[2019-05-10T00:17:54,346][INFO ][o.e.c.s.ClusterService ] [elasticsearch-node1] detected_master {elasticsearch-node3}{RNO7uYb-QOSJCQJ7EIkUMw}{VM3cXe-_TDOc_1qyq7yW3A}{10.211.55.10}{10.211.55.10:9301}, added {{elasticsearch-node3}{RNO7uYb-QOSJCQJ7EIkUMw}{VM3cXe-_TDOc_1qyq7yW3A}{10.211.55.10}{10.211.55.10:9301},}, reason: zen-disco-receive(from master [master {elasticsearch-node3}{RNO7uYb-QOSJCQJ7EIkUMw}{VM3cXe-_TDOc_1qyq7yW3A}{10.211.55.10}{10.211.55.10:9301} committed version [1]])
[2019-05-10T00:17:54,361][INFO ][o.e.h.n.Netty4HttpServerTransport] [elasticsearch-node1] publish_address {10.211.55.7:9201}, bound_addresses {10.211.55.7:9201}
[2019-05-10T00:17:54,362][INFO ][o.e.n.Node ] [elasticsearch-node1] started
[2019-05-10T00:17:54,476][INFO ][o.e.c.s.ClusterService ] [elasticsearch-node1] added {{elasticsearch-node2}{lQp8MtlHQZ6SPaAItO6XNQ}{DKUwk92pTCizmqvDIcxrnw}{10.211.55.9}{10.211.55.9:9301},}, reason: zen-disco-receive(from master [master {elasticsearch-node3}{RNO7uYb-QOSJCQJ7EIkUMw}{VM3cXe-_TDOc_1qyq7yW3A}{10.211.55.10}{10.211.55.10:9301} committed version [3]])
启动的时候有个WARN警告信息,是因为刚启动还没找到谁是主节点,所以参生了一条警告信息,不过当集群建立后,很快就没了
节点二启动信息
[root@CentOS7_node2 ~]# su elasticsearch /usr/local/elasticsearch-5.6.16/bin/elasticsearch
[2019-05-10T00:17:45,882][INFO ][o.e.n.Node ] [elasticsearch-node2] initializing ...
[2019-05-10T00:17:46,012][INFO ][o.e.e.NodeEnvironment ] [elasticsearch-node2] using [3] data paths, mounts [[/ (rootfs)]], net usable_space [43.8gb], net total_space [49gb], spins? [unknown], types [rootfs]
[2019-05-10T00:17:46,013][INFO ][o.e.e.NodeEnvironment ] [elasticsearch-node2] heap size [1007.3mb], compressed ordinary object pointers [true]
[2019-05-10T00:17:46,015][INFO ][o.e.n.Node ] [elasticsearch-node2] node name [elasticsearch-node2], node ID [lQp8MtlHQZ6SPaAItO6XNQ]
[2019-05-10T00:17:46,015][INFO ][o.e.n.Node ] [elasticsearch-node2] version[5.6.16], pid[17079], build[3a740d1/2019-03-13T15:33:36.565Z], OS[Linux/3.10.0-957.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_161/25.161-b12]
[2019-05-10T00:17:46,016][INFO ][o.e.n.Node ] [elasticsearch-node2] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -Djdk.io.permissionsUseCanonicalPath=true, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Dlog4j.skipJansi=true, -XX:+HeapDumpOnOutOfMemoryError, -Des.path.home=/usr/local/elasticsearch-5.6.16]
[2019-05-10T00:17:47,214][INFO ][o.e.p.PluginsService ] [elasticsearch-node2] loaded module [aggs-matrix-stats]
[2019-05-10T00:17:47,214][INFO ][o.e.p.PluginsService ] [elasticsearch-node2] loaded module [ingest-common]
[2019-05-10T00:17:47,214][INFO ][o.e.p.PluginsService ] [elasticsearch-node2] loaded module [lang-expression]
[2019-05-10T00:17:47,214][INFO ][o.e.p.PluginsService ] [elasticsearch-node2] loaded module [lang-groovy]
[2019-05-10T00:17:47,214][INFO ][o.e.p.PluginsService ] [elasticsearch-node2] loaded module [lang-mustache]
[2019-05-10T00:17:47,215][INFO ][o.e.p.PluginsService ] [elasticsearch-node2] loaded module [lang-painless]
[2019-05-10T00:17:47,215][INFO ][o.e.p.PluginsService ] [elasticsearch-node2] loaded module [parent-join]
[2019-05-10T00:17:47,215][INFO ][o.e.p.PluginsService ] [elasticsearch-node2] loaded module [percolator]
[2019-05-10T00:17:47,215][INFO ][o.e.p.PluginsService ] [elasticsearch-node2] loaded module [reindex]
[2019-05-10T00:17:47,215][INFO ][o.e.p.PluginsService ] [elasticsearch-node2] loaded module [transport-netty3]
[2019-05-10T00:17:47,215][INFO ][o.e.p.PluginsService ] [elasticsearch-node2] loaded module [transport-netty4]
[2019-05-10T00:17:47,216][INFO ][o.e.p.PluginsService ] [elasticsearch-node2] no plugins loaded
[2019-05-10T00:17:49,892][INFO ][o.e.d.DiscoveryModule ] [elasticsearch-node2] using discovery type [zen]
[2019-05-10T00:17:50,553][INFO ][o.e.n.Node ] [elasticsearch-node2] initialized
[2019-05-10T00:17:50,553][INFO ][o.e.n.Node ] [elasticsearch-node2] starting ...
[2019-05-10T00:17:51,232][INFO ][o.e.t.TransportService ] [elasticsearch-node2] publish_address {10.211.55.9:9301}, bound_addresses {10.211.55.9:9301}
[2019-05-10T00:17:51,244][INFO ][o.e.b.BootstrapChecks ] [elasticsearch-node2] bound or publishing to a non-loopback address, enforcing bootstrap checks
[2019-05-10T00:17:54,493][INFO ][o.e.c.s.ClusterService ] [elasticsearch-node2] detected_master {elasticsearch-node3}{RNO7uYb-QOSJCQJ7EIkUMw}{VM3cXe-_TDOc_1qyq7yW3A}{10.211.55.10}{10.211.55.10:9301}, added {{elasticsearch-node1}{Zwvq1z3TQZK-oPALgixXEw}{Eu1dFZSbRX6tYMwiOtqeZg}{10.211.55.7}{10.211.55.7:9301},{elasticsearch-node3}{RNO7uYb-QOSJCQJ7EIkUMw}{VM3cXe-_TDOc_1qyq7yW3A}{10.211.55.10}{10.211.55.10:9301},}, reason: zen-disco-receive(from master [master {elasticsearch-node3}{RNO7uYb-QOSJCQJ7EIkUMw}{VM3cXe-_TDOc_1qyq7yW3A}{10.211.55.10}{10.211.55.10:9301} committed version [3]])
[2019-05-10T00:17:54,556][INFO ][o.e.h.n.Netty4HttpServerTransport] [elasticsearch-node2] publish_address {10.211.55.9:9201}, bound_addresses {10.211.55.9:9201}
[2019-05-10T00:17:54,556][INFO ][o.e.n.Node ] [elasticsearch-node2] started
节点三启动信息
[root@CentOS7_node3 ~]# su elasticsearch /usr/local/elasticsearch-5.6.16/bin/elasticsearch
[2019-05-10T00:17:46,623][INFO ][o.e.n.Node ] [elasticsearch-node3] initializing ...
[2019-05-10T00:17:46,792][INFO ][o.e.e.NodeEnvironment ] [elasticsearch-node3] using [3] data paths, mounts [[/ (rootfs)]], net usable_space [44.1gb], net total_space [49gb], spins? [unknown], types [rootfs]
[2019-05-10T00:17:46,793][INFO ][o.e.e.NodeEnvironment ] [elasticsearch-node3] heap size [1007.3mb], compressed ordinary object pointers [true]
[2019-05-10T00:17:46,796][INFO ][o.e.n.Node ] [elasticsearch-node3] node name [elasticsearch-node3], node ID [RNO7uYb-QOSJCQJ7EIkUMw]
[2019-05-10T00:17:46,797][INFO ][o.e.n.Node ] [elasticsearch-node3] version[5.6.16], pid[16838], build[3a740d1/2019-03-13T15:33:36.565Z], OS[Linux/3.10.0-957.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_161/25.161-b12]
[2019-05-10T00:17:46,797][INFO ][o.e.n.Node ] [elasticsearch-node3] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -Djdk.io.permissionsUseCanonicalPath=true, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Dlog4j.skipJansi=true, -XX:+HeapDumpOnOutOfMemoryError, -Des.path.home=/usr/local/elasticsearch-5.6.16]
[2019-05-10T00:17:48,071][INFO ][o.e.p.PluginsService ] [elasticsearch-node3] loaded module [aggs-matrix-stats]
[2019-05-10T00:17:48,072][INFO ][o.e.p.PluginsService ] [elasticsearch-node3] loaded module [ingest-common]
[2019-05-10T00:17:48,072][INFO ][o.e.p.PluginsService ] [elasticsearch-node3] loaded module [lang-expression]
[2019-05-10T00:17:48,072][INFO ][o.e.p.PluginsService ] [elasticsearch-node3] loaded module [lang-groovy]
[2019-05-10T00:17:48,072][INFO ][o.e.p.PluginsService ] [elasticsearch-node3] loaded module [lang-mustache]
[2019-05-10T00:17:48,072][INFO ][o.e.p.PluginsService ] [elasticsearch-node3] loaded module [lang-painless]
[2019-05-10T00:17:48,072][INFO ][o.e.p.PluginsService ] [elasticsearch-node3] loaded module [parent-join]
[2019-05-10T00:17:48,072][INFO ][o.e.p.PluginsService ] [elasticsearch-node3] loaded module [percolator]
[2019-05-10T00:17:48,073][INFO ][o.e.p.PluginsService ] [elasticsearch-node3] loaded module [reindex]
[2019-05-10T00:17:48,073][INFO ][o.e.p.PluginsService ] [elasticsearch-node3] loaded module [transport-netty3]
[2019-05-10T00:17:48,073][INFO ][o.e.p.PluginsService ] [elasticsearch-node3] loaded module [transport-netty4]
[2019-05-10T00:17:48,074][INFO ][o.e.p.PluginsService ] [elasticsearch-node3] no plugins loaded
[2019-05-10T00:17:50,333][INFO ][o.e.d.DiscoveryModule ] [elasticsearch-node3] using discovery type [zen]
[2019-05-10T00:17:50,965][INFO ][o.e.n.Node ] [elasticsearch-node3] initialized
[2019-05-10T00:17:50,966][INFO ][o.e.n.Node ] [elasticsearch-node3] starting ...
[2019-05-10T00:17:51,225][INFO ][o.e.t.TransportService ] [elasticsearch-node3] publish_address {10.211.55.10:9301}, bound_addresses {10.211.55.10:9301}
[2019-05-10T00:17:51,240][INFO ][o.e.b.BootstrapChecks ] [elasticsearch-node3] bound or publishing to a non-loopback address, enforcing bootstrap checks
[2019-05-10T00:17:54,332][INFO ][o.e.c.s.ClusterService ] [elasticsearch-node3] new_master {elasticsearch-node3}{RNO7uYb-QOSJCQJ7EIkUMw}{VM3cXe-_TDOc_1qyq7yW3A}{10.211.55.10}{10.211.55.10:9301}, added {{elasticsearch-node1}{Zwvq1z3TQZK-oPALgixXEw}{Eu1dFZSbRX6tYMwiOtqeZg}{10.211.55.7}{10.211.55.7:9301},}, reason: zen-disco-elected-as-master ([1] nodes joined)[{elasticsearch-node1}{Zwvq1z3TQZK-oPALgixXEw}{Eu1dFZSbRX6tYMwiOtqeZg}{10.211.55.7}{10.211.55.7:9301}]
[2019-05-10T00:17:54,397][INFO ][o.e.h.n.Netty4HttpServerTransport] [elasticsearch-node3] publish_address {10.211.55.10:9201}, bound_addresses {10.211.55.10:9201}
[2019-05-10T00:17:54,397][INFO ][o.e.n.Node ] [elasticsearch-node3] started
[2019-05-10T00:17:54,474][INFO ][o.e.g.GatewayService ] [elasticsearch-node3] recovered [0] indices into cluster_state
[2019-05-10T00:17:54,475][INFO ][o.e.c.s.ClusterService ] [elasticsearch-node3] added {{elasticsearch-node2}{lQp8MtlHQZ6SPaAItO6XNQ}{DKUwk92pTCizmqvDIcxrnw}{10.211.55.9}{10.211.55.9:9301},}, reason: zen-disco-node-join[{elasticsearch-node2}{lQp8MtlHQZ6SPaAItO6XNQ}{DKUwk92pTCizmqvDIcxrnw}{10.211.55.9}{10.211.55.9:9301}]
验证测试
简单测试
[root@CentOS7_node1 /]# curl http://10.211.55.7:9201
{
"name" : "elasticsearch-node1",
"cluster_name" : "elasticsearch_dockerc",
"cluster_uuid" : "3S3OpVh-SpqNaX59cnP-UQ",
"version" : {
"number" : "5.6.16",
"build_hash" : "3a740d1",
"build_date" : "2019-03-13T15:33:36.565Z",
"build_snapshot" : false,
"lucene_version" : "6.6.1"
},
"tagline" : "You Know, for Search"
}
[root@CentOS7_node1 /]# curl http://10.211.55.9:9201
{
"name" : "elasticsearch-node2",
"cluster_name" : "elasticsearch_dockerc",
"cluster_uuid" : "3S3OpVh-SpqNaX59cnP-UQ",
"version" : {
"number" : "5.6.16",
"build_hash" : "3a740d1",
"build_date" : "2019-03-13T15:33:36.565Z",
"build_snapshot" : false,
"lucene_version" : "6.6.1"
},
"tagline" : "You Know, for Search"
}
[root@CentOS7_node1 /]# curl http://10.211.55.10:9201
{
"name" : "elasticsearch-node3",
"cluster_name" : "elasticsearch_dockerc",
"cluster_uuid" : "3S3OpVh-SpqNaX59cnP-UQ",
"version" : {
"number" : "5.6.16",
"build_hash" : "3a740d1",
"build_date" : "2019-03-13T15:33:36.565Z",
"build_snapshot" : false,
"lucene_version" : "6.6.1"
},
"tagline" : "You Know, for Search"
}
集×××互
和集×××互语法如下:
curl -X '://:/?' -d ''
:指定请求方式如:GET,POST,PUT,DELETE
:指定请求协议,这里应该都为http
:指定主机地址,可以是IP地址也可以是hostname
:指定端口
:指定路径
:特殊的请求方式:/_cat, /_search, /_cluster
:json格式的请求主体
_cat方式
_cat的用法有很多,具体看下面使用方法
[root@CentOS7_node1 /]# curl -XGET 'http://10.211.55.7:9201/_cat?pretty'
=^.^=
/_cat/allocation
/_cat/shards
/_cat/shards/{index}
/_cat/master
/_cat/nodes
/_cat/tasks
/_cat/indices
/_cat/indices/{index}
/_cat/segments
/_cat/segments/{index}
/_cat/count
/_cat/count/{index}
/_cat/recovery
/_cat/recovery/{index}
/_cat/health
/_cat/pending_tasks
/_cat/aliases
/_cat/aliases/{alias}
/_cat/thread_pool
/_cat/thread_pool/{thread_pools}
/_cat/plugins
/_cat/fielddata
/_cat/fielddata/{fields}
/_cat/nodeattrs
/_cat/repositories
/_cat/snapshots/{repository}
/_cat/templates
[root@CentOS7_node1 /]# curl -XGET 'http://10.211.55.7:9201/_cat/nodes' #查看node节点,下面*为master节点
10.211.55.7 14 50 1 0.00 0.01 0.05 mdi - elasticsearch-node1
10.211.55.9 12 53 1 0.00 0.01 0.05 mdi - elasticsearch-node2
10.211.55.10 10 72 1 0.00 0.01 0.05 mdi * elasticsearch-node3
[root@CentOS7_node1 /]# curl -XGET 'http://10.211.55.7:9201/_cat/nodes?v' #加了?v来人性化显示内容,首行为内容表示
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
10.211.55.7 15 50 1 0.00 0.01 0.05 mdi - elasticsearch-node1
10.211.55.9 12 53 0 0.00 0.01 0.05 mdi - elasticsearch-node2
10.211.55.10 10 72 0 0.00 0.01 0.05 mdi * elasticsearch-node3
[root@CentOS7_node1 /]# curl -XGET 'http://10.211.55.7:9201/_cat/health?v' #查看集群的健康程度,status状态为green,意思为状态良好,无分片出现问题等
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1557419073 00:24:33 elasticsearch_dockerc green 3 3 0 0 0 0 0 0 - 100.0%
[root@CentOS7_node1 /]# curl -XGET 'http://10.211.55.7:9201/_cat/plugins?v' #查看插件
name component version
[root@CentOS7_node1 /]# curl -XGET 'http://10.211.55.7:9201/_cat/master?v' #查看master节点
id host ip node
RNO7uYb-QOSJCQJ7EIkUMw 10.211.55.10 10.211.55.10 elasticsearch-node3
[root@CentOS7_node1 /]# curl -XGET 'http://10.211.55.7:9201/_cat/tasks?v' #查看节点任务
action task_id parent_task_id type start_time timestamp running_time ip node
cluster:monitor/tasks/lists Zwvq1z3TQZK-oPALgixXEw:92 - transport 1557419112373 00:25:12 6.4ms 10.211.55.7 elasticsearch-node1
cluster:monitor/tasks/lists[n] Zwvq1z3TQZK-oPALgixXEw:93 Zwvq1z3TQZK-oPALgixXEw:92 direct 1557419112376 00:25:12 4.4ms 10.211.55.7 elasticsearch-node1
cluster:monitor/tasks/lists[n] RNO7uYb-QOSJCQJ7EIkUMw:136 Zwvq1z3TQZK-oPALgixXEw:92 netty 1557419112383 00:25:12 3.8ms 10.211.55.10 elasticsearch-node3
cluster:monitor/tasks/lists[n] lQp8MtlHQZ6SPaAItO6XNQ:69 Zwvq1z3TQZK-oPALgixXEw:92 netty 1557419112383 00:25:12 3.9ms 10.211.55.9 elasticsearch-node2
[root@CentOS7_node1 /]# curl -XGET 'http://10.211.55.7:9201/_cat/shards?v' #查看es分片,因为无数据,所以无分片
index shard prirep state docs store ip node
[root@CentOS7_node1 /]# curl -XGET 'http://10.211.55.7:9201/_cat/indices?v' #查看索引
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
search方式
[root@CentOS7_node1 /]# curl -XGET 'http://10.211.55.7:9201/_search?pretty'
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 0,
"successful" : 0,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : 0.0,
"hits" : [ ]
}
}
cluster方式
[root@CentOS7_node1 /]# curl -XGET 'http://10.211.55.7:9201/_cluster?pretty'
{
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "No endpoint or operation is available at [_cluster]"
}
],
"type" : "illegal_argument_exception",
"reason" : "No endpoint or operation is available at [_cluster]"
},
"status" : 400
}