ELK之elasticsearch6.5
官方网站:https://www.elastic.co/guide/en/elasticsearch/reference/current/rpm.html
这里采用rpm的方式安装:
# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.4.rpm
elasticsearch依赖java环境,于是在安装之前需要配置java:
# rpm -ivh jdk-8u191-linux-x64.rpm
# java -version
java环境安装完成后,安装elasticsearch:
# rpm --install elasticsearch-6.5.4.rpm
elasticsearch的配置文件:
[root@node1 ~]# cd /etc/elasticsearch/
[root@node1 elasticsearch]# ll
总用量 36
-rw-rw----. 1 root elasticsearch 207 12月 23 18:04 elasticsearch.keystore
-rw-rw----. 1 root elasticsearch 2869 12月 18 05:21 elasticsearch.yml
-rw-rw----. 1 root elasticsearch 3266 12月 18 05:21 jvm.options
-rw-rw----. 1 root elasticsearch 12423 12月 18 05:21 log4j2.properties
-rw-rw----. 1 root elasticsearch 473 12月 18 05:21 role_mapping.yml
-rw-rw----. 1 root elasticsearch 197 12月 18 05:21 roles.yml
-rw-rw----. 1 root elasticsearch 0 12月 18 05:21 users
-rw-rw----. 1 root elasticsearch 0 12月 18 05:21 users_roles
如果需要修改jvm参数,调整jvm.options这个配置文件就行:默认配置为1g
[root@node1 elasticsearch]# egrep "^-Xms|^-Xmx" jvm.options
-Xms1g
-Xmx1g
现在将elasticsearch做一下简单的配置如下:
[root@node1 elasticsearch]# egrep -v "^$|^#" elasticsearch.yml
cluster.name: es 集群的名字
node.name: node1 节点的名字
path.data: /var/lib/elasticsearch 数据目录
path.logs: /var/log/elasticsearch 日志目录
network.host: 0.0.0.0 服务监听的ip
http.port: 9200 服务监听的端口
然后启动elasticsearch服务:
# systemctl daemon-reload
# systemctl enable elasticsearch.service
# systemctl start elasticsearch.service
# systemctl status elasticsearch.service
查看监听状态:
[root@node1 elasticsearch]# netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 968/sshd
tcp6 0 0 :::9200 :::* LISTEN 2756/java
tcp6 0 0 :::9300 :::* LISTEN 2756/java
tcp6 0 0 :::22 :::* LISTEN 968/sshd
于是单节点的elasticsearch服务配置完成,现在做一些curl的操作,熟悉elasticsearch的一些查询:
1.关于cat API的使用:
[root@node1 elasticsearch]# curl -X GET "localhost:9200/_cat/nodes"
172.16.23.129 32 68 0 0.00 0.04 0.05 mdi * node1
[root@node1 elasticsearch]# curl -X GET "localhost:9200/_cat/nodes?v"
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
172.16.23.129 28 68 2 0.02 0.07 0.05 mdi * node1
由于es集群只有一个节点,所以节点node1也是master节点:
[root@node1 elasticsearch]# curl -X GET "localhost:9200/_cat/master?v"
id host ip node
q95yZ4W4Tj6PaXyzLZZYDQ 172.16.23.129 172.16.23.129 node1
然后可以根据指定的字段获取结果:
[root@node1 elasticsearch]# curl -X GET "localhost:9200/_cat/nodes?v&h=id,ip,port,v,m"
id ip port v m
q95y 172.16.23.129 9300 6.5.4 *
指定的字段格式为:h=colume即可:这里的h代表为header
[root@node1 elasticsearch]# curl -X GET "localhost:9200/_cat/nodes?v&h=ram.percent"
ram.percent
69
具体header后面可以过滤哪些colume,请查看官网:https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-nodes.html
查看health:
[root@node1 elasticsearch]# curl -X GET "localhost:9200/_cat/health?v"
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1545561036 10:30:36 es green 1 1 0 0 0 0 0 0 - 100.0%
elasticsearch下重要的index:
[root@node1 elasticsearch]# curl -X GET "localhost:9200/_cat/indices?v"
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
由上面返回结果来看,是没有数据的,表示es这个集群并没有构建索引
2.关于indices API的使用:
2.1创建一个index:
# curl -X PUT "localhost:9200/test1" 创建的索引全部以默认值,默认的shard等等
查看这个index:
[root@node1 elasticsearch]# curl -X GET "localhost:9200/_cat/indices?v"
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open test1 KqGrTZ7GQv6o5jEQPK-wwA 5 1 0 0 1.1kb 1.1kb
创建的index拥有默认的shards个数,5个,可以通过将indeices换为shards进行查看
查看索引test1的具体的默认配置,获取索引test1:
[root@node1 elasticsearch]# curl -X GET "localhost:9200/test1"
{"test1":{"aliases":{},"mappings":{},"settings":{"index":{"creation_date":"1545561578119","number_of_shards":"5","number_of_replicas":"1","uuid":"KqGrTZ7GQv6o5jEQPK-wwA","version":{"created":"6050499"},"provided_name":"test1"}}}}[root@node1 elasticsearch]#
由于上面的结果不利于查看,于是使用python的json工具转化一下:
[root@node1 elasticsearch]# curl -X GET "localhost:9200/test1" |python -m json.tool
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 229 100 229 0 0 6870 0 --:--:-- --:--:-- --:--:-- 7387
{
"test1": {
"aliases": {},
"mappings": {},
"settings": {
"index": {
"creation_date": "1545561578119",
"number_of_replicas": "1",
"number_of_shards": "5",
"provided_name": "test1",
"uuid": "KqGrTZ7GQv6o5jEQPK-wwA",
"version": {
"created": "6050499"
}
}
}
}
}
可以看见上面依然显示不是很友好,有下载的状态,curl的参数-s静默输出:
[root@node1 elasticsearch]# curl -X GET "localhost:9200/test1" -s|python -m json.tool
{
"test1": {
"aliases": {},
"mappings": {},
"settings": {
"index": {
"creation_date": "1545561578119",
"number_of_replicas": "1",
"number_of_shards": "5",
"provided_name": "test1",
"uuid": "KqGrTZ7GQv6o5jEQPK-wwA",
"version": {
"created": "6050499"
}
}
}
}
}
可以看出索引test1的shards数为5个,replicas数为1个等等信息
获取索引test1中结果的某指定字段:
[root@node1 elasticsearch]# curl -X GET "localhost:9200/test1/_settings" -s|python -m json.tool
{
"test1": {
"settings": {
"index": {
"creation_date": "1545561578119",
"number_of_replicas": "1",
"number_of_shards": "5",
"provided_name": "test1",
"uuid": "KqGrTZ7GQv6o5jEQPK-wwA",
"version": {
"created": "6050499"
}
}
}
}
}
[root@node1 elasticsearch]# curl -X GET "localhost:9200/test1/_mappings" -s|python -m json.tool
{
"test1": {
"mappings": {}
}
}
2.2删除索引
[root@node1 elasticsearch]# curl -X DELETE "localhost:9200/test1"
{"acknowledged":true}[root@node1 elasticsearch]#
3._cluster API查询:
[root@node1 elasticsearch]# curl -X GET "localhost:9200/_cluster/health" -s |python -m json.tool
{
"active_primary_shards": 5,
"active_shards": 5,
"active_shards_percent_as_number": 50.0,
"cluster_name": "es",
"delayed_unassigned_shards": 0,
"initializing_shards": 0,
"number_of_data_nodes": 1,
"number_of_in_flight_fetch": 0,
"number_of_nodes": 1,
"number_of_pending_tasks": 0,
"relocating_shards": 0,
"status": "yellow",
"task_max_waiting_in_queue_millis": 0,
"timed_out": false,
"unassigned_shards": 5
}
[root@node1 elasticsearch]# curl -X GET "localhost:9200/_cluster/health/test1" -s |python -m json.tool
{
"active_primary_shards": 5,
"active_shards": 5,
"active_shards_percent_as_number": 50.0,
"cluster_name": "es",
"delayed_unassigned_shards": 0,
"initializing_shards": 0,
"number_of_data_nodes": 1,
"number_of_in_flight_fetch": 0,
"number_of_nodes": 1,
"number_of_pending_tasks": 0,
"relocating_shards": 0,
"status": "yellow",
"task_max_waiting_in_queue_millis": 0,
"timed_out": false,
"unassigned_shards": 5
}
[root@node1 elasticsearch]# curl -X GET "localhost:9200/_cluster/health/test1?level=shards" -s |python -m json.tool
如果不想-s |python -m json.tool,那么还有一种方式格式化输出:
[root@node1 elasticsearch]# curl -X GET "localhost:9200/test1?human&pretty"
{
"test1" : {
"aliases" : { },
"mappings" : { },
"settings" : {
"index" : {
"creation_date_string" : "2018-12-23T11:04:48.982Z",
"number_of_shards" : "5",
"provided_name" : "test1",
"creation_date" : "1545563088982",
"number_of_replicas" : "1",
"uuid" : "ZAjj9y_sSPmGz8ZscIXUsA",
"version" : {
"created_string" : "6.5.4",
"created" : "6050499"
}
}
}
}
}
需要在后面加上?human&pretty
或者直接在后面加上?pretty:
[root@master ~]# curl -XGET localhost:9200/_cluster/health?pretty
{
"cluster_name" : "estest",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 3,
"number_of_data_nodes" : 3,
"active_primary_shards" : 5,
"active_shards" : 10,
"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
}
ELK之elasticsearch6.5的更多相关文章
- centos6.10搭建ELK之elasticsearch6.5.4
1.环境准备 1.1.安装java环境版本不要低于java8 # java -version java version "1.8.0_191" Java(TM) SE Runtim ...
- ELK之elasticsearch6安装认证模块search guard
参考:https://www.cnblogs.com/marility/p/9392645.html 1,安装环境及软件版本 程序 版本 安装方式 elasticsearch 6.3.1 rpm ...
- ELK(Elasticsearch6.0以上版本head插件安装)
参考:https://www.cnblogs.com/Onlywjy/p/Elasticsearch.html Elasticsearch6.0不能使用命令直接安装head插件 修改配置文件/etc/ ...
- ELK之elasticsearch6.5集群
前面介绍并初试了es6.5系列的单节点的操作,现在搭建es6.5系列的集群: 环境:三节点:master-172.16.23.128.node1-172.16.23.129.node2-172.16. ...
- ELK+filebeat、kafka、zookeeper搭建文档
系统:centos 6.5 JDK:1.8 Elasticsearch-6.0.0Logstash-6.0.0kibana-6.0.0zookeeper-3.5.3kafka_2.12-1.0.0fi ...
- ELK Stack 笔记
ELK Stack ELK Stack ELK Stack ELK 介绍 架构 Elasticsearch 安装 常见问题 关闭 Elasticsearch Elasticsearch-head Ki ...
- ELK测试安装
https://blog.csdn.net/guyan0319/article/details/78749639 https://www.cnblogs.com/frankdeng/p/9139035 ...
- ELK(使用RPM包安装配置ELK)
1,安装环境查看 2,下载rmp包 下载地址:https://www.elastic.co/cn/downloads 分别下载最新rmp包 elasticsearch-6.2.4.rpm logsta ...
- 从零开始搭建系统2.2——ELK安装及配置
ELK 最新版本对JDK的最低要求是1.8,安装java_1.8版本 一.Elasticsearch 1.创建目录 2.下载安装包 wget https://artifacts.elastic.co/ ...
随机推荐
- POJ 2240 - Arbitrage - [bellman-ford求最短路]
Time Limit: 1000MS Memory Limit: 65536K Description Arbitrage is the use of discrepancies in currenc ...
- python中super的使用方法
说白了,super的使用就是要子类要调用父类的方法,我们就用super,那你要有调用的规范,我们明白这个规范就可以了. 在python2和python3中,调用方法不同,注意就是了.Python3.x ...
- Qt 事件系统浅析 (用 Windows API 描述,分析了QCoreApplication::exec()和QEventLoop::exec的源码)(比起新号槽,事件机制是更高级的抽象,拥有更多特性,比如 accept/ignore,filter,还是实现状态机等高级 API 的基础)
事件系统在 Qt 中扮演了十分重要的角色,不仅 GUI 的方方面面需要使用到事件系统,Signals/Slots 技术也离不开事件系统(多线程间).我们本文中暂且不描述 GUI 中的一些特殊情况,来说 ...
- B. Berland National Library---cf567B(set|模拟)
题目链接:http://codeforces.com/problemset/problem/567/B 题意:题目大意: 一个计数器, +号代表一个人进入图书馆, -号代表一个人出去图书馆. 给一个 ...
- Eclipse+Pydev 搭建开发环境(转)
add by zhj: 对原文略有修改 原文:http://www.cnblogs.com/TankXiao/archive/2013/05/29/3033640.html C#之所以容易让人感兴趣, ...
- java NIO (二) 一个故事讲清楚NIO
假设某银行只有10个职员.该银行的业务流程分为以下4个步骤: 1) 顾客填申请表(5分钟): 2) 职员审核(1分钟): 3) 职员叫保安去金库取钱(3分钟): 4) 职员打印票据,并将钱和票据返回给 ...
- if判断代码 转变为 流程图
转换规则如下: if 代表一个菱形+问号 if后面的条件代表菱形里的内容+↓yes(向下箭头和yes) if同级的else代表右拐向下箭头和no 执行语句块代表一个矩形. if 今天发工资: 先还信用 ...
- 使用pssh进行并行批量操作
假如同时给上千台服务器执行一个命令,拷贝一个文件,杀一个进程等,有什么简化运维管理的工具呢?在小型使用中我都是使用for循 环,数量巨大,一方面不确定操作是否成功,一方面for循环语句性能不好估计且是 ...
- 使用gunicorn部署Flask项目
[*] 本文出处:http://b1u3buf4.xyz/ [*] 本文作者:B1u3Buf4 [*] 本文授权:禁止转载 从自己的博客移动过来. gunicorn是一个python Wsgi的WEB ...
- C#读取Excel,Access数据库
出自:http://blog.csdn.net/limpire/article/details/2599760 使用 OpenRowSet 和 OpenDataSource 访问 Excel 97-2 ...