Elasticsearch 安装笔记

2 篇文章 0 订阅
2 篇文章 0 订阅

官方安装文档

采用RPM包安装方式

[visitor@localhost ~]$ yum list elasticsearch

已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.tuna.tsinghua.edu.cn
 * epel: mirrors.yun-idc.com
 * extras: mirrors.tuna.tsinghua.edu.cn
 * updates: mirrors.tuna.tsinghua.edu.cn
错误:没有匹配的软件包可以列出

[visitor@localhost ~]$ sudo vim /etc/yum.repos.d/elasticsearch.repo

[elasticsearch-6.x]
name=Elasticsearch repository for 6.x packages
baseurl=https://artifacts.elastic.co/packages/6.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

[visitor@localhost ~]$ yum list elasticsearch

可安装的软件包
elasticsearch.noarch                                                     6.7.2-1                                                     logstash-6.x

[visitor@localhost ~]$ sudo yum -y install elasticsearch

已安装:
  elasticsearch.noarch 0:6.7.2-1                                                                                                                 

完毕!

安装指定版本,第一步下载特定版本RPM包,yum安装本地包:yum localinstall elasticsearch-6.7.1.rpm

[visitor@localhost ~]$ sudo vim /etc/profile

export PATH=$PATH:/usr/share/elasticsearch/bin

[visitor@localhost ~]$ source /etc/profile

[visitor@localhost ~]$ su

密码:

[root@localhost visitor]# elasticsearch -V

Version: 6.7.2, Build: default/rpm/56c6e48/2019-04-29T09:05:50.290371Z, JVM: 1.8.0_20

[root@localhost visitor]# elasticsearch-plugin -h

Commands
--------
list - Lists installed elasticsearch plugins
install - Install a plugin
remove - removes a plugin from Elasticsearch

Non-option arguments:
command              

Option         Description        
------         -----------        
-h, --help     show help          
-s, --silent   show minimal output
-v, --verbose  show verbose outpu

[root@localhost visitor]# elasticsearch-plugin list

(没有默认自带的安装插件)

[root@localhost visitor]# exit

[visitor@localhost ~]$ systemctl status elasticsearch

● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: http://www.elastic.co

elasticsearch不能用root启动

[visitor@localhost ~]$ sudo systemctl start elasticsearch

[sudo] password for visitor: 

[visitor@localhost ~]$ systemctl status elasticsearch

● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled)
   Active: active (running) since 二 2019-05-14 11:50:33 CST; 8s ago

移除--quiet参数,使得可查看日志

[visitor@localhost ~]$ sudo vim /usr/lib/systemd/system/elasticsearch.service

ExecStart=/usr/share/elasticsearch/bin/elasticsearch -p ${PID_DIR}/elasticsearch.pid

[visitor@localhost ~]$ sudo journalctl -f

[o.e.n.Node               ] [g93YnII] initialized

[o.e.n.Node               ] [g93YnII] starting ...

[o.e.t.TransportService   ] [g93YnII] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}

[o.e.h.n.Netty4HttpServerTransport] [g93YnII] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}

[o.e.n.Node               ] [g93YnII] started

[o.e.g.GatewayService     ] [g93YnII] recovered [0] indices into cluster_state

[visitor@localhost ~]$ sudo firewall-cmd --zone=public --add-port=9200/tcp --permanent

success

[visitor@localhost ~]$ sudo firewall-cmd --zone=public --add-port=9300/tcp --permanent

success

[visitor@localhost ~]$ sudo firewall-cmd --reload 

success

[visitor@localhost ~]$ sudo firewall-cmd --list-ports 

9200/tcp 3306/tcp 80/tcp  9300/tcp

外网地址访问放开

[visitor@localhost ~]$ sudo vim /etc/elasticsearch/elasticsearch.yml

# es7仅配置network.host会启动失败
#transport.host: 0.0.0.0
#transport.tcp.port: 9300
network.host: 0.0.0.0
#http.port: 9200
#discovery.seed_hosts: ["127.0.0.1", "[::1]"]

[visitor@localhost ~]$ sudo systemctl restart elasticsearch

外网访问

http://192.168.112.128:9200/

 # 客户端最低版本 >= 5.6.0
{
"name": "g93YnII",
"cluster_name": "elasticsearch",
"cluster_uuid": "Vcp9l3V5SSOUcvxd8-Mdgg",
"version": {
"number": "6.7.2",
"build_flavor": "default",
"build_type": "rpm",
"build_hash": "56c6e48",
"build_date": "2019-04-29T09:05:50.290371Z",
"build_snapshot": false,
"lucene_version": "7.7.0",
"minimum_wire_compatibility_version": "5.6.0",
"minimum_index_compatibility_version": "5.0.0"
},
"tagline": "You Know, for Search"
}

