主頁 > 資料庫 > Centos 7 通過 targz 檔案安裝 Elastic Search 服務

Centos 7 通過 targz 檔案安裝 Elastic Search 服務

2023-06-09 08:19:56 資料庫

區別于通過發行版自帶的倉庫, 介紹如何通過 targz 檔案安裝 Elastic Search 服務, 使用的 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 要改成當前服務器的hostname
  • path.data: /somew/data 資料路徑
  • path.logs: /somewhere/logs 日志路徑
  • network.host: 192.168.123.123 監聽的網口, 默認只監聽127.0.0.1
  • http.port: 9200 監聽的埠, 默認為9200
  • discovery.seed_hosts: ["192.168.123.123"] 集群主機串列, 和下面的cluster.initial_master_nodes必須寫一個, 不然啟動會報錯. 如果只是單節點, 這行可以注釋掉
  • cluster.initial_master_nodes: ["centos7001"] 啟動時初始化的參與選主的node 對應的 hostname, 要能決議為IP

node.name 和 cluster.initial_master_nodes, 可以填IP也可以填hostname, 但是要一致

系統配置

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

  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), 增加或修改為以下內容

*          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檔案,增加或修改為以下內容

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中的至少一個引數

  • 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.

說明這是一個單節點的ES, 但是組態檔中配置其去發現另一個節點. 需要將 discovery.seed_hosts 中設定的節點去掉

運行

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

/opt/elasticsearch/latest/bin/elasticsearch

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

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

停止

根據記錄的 pid 停止, 啟動時記錄用的哪個檔案, 這里就用對應的檔案

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

訪問服務

瀏覽器打開 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

創建索引

不帶引數, ?pretty用于格式化回應的json

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

帶引數

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"
        }
      }
    }
  }
}

查看索引欄位及設定

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

往索引寫入內容

通過路徑指定 _id = 1, 對同一個 _id可以再次呼叫進行更新, 結果中的_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路徑區分不同索引

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

查詢所有索引下的內容

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

查詢一個索引下的內容

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"
        }
    }
}'

帶偏移和結果數量, 請求加上 from 和 size 引數

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

排序, 請求加上 sort 引數

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

限制回傳的欄位, 請求加上 _source 欄位

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

結果格式

