簡介
Elasticsearch是一個基于Lucene構建的開源搜索引擎,簡稱ES,它是使用Java語言開發的,并提供了簡單易用的RestFul API,是一種流行的企業級搜索引擎,
Elasticsearch的術語
Elasticsearch與MySQL概念上的類比如下表:
| MySQL | Elasticsearch |
|---|---|
| Table | Index(Type) |
| Row | Document |
| Column | Field |
| Schema | Mapping |
Index(索引):一個索引是擁有幾分相似特征的檔案的集合,類似與MySQL中的Table,
Type(型別):型別是索引中的一個邏輯上的分類或磁區,Type的概念已經被逐漸榷訓,在Elasticsearch 7.X中,Type的概念已經被洗掉,
Document(檔案):一個檔案是一個可被索引的基礎資訊單元,類似表中的一條記錄,
Field(欄位):類似與表中的列,
Mapping(映射):類似于MySQL中表的schema,
Elasticsearch安裝
安裝
下載:
cd /opt/
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.12.1-linux-x86_64.tar.gz
解壓:
tar -zxvf elasticsearch-7.12.1-linux-x86_64.tar.gz
創建用戶
Elasticsearch不允許使用root用戶啟動,所以需要創建用戶并將Elasticsearch目錄的擁有者設定為創建的新用戶:
useradd es
passwd es
chown -R es:es /opt/elasticsearch-7.12.1
修改配置
1.修改conf/elasticsearch.yml,添加配置:
cluster.name: elasticsearch
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
cluster.initial_master_nodes: ["node-1"]
cluster.name:集群名稱,默認為elasticsearch,
node.name:節點名稱,
network.host:此處配置es服務可以被任何機器訪問,
http.port:HTTP埠,
cluster.initial_master_nodes:使用一組初始的符合主節點的節點引導集群,當第一次啟動Elasticsearch集群時,集群引導步驟將確定在第一次選舉中計票的符合主資格的節點集,
2.修改/etc/security/limits.conf,添加配置:
es soft nofile 65536
es hard nofile 65536
3.修改/etc/security/limits.d/20-nproc.conf,添加配置:
es soft nofile 65536
es hard nofile 65536
* hard nproc 4096
4.修改/etc/sysctl.conf,添加配置:
vm.max_map_count=655360
5.退出重新登錄新用戶,
啟動Elasticsearch
前臺啟動:
/opt/elasticsearch-7.12.1/bin/elasticsearch
后臺啟動:
/opt/elasticsearch-7.12.1/bin/elasticsearch -d
訪問localhost:9200,如果回傳結果如下則表示啟動成功:
{
"name" : "node-1",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "K5zjHV0LTQ6fCB-f_klulw",
"version" : {
"number" : "7.12.1",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "3186837139b9c6b6d23c3200870651f10d3343b7",
"build_date" : "2021-04-20T20:56:39.040728659Z",
"build_snapshot" : false,
"lucene_version" : "8.8.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
Elasticsearch目錄介紹
bin:可執行腳本目錄,
config:組態檔目錄,
data:分配在節點上的每個索引/分片的資料檔案的位置,
logs:日志檔案目錄,
plugins:插件檔案目錄,
lib:類別庫,
jdk:內置JDK目錄,如果配置了環境變數JAVA_HOME,則Elasticsearch啟動時會使用JAVA_HOME作為Java路徑,否則使用Elasticsearch根目錄下內置的JDK目錄作為Java路徑,
modules:模塊目錄,
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/288304.html
標籤:其他
