ES项目实战
前置
ES: Java
Spark/Flink Stack + Spring Boot + ES
Scala/Java + Java/Scala + Java
==> 用API的方式来掌握ES的用法(API、SpringBoot的使用)
ES: API RESTFul
ElasticSearch + Kibana
存储 展示/分析
ES Plugin: Head SQL Kibana (三个插件,Kibana也算插件)
最终数据要到SQL (易用性)
ES的安装
地址: https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.6.2.tar.gz


- 解压: tar -zxvf elasticsearch-6.6.2.tar.gz -C ~/app/
- 配置到系统环境变量:
- 修改:
cd elasticsearch-6.6.2
删除bin目录中以bat结尾的命令(windows中的,无用)
$ES_HOME (重要的文件)
bin
elasticsearch 启动ES
elasticsearch 前台方法启动
elasticsearch -d 后台方法启动 (需要打开日志查看系统输出信息)
elasticsearch-plugin 管理ES插件
elasticsearch-sql-cli sql客户端
config
elasticsearch.yml es的配置信息
#cluster.name: my-application (集群名称)
#node.name: node-1 (节点名称)
#path.data: /path/to/data
Path to log files:
path.logs: /path/to/logs
#network.host: 0.0.0.0 (全网)
Set a custom port for HTTP:
http.port: 9200
jvm.optiom es的JVM相关的配置信息
## the heap to 4 GB, set:
##
## -Xms4g
## -Xmx4g
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
-Xms1g
-Xmx1g
## GC configuration
-XX:+UseConcMarkSweepGC
-XX:CMSInitiatingOccupancyFraction=75
-XX:+UseCMSInitiatingOccupancyOnly
# explicitly set the stack size
-Xss1m
# specify an alternative path for heap dumps; ensure the directory exists and
# has sufficient space
-XX:HeapDumpPath=data
# specify an alternative path for JVM fatal error logs
-XX:ErrorFile=logs/hs_err_pid%p.log
# ----------------------------------- Memory -----------------------------------
elasticsearch-migrate x-pack-env
8:-XX:+PrintGCApplicationStoppedTime
8:-Xloggc:logs/gc.log
8:-XX:+UseGCLogFileRotation
8:-XX:NumberOfGCLogFiles=32
8:-XX:GCLogFileSize=64m
***注:ES对硬盘要求极高(一般SSD、内存大) ***
后台启动ES: elasticsearch -d
去Web UI查看: hadoop000:9200 (Web UI port)
hadoop000:9300 服务器端口(server port)
Lucene_version: "7.6.0" 不对应
技巧:用chrome中的json字符串美化插件 (JSON Formatter)
ES核心概念
Cluster
Node
Index Database
Type Table
Document Row
Field Column //这四种的REST API在工作中用的最多
shard(分片--分区集叫分片)
replica(副本)
对应关系:
Index -> Type -> Document -> Field
Database -> Table -> Row -> Column
代码开发
需要: IDEA+Maven+Java
pom.xml
<!--添加elasticsearch依赖-->
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>6.6.2</version>
</dependency>
<!--添加junit依赖(默认已有)-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<!--<scope>test</scope>(去掉这块),需要重新导入依赖-->
</dependency>
PreBuiltTransportClient.java
/**
* Creates a new transport client with pre-installed plugins.
*
* @param settings the settings passed to this transport client
* @param plugins an optional array of additional plugins to run with this client
*/
@SafeVarargs
public PreBuiltTransportClient(Settings settings, Class<? extends Plugin>... plugins) {
this(settings, Arrays.asList(plugins));
}
//Class<? extends Plugin>...
// ...代表一个/多个可变参数, 可填可不填
TransportClient.java
/**
* Adds a transport address that will be used to connect to.
* <p>
* The Node this transport address represents will be used if its possible to connect to it.
* If it is unavailable, it will be automatically connected to once it is up.
* <p>
* In order to get the list of all the current connected nodes, please see {@link #connectedNodes()}.
*/
public TransportClient addTransportAddress(TransportAddress transportAddress) {
nodesService.addTransportAddresses(transportAddress);
return this;
}
ES项目实战的更多相关文章
- Elasticsearch.net项目实战
elasticsearch.net项目实战 目录 Elasticsearch+kibana 环境搭建 windows 10环境配置 安装Elasticsearch head安装(非必需) 安装kiba ...
- ELKStack-生产案例项目实战(十一)
ELKStack-生产案例项目实战 1.收集ES和apache日志,入redis input { file { path => "/etc/httpd/logs/access_log& ...
- [elk]logstash的最佳实战-项目实战
重点参考: http://blog.csdn.net/qq1032355091/article/details/52953837 不得不说这是一个伟大的项目实战,是正式踏入logstash门槛的捷径 ...
- SpringBoot电商项目实战 — ElasticSearch接入实现
如今在一些中大型网站中,搜索引擎已是必不可少的内容了.首先我们看看搜索引擎到底是什么呢?搜索引擎,就是根据用户需求与一定算法,运用特定策略从互联网检索出制定信息反馈给用户的一门检索技术.搜索引擎依托于 ...
- 海量数据MySQL项目实战
主要内容包含 MySQL 典型数据库架构介绍.MySQL 主流数据库架构对比等理论性知识,然后从“订单.用户”两个项目实战,抛砖引玉,介绍亿级互联网业务数据库项目如何设计. MySQL 典型数据库架构 ...
- Java 18套JAVA企业级大型项目实战分布式架构高并发高可用微服务电商项目实战架构
Java 开发环境:idea https://www.jianshu.com/p/7a824fea1ce7 从无到有构建大型电商微服务架构三个阶段SpringBoot+SpringCloud+Solr ...
- 从 0 使用 SpringBoot MyBatis MySQL Redis Elasticsearch打造企业级 RESTful API 项目实战
大家好!这是一门付费视频课程.新课优惠价 699 元,折合每小时 9 元左右,需要朋友的联系爱学啊客服 QQ:3469271680:我们每课程是明码标价的,因为如果售价为现在的 2 倍,然后打 5 折 ...
- Asp.Net Core 项目实战之权限管理系统(4) 依赖注入、仓储、服务的多项目分层实现
0 Asp.Net Core 项目实战之权限管理系统(0) 无中生有 1 Asp.Net Core 项目实战之权限管理系统(1) 使用AdminLTE搭建前端 2 Asp.Net Core 项目实战之 ...
- 给缺少Python项目实战经验的人
我们在学习过程中最容易犯的一个错误就是:看的多动手的少,特别是对于一些项目的开发学习就更少了! 没有一个完整的项目开发过程,是不会对整个开发流程以及理论知识有牢固的认知的,对于怎样将所学的理论知识应用 ...
随机推荐
- python爬虫中文乱码问题(request方式爬取)
https://blog.csdn.net/guoxinian/article/details/83047746 req = requests.get(url)返回的是类对象 其包括的属性有: r ...
- Linux 内存文件系统-ramfs and tmpfs
Linux内存文件系统:可满足高IO的要求 ramdisk: 基于虚拟在内存中的其他文件系统(ex2fs). 挂载方式:mount /dev/ram /mnt/ramdisk ramfs: 物理内存文 ...
- fastdfs-nginx-module安装和配置
fastdfs-nginx-module安装和配置 为什么要在fastdfs的storage端,安装fastdfs-nginx-module? 答案:https://www.cnblogs.com/l ...
- AtCoder - 2140 (思维)
题意 https://vjudge.net/problem/AtCoder-2140 每次告诉你新的a:b,计算最后最小的a+b. 思路 如 3 2 3 1 1 3 2 先令a=2,b=3,发现新的为 ...
- 28.Java基础_抽象类
抽象类的成员特点 public abstract class Animal { private String name; private int age; public Animal() { } pu ...
- 【cf741】D. Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths(dsu on tree)
传送门 题意: 给出一颗以\(1\)为根的有根树,树边带有一个字符(\(a\)~\(v\))的信息. 输出对于每个结点,其子树内最长的简单路径并且满足边上的字符能够组成回文串. 思路: 显然最终的答案 ...
- Requests 详解
什么是Requests Requests是用Python语言编写,基于urllib,他比urllib更加方便,可以节约我们的大量工作,完全满足HTTP测试需求
- Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) A. Forgetting Things 水题
A. Forgetting Things Kolya is very absent-minded. Today his math teacher asked him to solve a simple ...
- Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) C. p-binary 水题
C. p-binary Vasya will fancy any number as long as it is an integer power of two. Petya, on the othe ...
- Windows安装RabbitMQ并设置数据存储目录
一.安装Elang 下载otp_win64_xx.x.exe,当前使用otp_win64_21.3.exe版本,按步骤完成安装. 下载地址:http://www.erlang.org/download ...