国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Centos 7 通過 targz 文件安裝 Elastic Search 服務(wù)

這篇具有很好參考價值的文章主要介紹了Centos 7 通過 targz 文件安裝 Elastic Search 服務(wù)。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

區(qū)別于通過發(fā)行版自帶的倉庫, 介紹如何通過 targz 文件安裝 Elastic Search 服務(wù), 使用的 Linux 為 Centos 7

下載

https://www.elastic.co/downloads/elasticsearch

選擇 Linux x86_64, 下載 elasticsearch-8.8.0-linux-x86_64.tar.gz

安裝

解壓到 /opt/elasticsearch, 并加上軟鏈

tar xvf elasticsearch-8.8.0-linux-x86_64.tar.gz 

cd /opt/
sudo mkdir elasticsearch
cd elasticsearch/
sudo mv ~/backup/elasticsearch-8.8.0 .
sudo chown -R milton:milton elasticsearch-8.8.0/
sudo ln -s elasticsearch-8.8.0 latest

這個版本的 Elastic Search 自帶 JVM, 版本為 openjdk version "20.0.1" 2023-04-18

配置

可能需要修改的配置

# Use a descriptive name for your cluster:
#cluster.name: my-application
# Use a descriptive name for the node:
node.name: centos7001
# Add custom attributes to the node:
#node.attr.rack: r1
# Path to directory where to store the data (separate multiple locations by comma):
path.data: /home/milton/es_run/data
# Path to log files:
path.logs: /home/milton/es_run/logs
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
network.host: 192.168.9.10
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#http.port: 9200
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#discovery.seed_hosts: ["centos7001"]
# Bootstrap the cluster using an initial set of master-eligible nodes:
cluster.initial_master_nodes: ["centos7001"]
# For more information, consult the discovery and cluster formation module documentation.
# Allow wildcard deletion of indices:
#action.destructive_requires_name: false
xpack.security.enabled: false
  • cluster.name: my-application 集群名稱
  • node.name 要改成當前服務(wù)器的hostname
  • path.data: /somew/data 數(shù)據(jù)路徑
  • path.logs: /somewhere/logs 日志路徑
  • network.host: 192.168.123.123 監(jiān)聽的網(wǎng)口, 默認只監(jiān)聽127.0.0.1
  • http.port: 9200 監(jiān)聽的端口, 默認為9200
  • discovery.seed_hosts: ["192.168.123.123"] 集群主機列表, 和下面的cluster.initial_master_nodes必須寫一個, 不然啟動會報錯. 如果只是單節(jié)點, 這行可以注釋掉
  • cluster.initial_master_nodes: ["centos7001"] 啟動時初始化的參與選主的node 對應(yīng)的 hostname, 要能解析為IP

node.name 和 cluster.initial_master_nodes, 可以填I(lǐng)P也可以填hostname, 但是要一致

系統(tǒng)配置

以下的配置用于解決下面的問題

  1. max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
  2. max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
  3. the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
  4. Transport SSL must be enabled if security is enabled. Please set [xpack.security.transport.ssl.enabled] to [true] or disable security by setting [xpack.security.enabled] to [false]

1. max file descriptors 65535

修改/etc/security/limits.conf (或者 /etc/security/limits.d/20-nproc.conf), 增加或修改為以下內(nèi)容

*          soft    nofile    65535
*          hard    nofile    65535
*          soft    nproc     65535
*          hard    nproc     65535
root       soft    nproc     unlimited

需要重啟, 用 ulimit -n 檢查

2. vm.max_map_count 262144

修改/etc/sysctl.conf 或者 /etc/sysctl.d/99-sysctl.conf文件,增加或修改為以下內(nèi)容

vm.max_map_count=262144

3. the default discovery settings are unsuitable for production use

需要配置 discovery.seed_hosts,discovery.seed_providers,cluster.initial_master_nodes中的至少一個參數(shù)

  • discovery.seed_hosts: 集群主機列表
  • discovery.seed_providers: 基于配置文件配置集群主機列表
  • cluster.initial_master_nodes: 啟動時初始化的參與選主的node

修改配置文件 config/elasticsearch.yml, 配置以下兩項

discovery.seed_hosts: ["127.0.0.1"]
cluster.initial_master_nodes: ["node-1"]

4. Transport SSL must be enabled if security is enabled

修改配置文件 config/elasticsearch.yml, 增加