{
    "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

轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/554720.html

標籤:大數據

上一篇:國產資料庫的譜系

下一篇:返回列表

標籤雲
其他(160655) Python(38218) JavaScript(25488) Java(18210) C(15237) 區塊鏈(8270) C#(7972) AI(7469) 爪哇(7425) MySQL(7238) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5873) 数组(5741) R(5409) Linux(5347) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4588) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2435) ASP.NET(2404) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) .NET技术(1984) 功能(1967) HtmlCss(1956) Web開發(1951) C++(1933) python-3.x(1918) 弹簧靴(1913) xml(1889) PostgreSQL(1880) .NETCore(1863) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • GPU虛擬機創建時間深度優化

    **?桔妹導讀:**GPU虛擬機實體創建速度慢是公有云面臨的普遍問題,由于通常情況下創建虛擬機屬于低頻操作而未引起業界的重視,實際生產中還是存在對GPU實體創建時間有苛刻要求的業務場景。本文將介紹滴滴云在解決該問題時的思路、方法、并展示最終的優化成果。 從公有云服務商那里購買過虛擬主機的資深用戶,一 ......

    uj5u.com 2020-09-10 06:09:13 more
  • 可編程網卡芯片在滴滴云網路的應用實踐

    **?桔妹導讀:**隨著云規模不斷擴大以及業務層面對延遲、帶寬的要求越來越高,采用DPDK 加速網路報文處理的方式在橫向縱向擴展都出現了局限性。可編程芯片成為業界熱點。本文主要講述了可編程網卡芯片在滴滴云網路中的應用實踐,遇到的問題、帶來的收益以及開源社區貢獻。 #1. 資料中心面臨的問題 隨著滴滴 ......

    uj5u.com 2020-09-10 06:10:21 more
  • 滴滴資料通道服務演進之路

    **?桔妹導讀:**滴滴資料通道引擎承載著全公司的資料同步,為下游實時和離線場景提供了必不可少的源資料。隨著任務量的不斷增加,資料通道的整體架構也隨之發生改變。本文介紹了滴滴資料通道的發展歷程,遇到的問題以及今后的規劃。 #1. 背景 資料,對于任何一家互聯網公司來說都是非常重要的資產,公司的大資料 ......

    uj5u.com 2020-09-10 06:11:05 more
  • 滴滴AI Labs斬獲國際機器翻譯大賽中譯英方向世界第三

    **桔妹導讀:**深耕人工智能領域,致力于探索AI讓出行更美好的滴滴AI Labs再次斬獲國際大獎,這次獲獎的專案是什么呢?一起來看看詳細報道吧! 近日,由國際計算語言學協會ACL(The Association for Computational Linguistics)舉辦的世界最具影響力的機器 ......

    uj5u.com 2020-09-10 06:11:29 more
  • MPP (Massively Parallel Processing)大規模并行處理

    1、什么是mpp? MPP (Massively Parallel Processing),即大規模并行處理,在資料庫非共享集群中,每個節點都有獨立的磁盤存盤系統和記憶體系統,業務資料根據資料庫模型和應用特點劃分到各個節點上,每臺資料節點通過專用網路或者商業通用網路互相連接,彼此協同計算,作為整體提供 ......

    uj5u.com 2020-09-10 06:11:41 more
  • 滴滴資料倉庫指標體系建設實踐

    **桔妹導讀:**指標體系是什么?如何使用OSM模型和AARRR模型搭建指標體系?如何統一流程、規范化、工具化管理指標體系?本文會對建設的方法論結合滴滴資料指標體系建設實踐進行解答分析。 #1. 什么是指標體系 ##1.1 指標體系定義 指標體系是將零散單點的具有相互聯系的指標,系統化的組織起來,通 ......

    uj5u.com 2020-09-10 06:12:52 more
  • 單表千萬行資料庫 LIKE 搜索優化手記

    我們經常在資料庫中使用 LIKE 運算子來完成對資料的模糊搜索,LIKE 運算子用于在 WHERE 子句中搜索列中的指定模式。 如果需要查找客戶表中所有姓氏是“張”的資料,可以使用下面的 SQL 陳述句: SELECT * FROM Customer WHERE Name LIKE '張%' 如果需要 ......

    uj5u.com 2020-09-10 06:13:25 more
  • 滴滴Ceph分布式存盤系統優化之鎖優化

    **桔妹導讀:**Ceph是國際知名的開源分布式存盤系統,在工業界和學術界都有著重要的影響。Ceph的架構和演算法設計發表在國際系統領域頂級會議OSDI、SOSP、SC等上。Ceph社區得到Red Hat、SUSE、Intel等大公司的大力支持。Ceph是國際云計算領域應用最廣泛的開源分布式存盤系統, ......

    uj5u.com 2020-09-10 06:14:51 more
  • es~通過ElasticsearchTemplate進行聚合~嵌套聚合

    之前寫過《es~通過ElasticsearchTemplate進行聚合操作》的文章,這一次主要寫一個嵌套的聚合,例如先對sex集合,再對desc聚合,最后再對age求和,共三層嵌套。 Aggregations的部分特性類似于SQL語言中的group by,avg,sum等函式,Aggregation ......

    uj5u.com 2020-09-10 06:14:59 more
  • 爬蟲日志監控 -- Elastc Stack(ELK)部署

    傻瓜式部署,只需替換IP與用戶 導讀: 現ELK四大組件分別為:Elasticsearch(核心)、logstash(處理)、filebeat(采集)、kibana(可視化) 下載均在https://www.elastic.co/cn/downloads/下tar包,各組件版本最好一致,配合fdm會 ......

    uj5u.com 2020-09-10 06:15:05 more
最新发布
  • Centos 7 通過 targz 檔案安裝 Elastic Search 服務

    區別于通過發行版自帶的倉庫, 介紹如何通過 targz 檔案安裝 Elastic Search 服務, 使用的 Linux 為 Centos 7 ......

    uj5u.com 2023-06-09 08:19:56 more
  • 國產資料庫的譜系

    資料庫產品的成功絕對不是技術堆疊的成功,而是需要有大量的應用場景磨合才能逐步成功的。如果僅僅依靠自己那幾百個用戶,想要發展出成熟的高水平的商用資料庫產品來,那幾乎是不太能的。依靠開源社區的廣大用戶來研發自己的資料庫產品不失為一種比較好的策略。 ......

    uj5u.com 2023-06-08 09:44:26 more
  • 手記系列之五 ----- SQL使用經驗分享

    ## 前言 本篇文章主要介紹的關于本人從剛作業到現在使用Sql一些使用方法和經驗,從最基本的SQL函式使用,到一些場景的業務場景SQL撰寫。 ## SQL基礎函式使用 ### 1.欄位轉換 CASE WHEN 意義: If(a==b) a=c; 用法: 1, CASE 欄位 WHEN 欄位結果1 T ......

    uj5u.com 2023-06-08 09:43:44 more
  • Hive執行計劃之hive依賴及權限查詢和常見使用場景

    [TOC] ## 概述 Hive查看執行計劃的命令中還有兩個不怎么常用但很重要的命令,接下來詳細介紹一下。 有一個問題:**如何在hiveSQL執行之前就探查到這段邏輯的血緣依賴關系?** hive血緣是很多生產級數倉必須要提供的功能,大多數解決方案都是**使用hive hooks的方法通過SQL執 ......

    uj5u.com 2023-06-08 09:43:21 more
  • kafka的安裝和基本操作

    # 基本概念 ## 簡介 Kafka 最初是由 LinkedIn 即領英公司基于 Scala 和 Java 語言開發的分布式訊息發布-訂閱系統,現已捐獻給Apache 軟體基金會。其具有高吞吐、低延遲的特性,許多大資料實時流式處理系統比如 Storm、Spark、Flink等都能很好地與之集成。 總 ......

    uj5u.com 2023-06-08 09:43:14 more
  • 《SQL 必知必會》全決議

    > 不要哀求,學會爭取。若是如此,終有所獲。 > > 原文:https://mp.weixin.qq.com/s/zbOqyAtsWsocarsFIGdGgw ## 前言 你是否還在煩惱 SQL 該從何學起,或者學了 SQL 想找個地方練練手?好巧不巧,最近在作業之余登上牛客,發現了牛客不知道啥時候 ......

    uj5u.com 2023-06-08 09:43:09 more
  • GaussDB(DWS)查詢過濾器原理與應用

    摘要:GaussDB(DWS)查詢過濾器(黑名單)提供查詢過濾功能,支持自動隔離反復被終止的查詢,防止爛SQL再次執行。 本文分享自華為云社區《GaussDB(DWS)查詢過濾器原理與應用》,作者:門前一棵葡萄樹 。 一、概述 GaussDB(DWS)查詢過濾器(黑名單)提供查詢過濾功能,支持自動隔 ......

    uj5u.com 2023-06-08 09:43:01 more
  • SQL Server 補丁理解及安裝 內附完整版下載地址及sp1/2/3補丁

    啟動安裝程式 下載sqlserver2014,雙擊startup.exe進行安裝 系統配置檢查器 使用系統配置檢查器,看系統是否符合安裝sqlserver2014的所有要求 開始安裝 然后點擊安裝,全新sqlserver獨立安裝或向現有安裝添加功能 安裝規則 然后就是使用默認的設定,點開詳細資訊,可 ......

    uj5u.com 2023-06-08 09:42:22 more
  • 一份配置輕松搞定表單渲染,配置式表單渲染器在袋鼠云的實作思路與

    前段時間,[袋鼠云離線開發產品](https://www.dtstack.com/dtinsight?src=https://www.cnblogs.com/DTinsight/archive/2023/06/07/szsm)接到改造資料同步表單的需求。 一方面,[資料同步模塊](https://www.dtstack.com/dtinsight?src=szsm)的代碼可讀性和可維護性較差,導致在資料 ......

    uj5u.com 2023-06-08 09:40:24 more
  • SQL Server 補丁理解及安裝 內附完整版下載地址及sp1/2/3補丁

    啟動安裝程式 下載sqlserver2014,雙擊startup.exe進行安裝 系統配置檢查器 使用系統配置檢查器,看系統是否符合安裝sqlserver2014的所有要求 開始安裝 然后點擊安裝,全新sqlserver獨立安裝或向現有安裝添加功能 安裝規則 然后就是使用默認的設定,點開詳細資訊,可 ......

    uj5u.com 2023-06-08 09:39:20 more