zoukankan      html  css  js  c++  java
  • 【ES】elasticsearch学习笔记

    ES学习
    1 优势
    1.1 简单
    1.1.1 相比Solor配置部署等非常简单
    1.2 高效
    1.2.1 ES使用Netty作为内部RPC框架,Solor使用Jetty
    1.3 插件化
    1.3.1 ES易扩展,编写插件即可
    1.4 Clients丰富
    1.4.1 Java、Python、Rest等各种客户端
    1.5 http://www.cnblogs.com/chowmin/articles/4629220.html
    1.6 架构
    1.6.1
    1.6.1.1
    1.7 基础视频
    1.7.1 https://www.douban.com/group/topic/94477155/
    1.8 深入视频
    1.8.1 http://www.roncoo.com/course/view/03b0916b225f4feb995586ab3e975c8f#boxTwo
    1.8.2 http://www.roncoo.com/course/view/f6c7d5f0eef34b20b280621e42facbcf
    1.9 ES中文文档
    1.9.1 https://www.elastic.co/guide/cn/elasticsearch/guide/current/index.html
    1.9.2 http://www.jianshu.com/p/2c7b0c76fa04
    1.9.3 https://github.com/dzharii/awesome-elasticsearch
    1.9.4 Subthttps://www.zhihu.com/topic/19899427/hotopic
    1.10 与SPark等技术对比
    1.10.1 https://www.zhihu.com/question/35214783
    1.10.2 https://www.zhihu.com/topic/19899427/hot
    1.10.3 https://www.zhihu.com/question/41109030
    1.10.4 https://www.zhihu.com/question/35351352
    1.10.5 https://github.com/chenryn/ELKstack-guide-cn/blob/master/SUMMARY.md
    1.10.6 http://www.weixinnu.com/tag/article/1542492037
    1.10.7 http://blog.csdn.net/u010022051/article/details/54342174
    1.10.8 https://www.ibm.com/developerworks/cn/analytics/library/ba-1512-elkstack-logprocessing/index.html
    2 核心概念
    2.1 准实时、集群、节点
    2.2 Index索引-DB、Type类型-Table、Document文档-Row-JSON
    2.3 Shard分片、Replicas多副本
    2.3.1 http://www.cnblogs.com/huangfox/p/3543351.html
    2.3.2 分片数量索引创建之前指定,指定之后不可修改
    2.3.2.1 文档存储到分片可以指定路由方法
    2.3.3 多副本既可以容灾备份,也可以负载均衡提高查询效率
    2.4 recovery再分配
    2.4.1 集群增加删除节点会触发分片、副本的重新分配/数据平衡
    2.5 Gateway
    2.5.1 数据持久化方式
    2.5.2 es支持多种类型gateway,本地文件系统、分布式文件系统、HDFS、S3等各种持久化方式
    2.6 Transport
    2.6.1 内部节点交互协议可定制,默认TCP,可以定制为http、thrift等
    2.7 river
    2.7.1 数据迁移,支持Redis、MySQL、Kafka、Rabbit等
    2.8 beats
    2.8.1 收据收集器-文件、监控数据等
    2.9 辅助组件
    2.9.1 防数据丢失、提高性能
    2.9.2 shipper-->haproxy-->logstash-->redis/kafka-->logstash-->nginx-->es-->kibana
    2.9.3 Master节点与DataNode分离
    2.9.4 logstash、nginx参数调优,线程数、批量操作、吞吐率提高等方面rushou
    2.9.5 推荐文章
    2.9.5.1 http://www.jianshu.com/p/fa31f38d241e
    2.9.5.2 https://zhuanlan.zhihu.com/p/22604199
    3 部署
    3.1 JDK
    3.1.1 http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
    3.2 版本5.6
    3.2.1 https://www.elastic.co/guide/en/elasticsearch/reference/5.6/index.html
    3.2.2 https://www.elastic.co/downloads
    3.2.3 新版本优势何在?
    3.2.3.1 http://weishiym.iteye.com/blog/2313992
    3.3 启动问题
    3.3.1 参考资料
    3.3.1.1 http://blog.csdn.net/wang_zhenwei/article/details/53785048
    3.3.1.2 http://blog.csdn.net/dream_flying_bj/article/details/67632448
    3.3.1.3 http://blog.csdn.net/feifantiyan/article/details/54614614
    3.3.2 unable to install syscall filter
    3.3.2.1 升级内核
    3.3.3 资源限制问题
    3.3.3.1 文件描述符问题 &线程数限制问题
    3.3.3.1.1 http://linux.vbird.org/linux_basic/0320bash.php#variable_ulimit
    3.3.3.1.2 http://blog.csdn.net/jk0803_wantao/article/details/18614447
    3.3.3.1.3 vi /etc/security/limits.conf
    3.3.3.1.3.1 * soft nofile 65536 * hard nofile 131072 * soft nproc 2048 * hard nproc 4096 * soft memlock unlimited * hard memlock unlimited
    3.3.3.2 线程数限制问题
    3.3.3.2.1 vi /etc/security/limits.d/90-nproc.conf
    3.3.3.2.1.1 * soft nproc 1024 #修改为 * soft nproc 2048
    3.3.3.3 虚拟地址空间
    3.3.3.3.1 vi /etc/sysctl.conf
    3.3.3.3.1.1 vm.max_map_count=655360 sysctl -p
    3.4 ansible部署ES参考
    3.4.1 https://gitee.com/jiemo/ansible-elasticsearch/
    3.4.2 https://www.digitalocean.com/community/tutorials/how-to-use-ansible-to-set-up-a-production-elasticsearch-cluster
    3.4.3 https://github.com/thisismitch/ansible-tinc-elasticsearch-example
    3.4.4 性能优化参数配置
    3.4.4.1 http://zhaoyanblog.com/archives/826.html
    3.4.4.2 http://www.bigdata1024.com/?p=109
    3.4.4.3 http://1358440610-qq-com.iteye.com/blog/2336072
    3.4.4.4 http://www.infoq.com/cn/news/2017/01/ElasticSearch-9
    3.4.4.5 https://zhidao.baidu.com/question/691603793297721724.html
    3.4.5 脑裂问题
    3.4.5.1 https://zhidao.baidu.com/question/433342225658620604.html
    3.4.5.2 http://blog.csdn.net/a19860903/article/details/72467996
    3.4.6 Gateway Recover缓慢问题
    3.4.6.1 http://blog.csdn.net/asia_kobe/article/details/51453034
    3.5 集群部署
    3.5.1 主机规划
    3.5.1.1 10.20.0.11 node-01 10.20.0.12 node-02 10.20.0.13 node-03 10.20.0.14 node-04
    3.6 基本操作
    3.6.1 详见: README
    3.6.2 如何支持JOIN
    3.6.2.1 https://stackoverflow.com/questions/22611049/join-query-in-elasticsearch
    3.6.2.2 https://segmentfault.com/a/1190000004468130
    3.6.3 ElasticSearch提供了易用但功能强大的RESTful API以用于与集群进行交互,这些API大体可分为如下四类: (1)检查集群、节点、索引等健康与否,以及获取其相关状态与统计信息; (2)管理集群、节点、索引数据及元数据; (3)执行CRUD操作及搜索操作; (4)执行高级搜索操作,例如paging、filtering、scripting、faceting、aggregations及其它操作;
    3.6.4 文档中,域的数据存储时支持“string”、“numbers”、“Booleans”和“dates”几种类型,不同类型的数据在索引时是略有区别的。 在创建文档时,Elasticsearch会通过检查域的值来动态为其创建mapping,可通过Mapping API来查看type的mapping,其访问端点是_mapping。
    3.7 安装head插件
    3.7.1 wget -O- https://raw.githubusercontent.com/aliyun-node/tnvm/master/install.sh | bash source ~/.bashrc tnvm install node-v8.6.0 tnvm use node-v8.6.0 tnvm current # 设置淘宝npm源 npm config set registry https://registry.npm.taobao.org --global npm config set disturl https://npm.taobao.org/dist --global vi ~/.npmrc registry = https://registry.npm.taobao.org disturl = https://npm.taobao.org/dist echo "registry = https://registry.npm.taobao.org > disturl = https://npm.taobao.org/dist > " >> ~/.npmrc # 验证设置成功 npm config get registry npm config get disturl sudo yum install zip unzip -y # https://github.com/mobz/elasticsearch-head unzip elasticsearch-head-1.x.zip cd elasticsearch-head-1.x 修改Gruntfile.js启动hostname npm install # npm install -g grunt-cli # grunt server npm run start # nohup npm run start >/dev/null 2>&1 &
    3.7.1.1
    3.8 安装Kibana
    3.8.1 vi config/kibana.yml #server.host: "localhost" #elasticsearch.url: "http://localhost:9200" bin/kibana # nohup bin/kibana >/dev/null 2>&1 &
    4 视频资料
    4.1 https://www.douban.com/group/topic/94477155/
    4.1.1 偏重实践
    4.2 http://www.roncoo.com/course/view/03b0916b225f4feb995586ab3e975c8f
    4.2.1 偏重核心原理
    4.3 内部原理剖析
    4.3.1 http://blog.csdn.net/zlh3955649/article/details/53169617
    5 分词器
    5.1 IK分词器
    5.1.1 https://github.com/medcl/elasticsearch-analysis-ik
    5.1.2 ES自带标准分词器对中文支持不友好,IK支持智能切词
    5.1.3 ik_max_word:会将文本做最细粒度的拆分,比如会将“中华人民共和国国歌”拆分为“中华人民共和国,中华人民, 中华,华人,人民共和国,人民,人,民,共和国,共和,和,国国,国歌”,会穷尽各种可能的组合; ik_smart: 会做最粗粒度的拆分,比如会将“中华人民共和国国歌”拆分为“中华人民共和国,国歌”。
    6 mapping
    6.1 数据类型定义
    6.1.1 示例
    6.1.1.1
    6.1.2 可以像mysql一样修改吗
    6.2 新建文档
    6.2.1
    7 客户端
    7.1 Java客户端
    7.1.1 太麻烦
    7.1.2 与spring、springdata、springboot等整合
    7.1.3 与Netty、gRPC、Thrift等整合,提供RPC接口
    7.2 Rest客户端
    7.2.1 推荐方式、更加灵活
    8 生产环境部署建议
    8.1 硬件
    8.1.1 内存
    8.1.1.1 64G左右
    8.1.2 CPU
    8.1.2.1 多核
    8.1.3 硬盘
    8.1.3.1 RAID0,即不需要RAID级别的数据冗余
    8.1.3.2 SSD,IO调度程序更改,显著影响性能
    8.1.4 网络
    8.1.4.1 不要跨数据中心,不要搞NAS之类存储
    8.1.5 机器
    8.1.5.1 中高配机器,而不是很多小机器
    8.2 JVM
    8.2.1 最新版本JVM,Java8
    8.2.2 不要调整默认的JVM配置
    8.3 有用配置
    8.3.1 集群、节点名字
    8.3.2 日志、数据路径
    8.3.3 最小节点数防止脑裂
    8.3.4 集群恢复最小节点数、等待时间防止频繁数据平衡
    8.3.5 单播代替组播
    8.3.6 不要修改垃圾回收器、不要修改线程数
    8.3.7 设置堆内存为系统内存的一半,并设置Xms、Xmx一致,不要超过32G,可以调试得到最佳内存临界值, 不要使用内存交换: bootstrap.mlockall: true
    8.3.8 文件描述符设置,MMap设置等
    8.3.9 ES提高插入速度
    8.3.9.1 https://www.zhihu.com/question/44976788
    8.4 部署之后
    8.4.1 监控健康状态、任务状态等信息
    8.4.2 日志
    8.4.2.1 慢日志记录
    8.4.3 https://www.elastic.co/guide/cn/elasticsearch/guide/current/indexing-performance.html
    8.4.4 批量请求
     
     
  • 相关阅读:
    java1200_060_把数字格式化为货币字符串
    ccf_201712-02
    ccf_201712-01
    算法笔记-----单源最短路径之Bellman-Ford算法
    算法笔记-----贪心算法----加里比海盗船--最优装载问题
    算法笔记-----最优二叉搜索树
    SHTSC2017酱油记
    并不能来一发50AC
    【bzoj4514】: [Sdoi2016]数字配对 图论-费用流
    【bzoj1066】: [SCOI2007]蜥蜴 图论-最大流
  • 原文地址:https://www.cnblogs.com/junneyang/p/7659753.html
Copyright © 2011-2022 走看看