xpack.security.enabled: false

5. WARN: This node is a fully-formed single-node cluster

如果在日志中看到類似這樣的錯誤

[2023-06-09T07:29:43,781][WARN ][o.e.c.c.Coordinator      ] [centos7001] This node is a fully-formed single-node cluster with cluster UUID [6ejfGD71SVe6OpypK-1HmA], but it is configured as if to discover other nodes and form a multi-node cluster via the [discovery.seed_hosts=[192.168.123.123]] setting. Fully-formed clusters do not attempt to discover other nodes, and nodes with different cluster UUIDs cannot belong to the same cluster. The cluster UUID persists across restarts and can only be changed by deleting the contents of the node's data path(s). Remove the discovery configuration to suppress this message.

說明這是一個單節(jié)點的ES, 但是配置文件中配置其去發(fā)現(xiàn)另一個節(jié)點. 需要將 discovery.seed_hosts 中設(shè)置的節(jié)點去掉

運行

直接運行, 這樣會將日志直接輸出到控制臺

/opt/elasticsearch/latest/bin/elasticsearch

后臺運行, 在命令后加 -d -p pid-file, 在輸出一段控制臺日志后, 如果沒有報錯, 會轉(zhuǎn)入后臺運行

/opt/elasticsearch/latest/bin/elasticsearch -d -p /opt/elasticsearch/latest/logs/pid

停止

根據(jù)記錄的 pid 停止, 啟動時記錄用的哪個文件, 這里就用對應(yīng)的文件

pkill -F /opt/elasticsearch/latest/logs/pid

使用

ES與關(guān)系型數(shù)據(jù)庫的名詞對應(yīng)關(guān)系
Centos 7 通過 targz 文件安裝 Elastic Search 服務(wù)

服務(wù)檢查

瀏覽器打開 http://192.168.123.123:9200/ 能看到ES的輸出, 就說明運行成功

{
  "name" : "centos70",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "_na_",
  "version" : {
    "number" : "8.8.0",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "c01029875a091076ed42cdb3a41c10b1a9a5a22f",
    "build_date" : "2023-05-23T17:16:07.179039820Z",
    "build_snapshot" : false,
    "lucene_version" : "9.6.0",
    "minimum_wire_compatibility_version" : "7.17.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}

查詢集群運行狀況

curl -XGET "127.0.0.1:9200/_cat/health?v"

查詢集群所有索引

$ curl -XGET "192.168.123.123:9200/_cat/indices?v"
health status index        uuid                   pri rep docs.count docs.deleted store.size pri.store.size
yellow open   commodity002 XIrCTL_XQq2vteuEflY6vA   1   1          0            0       247b           247b
yellow open   commodity001 Z-LKjzsuR8uMLgVlYYALEw   1   1          0            0       247b           247b
yellow open   commodity004 sSxEiwNBSvernMH6EYsEvw   1   1          0            0       247b           247b
yellow open   commodity003 JSRUndkHQ8mQVdTkN9eCPw   1   1          0            0       247b           247b

按記錄數(shù)量排序, 字段可以從上面結(jié)果的表頭中取

curl -XGET "127.0.0.1:9200/_cat/indices?v&s=docs.count"

按存儲空間排序

curl -XGET "127.0.0.1:9200/_cat/indices?v&s=store.size"

創(chuàng)建索引

不帶參數(shù), ?pretty用于格式化響應(yīng)的json

curl -X PUT "localhost:9200/commodity?pretty"

帶參數(shù)

curl -H 'Content-Type: application/json' -X PUT 'http://192.168.123.123:9200/commodity007?pretty' \
--data '{
    "settings": {
        "number_of_shards": 3,
        "number_of_replicas": 2
    }
}'

帶索引字段,

curl -H 'Content-Type: application/json' -X PUT 'http://192.168.123.123:9200/commodity008?pretty' \
--data '{
  "settings": {
    "number_of_shards": 2,
    "number_of_replicas": 1
  },
  "mappings": {
    "properties": {
      "name":{
        "type": "text"
      },
      "studymodel":{
        "type": "keyword"
      },
      "price":{
        "type": "double"
      },
      "timestamp": {
         "type": "date",
         "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
      },
      "pic":{
        "type":"text",
        "index": false
      }
    }
  }
}'