http://192.168.112.128:9200/_cluster/health

{
"cluster_name": "elasticsearch",
"status": "green",
"timed_out": false,
"number_of_nodes": 1,
"number_of_data_nodes": 1,
"active_primary_shards": 0,
"active_shards": 0,
"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
}

http://192.168.112.128:9200/_cat/nodes?v

ip              heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
192.168.112.128           30          96   1    0.14    0.12     0.13 mdi       *      g93YnII

http://192.168.112.128:9200/_cat/indices?v

health status index uuid pri rep docs.count docs.deleted store.size pri.store.size

[visitor@localhost ~]$ curl -XPUT 'localhost:9200/es_test?pretty'      # 新增索引

{
  "acknowledged" : true,
  "shards_acknowledged" : true,
  "index" : "es_test"
}

http://192.168.112.128:9200/_cat/indices?v

health status index   uuid                   pri rep docs.count docs.deleted store.size pri.store.size
yellow open   es_test 7MA4csctQf2EfAi_9npQZA   5   1          0            0       460b           460b

当elasticsearch的health为yellow时,使用下面的命名调整:

[visitor@localhost ~]$ curl -H "Content-Type: application/json" -XPUT 'http://localhost:9200/_settings' -d '
{
    "index" : {
        "number_of_replicas" : 0
    }
}'

{"acknowledged":true}

[visitor@localhost ~]$ curl -XGET 'localhost:9200/es_test/article/1?pretty'  # 查询记录

{
  "_index" : "es_test",
  "_type" : "article",
  "_id" : "1",
  "found" : false
}

[visitor@localhost ~]$ curl -XGET 'localhost:9200/es_test/_search'  # 查询所有数据

{"took": 411,"timed_out": false,"_shards": {"total": 1,"successful": 1,"skipped": 0,"failed": 0},"hits": {"total": {"value": 62,"relation": "eq"},"max_score": 1,"hits": []}}

查看字段类型

http://192.168.112.128:9200/es_test/_mappings?pretty=true 

[visitor@localhost ~]$ curl -XDELETE 'localhost:9200/es_test?pretty'   

{
  "acknowledged" : true
}

==============================================================================

Spring Data Elasticsearch 官方文档

==============================================================================

 安装中文分词拼音分词 

查看已安装插件:http://192.168.112.128:9200/_cat/plugins  #没有默认安装插件

注意:IK分词器的版本需要跟ES的版本一致才能安装成功。

[root@localhost visitor]# elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.7.1/elasticsearch-analysis-ik-6.7.1.zip

Continue with installation? [y/N]y
-> Installed analysis-ik

[root@localhost visitor]# elasticsearch-plugin list

analysis-ik

[root@localhost visitor]# elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-pinyin/releases/download/v6.7.1/elasticsearch-analysis-pinyin-6.7.1.zip

-> Downloading https://github.com/medcl/elasticsearch-analysis-pinyin/releases/download/v6.7.1/elasticsearch-analysis-pinyin-6.7.1.zip
[=================================================] 100%   
-> Installed analysis-pinyin

[root@localhost visitor]# elasticsearch-plugin list

analysis-ik
analysis-pinyin
 

配置内存

[visitor@localhost ~]$ sudo vim /etc/elasticsearch/jvm.options

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

-Xms500m
-Xmx500m
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
elasticsearch 学习笔记包括以下内容: 一、Elasticsearch概述: - Elasticsearch是一种开源的分布式搜索和分析引擎,可以用于快速搜索、分析和存储大量的结构化和非结构化数据。 - Elasticsearch与Solr相比有一些区别,包括用户、开发和贡献者社区的规模和成熟度等方面。 二、Elasticsearch安装: 1. 下载Elasticsearch,可以从官方网站或华为云镜像下载。 2. 安装Elasticsearch。 三、安装head插件: - head插件是一个可视化的管理界面,可以方便地管理和监控Elasticsearch集群。 四、安装Kibana: 1. Kibana是一个开源的数据可视化工具,用于展示和分析Elasticsearch中的数据。 2. 下载Kibana并安装。 3. 启动Kibana并进行访问测试。 4. 可选的汉化操作。 五、ES核心概念理解: - 学习ES的核心概念,包括索引、文档、映射、查询等。 以上是elasticsearch学习笔记的主要内容,希望对你有帮助。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [Elasticsearch 学习笔记(上)](https://blog.csdn.net/m0_52691962/article/details/127064350)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值