對于嵌套存在的字段, mappings是可以用層級的, 例如對 type1下的obj1的索引

{
  "mappings": {
    "type1": {
      "properties": {
        "obj1": {
          "type": "nested"
        }
      }
    }
  }
}

查看索引字段及設(shè)置

curl -X GET 'http://192.168.123.123:9200/commodity008?pretty'

往索引寫入內(nèi)容

通過路徑指定 _id = 1, 對同一個 _id可以再次調(diào)用進行更新, 結(jié)果中的_version會遞增

curl --location --request PUT 'http://192.168.123.123:9200/commodity008/_doc/1?pretty' \
--header 'Content-Type: application/json' \
--data '{
    "name": "commodity008001",
    "studymodel": "202306",
    "price": 123.12,
    "timestamp": "2023-05-25 19:11:35",
    "pic": "23/06/01/a123b1fde0428.jpg"
}'

查詢

可以通過URL路徑區(qū)分不同索引

  • /_search 所有索引
  • /commodity008/_search commodity008索引
  • /commodity007,commodity008/_search commodity007 和 commodity008
  • /commodity*/_search 以 commodity 開頭的索引

查詢所有索引下的內(nèi)容

curl -X GET 'http://192.168.123.123:9200/_search?pretty'

查詢一個索引下的內(nèi)容

curl -X GET 'http://192.168.123.123:9200/commodity008/_search?pretty'

帶條件查詢

curl -H 'Content-Type: application/json' -X GET 'http://192.168.9.10:9200/commodity008/_search?pretty=null' \
--data '{
    "query" : {
        "match" : {
            "name": "commodity008001"
        }
    }
}'

帶偏移和結(jié)果數(shù)量, 請求加上 from 和 size 參數(shù)

{
  "from":10,
  "size":20,
  "query":{
    "match_all": {}
  }
}

排序, 請求加上 sort 參數(shù)

{
  "sort":[{"year":"desc"}],
  "query":{
    "match_all": {}
  }
}

限制返回的字段, 請求加上 _source 字段文章來源地址http://www.zghlxwxcb.cn/news/detail-475856.html

{
  "_source":["title"],
  "query":{
    "match_all": {}
  }
}

結(jié)果格式

{
    "took": 422,
    "timed_out": false,
    "_shards": {
        "total": 2,
        "successful": 2,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": {
            "value": 2,
            "relation": "eq"
        },
        "max_score": 1.0,
        "hits": [
            {
                "_index": "commodity008",
                "_id": "1",
                "_score": 1.0,
                "_source": {
                    "name": "commodity008001",
                    "studymodel": "202307",
                    "price": 123.53,
                    "timestamp": "2023-05-25 19:11:35",
                    "pic": "23/06/01/a123b1fde0428.jpg"
                }
            },
            ...
        ]
    }
}

參考

  • 通過 targz 安裝 Elastic Search https://www.elastic.co/guide/en/elasticsearch/reference/current/targz.html

到了這里,關(guān)于Centos 7 通過 targz 文件安裝 Elastic Search 服務(wù)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • 客快物流大數(shù)據(jù)項目(一百零四):為什么選擇Elastic Search作為存儲服務(wù)

    客快物流大數(shù)據(jù)項目(一百零四):為什么選擇Elastic Search作為存儲服務(wù)

    文章目錄 為什么選擇Elastic Search作為存儲服務(wù) 一、??????????????ElasticSearch簡介

    2023年04月11日
    瀏覽(24)
  • 【elastic search】JAVA操作elastic search

    【elastic search】JAVA操作elastic search

    目錄 1.環(huán)境準備 2.ES JAVA API 3.Spring Boot操作ES 本文是作者ES系列的第三篇文章,關(guān)于ES的核心概念移步: https://bugman.blog.csdn.net/article/details/135342256?spm=1001.2014.3001.5502 關(guān)于ES的下載安裝教程以及基本使用,移步: https://bugman.blog.csdn.net/article/details/135342256?spm=1001.2014.3001.5502 在前文

    2024年01月25日
    瀏覽(23)
  • Elastic Search一些用法

    Elastic Search一些用法

    參考: 中國開源社區(qū) 官方介紹 ES 的權(quán)重排序 【Elasticsearch】ElasticSearch 7.8 多字段權(quán)重排序 ElasticSearch7.3學(xué)習(xí)(十三)----定制動態(tài)映射(dynamic mapping) 【Elasticsearch教程4】Mapping 動態(tài)映射 【Elasticsearch教程5】Mapping 動態(tài)模板 Dynamic templates 注意事項:需要先創(chuàng)建模板,然后添加數(shù)據(jù)

    2024年02月06日
    瀏覽(19)
  • elastic search入門

    elastic search入門

    參考1:Elastic Search 入門 - 知乎 參考2:Ubuntu上安裝ElasticSearch_ubuntu elasticsearch-CSDN博客 1、ElasticSearch安裝 1.1安裝JDK,省略,之前已安裝過 1.2創(chuàng)建ES用戶 1.3?下載ElasticSearch安裝包 Ubuntu上下載: 然后解壓: 1.4配置 配置jvm.options 配置elasticsearch.yml: 根據(jù)以上設(shè)置的path.data和path.l

    2024年01月23日
    瀏覽(15)
  • SpringCloud整合Elastic Search

    1、配置Elastic Search 注釋說明: spring.elasticsearch.rest.uris :設(shè)置Elastic Search的連接地址,這里的示例是本地地址 http://localhost:9200 ,根據(jù)實際情況修改。 spring.elasticsearch.username 和 spring.elasticsearch.password :設(shè)置Elastic Search的用戶名和密碼,如果沒有設(shè)置訪問控制,這兩項可以省略

    2024年02月15日
    瀏覽(12)
  • Elastic Search 命令詳解-索引操作

    Elastic Search 命令詳解-索引操作

    關(guān)于Elastic Search安裝可以參考《Elastic Search 8.6.2集群安裝部署》及Kibana安裝可以參考《Elastic Search 8.6.2簡單操作》。相關(guān)命令將在Kibana工具的Console平臺上執(zhí)行。 Elastic Search索引操作主要包含:創(chuàng)建、刪除、關(guān)閉和打開索引,以及索引別名的操作。其中,索引別名的操作在生產(chǎn)環(huán)

    2024年02月08日
    瀏覽(18)
  • 【搜索引擎】elastic search核心概念

    【搜索引擎】elastic search核心概念

    前言 本文不涉及ES的具體安裝下載、操作、集群的內(nèi)容,這部分內(nèi)容會放在后面一篇文章中。本文只包含ES的核心理論,看完本文再去學(xué)ES的細節(jié)會事半功倍。 目錄 1.由日志存儲引出的問題 2.什么是ES? 3.ES的數(shù)據(jù)結(jié)構(gòu) 4.ES的核心原理 5.聯(lián)系作者 本文或者說本系列的來源: 前面

    2024年02月03日
    瀏覽(17)
  • Elastic Search的RestFul API入門:如何進行ES的查詢-search

    在這篇教學(xué)文章中,我們將深入探討Elasticsearch的search功能。這是一個非常強大且靈活的功能,它允許我們對存儲在Elasticsearch中的數(shù)據(jù)進行各種復(fù)雜的查詢和分析。本章的目標是讓讀者理解如何進行Elasticsearch的搜索,以及如何在搜索過程中自主調(diào)整搜索參數(shù),從而靈活地控制

    2024年02月03日
    瀏覽(27)
  • centos通過源文件的方式安裝node-red

    centos通過源文件的方式安裝node-red

    [回到目錄] ?查看你的Linux系統(tǒng)是32位還是64位的,不要搞錯版本了。執(zhí)行命令: cat /proc/version ?下載地址:【https://npm.taobao.org/mirrors/node/】 ?選擇合適的版本下載: 記住查看你的Linux系統(tǒng)是32位還是64位的,不要搞錯版本了。一般x86_64是64位,x86是32位的。 我的服務(wù)器是64位的

    2024年02月11日
    瀏覽(26)
  • Springboot項目使用Elastic Search教程(完整步驟)

    Springboot項目使用Elastic Search教程(完整步驟)

    最近的項目需要用到Elastic Search,上網(wǎng)查資料的時候發(fā)現(xiàn)內(nèi)容比較分散,搜索起來的時候比較費力, 于是最近入門配置成功之后,稍微總結(jié)一下吧。 先給出一些網(wǎng)上的教程 (152條消息) Spring Boot整合Elasticsearch,最新最全教程_spring elasticsearch_Cloud-Future的博客-CSDN博客 這一篇代碼

    2024年02月07日
    瀏覽(21)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包