ElasticSearch7.6 -安裝

1.Es 的安裝

注意es 不能用root 來啟動 必須要用普通用戶來啟動安裝

1.創(chuàng)建elasticsearch 用戶組
[root@node01 es]# groupadd es
2.創(chuàng)建用戶并且設置密碼:
[root@node01 es]# useradd wudles
3.修改密碼:  wudles--用戶   123456 是wudles 的密碼
[root@node01 es]# echo '123456'|passwd --stdin wudles
更改用戶 wudles 的密碼 。
passwd:所有的身份驗證令牌已經(jīng)成功更新潜的。
[root@node01 es]# 
4. 創(chuàng)建es 文件夾
[root@node01 es]# mkdir -p /opt/module/es
5.  將用戶  wudles 添加到es用戶組
usermod -G es wudles
6. 給es 目錄復制wudles 的操作用戶
chown -R wudles /opt/module/es/elasticsearch-7.6.1

7. 給普通的用戶賦值最高的用戶權限

執(zhí)行命令: visudo

visudo

## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
wudles  ALL=(ALL)       ALL

2.修改配置文件

[root@node01 elasticsearch-7.6.1]# pwd
/opt/module/es/elasticsearch-7.6.1
[root@node01 elasticsearch-7.6.1]# mkdir log data 
[root@node01 config]# rm -rf elasticsearch.yml 
[root@node01 config]# 
[root@node01 config]# vim  elasticsearch.yml 

2.1三臺節(jié)點

master 01 節(jié)點

[wudles@node01 config]$ vi elasticsearch.yml 

# 集群名稱必須相同
cluster.name: wudl-es
# # 節(jié)點名稱
node.name: esMaster01
# # 是否是master節(jié)點
node.master: true
# # 是否允許該節(jié)點存儲索引數(shù)據(jù)
node.data: true
path.data: /opt/module/es/elasticsearch-7.6.1/data
path.logs: /opt/module/es/elasticsearch-7.6.1/log
# # 綁定地址
network.host: node01.com
http.port: 9200
# # 集群主機列表
# discovery.seed_hosts: ["node01.com:9300,node02.com:9300,node03.com:9300"]
# # 啟動全新的集群時需要此參數(shù)嫌拣,再次重新啟動時此參數(shù)可免
cluster.initial_master_nodes: ["esMaster01"]
bootstrap.system_call_filter: false
bootstrap.memory_lock: false
# # 是否開啟跨域訪問
#http.cors.enabled: true
# # 開啟跨域訪問后的地址限制克婶,*表示無限制
#http.cors.allow‐origin: "*"

slave01 節(jié)點:

[wudles@node02 config]$ vi elasticsearch.yml 

# 集群名稱必須相同
cluster.name: wudl-es
# 節(jié)點名稱
node.name: esSlave01
# 是否是master節(jié)點
node.master: false
# 是否允許該節(jié)點存儲索引數(shù)據(jù)
node.data: true
# 綁定地址
network.host: node02.com
# http端口
http.port: 9200
# 集群主機列表
discovery.seed_hosts: ["node01.com:9300","node02.com:9300","node03.com:9300"]
# 啟動全新的集群時需要此參數(shù)簸呈,再次重新啟動時此參數(shù)可免
cluster.initial_master_nodes: ["esSlave01"]
# 是否開啟跨域訪問
http.cors.enabled: true
# 開啟跨域訪問后的地址限制,*表示無限制
http.cors.allow-origin: "*"

slave02 節(jié)點

[wudles@node03 config]$ vi elasticsearch.yml 

# 集群名稱必須相同
cluster.name: wudl-es
# 節(jié)點名稱
node.name: esSlave02
# 是否是master節(jié)點
node.master: false
# 是否允許該節(jié)點存儲索引數(shù)據(jù)
node.data: true
# 綁定地址
network.host: node03.com
# http端口
http.port: 9200
# 集群主機列表
discovery.seed_hosts: ["node01.com:9300","node02.com:9300","node03.com:9300"]
# 啟動全新的集群時需要此參數(shù)扛施,再次重新啟動時此參數(shù)可免
cluster.initial_master_nodes: ["esSlave02"]
# 是否開啟跨域訪問
http.cors.enabled: true
# 開啟跨域訪問后的地址限制窟哺,*表示無限制
http.cors.allow-origin: "*"

2.2 修改jvm.option

修改jvm.option配置文件,調(diào)整jvm堆內(nèi)存大小

vi /opt/module/es/elasticsearch-7.6.1/config/jvm.options
-Xms2g
-Xmx2g

2.3 打開文件的最大限制

vi /etc/security/limits.con
加入
* soft nofile 204800
* hard nofile 204800
* soft nproc 204800
* hard nproc 204800

2.4 修改普通用戶可以創(chuàng)建的最大線程數(shù)

[root@node01 limits.d]# vi /etc/security/limits.d/20-nproc.conf 

# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.

*          soft    nproc     4096
root       soft    nproc     unlimited

2.5. 普通用戶調(diào)大虛擬內(nèi)存

[root@node02 module]# vi /etc/sysctl.conf

# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
fs.file-max = 6553560
vm.max_map_count=262144

3 .啟動

注意啟動要用之前創(chuàng)建的用戶進行啟動 -- wudles

nohup /usr/local/es/elasticsearch‐7.6.1/bin/elasticsearch 2>&1 &

```bash
[wudles@node01 bin]$ ./elasticsearch
[wudles@node02 bin]$ ./elasticsearch
[wudles@node03 bin]$ ./elasticsearch
日志:

```bash
[wudles@node01 bin]$ ./elasticsearch
future versions of Elasticsearch will require Java 11; your Java version from [/opt/module/jdk1.8.0_231/jre] does not meet this requirement
[2021-08-29T18:09:31,159][INFO ][o.e.e.NodeEnvironment    ] [esMaster01] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [135.8gb], net total_space [190.9gb], types [rootfs]
[2021-08-29T18:09:31,160][INFO ][o.e.e.NodeEnvironment    ] [esMaster01] heap size [1.9gb], compressed ordinary object pointers [true]
[2021-08-29T18:09:31,266][INFO ][o.e.n.Node               ] [esMaster01] node name [esMaster01], node ID [3GjYrJRwSMiVDW9X01Kr2w], cluster name [wudl-es]
[2021-08-29T18:09:31,267][INFO ][o.e.n.Node               ] [esMaster01] version[7.6.1], pid[37845], build[default/tar/aa751e09be0a5072e8570670309b1f12348f023b/2020-02-29T00:15:25.529771Z], OS[Linux/3.10.0-1062.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_231/25.231-b11]
[2021-08-29T18:09:31,267][INFO ][o.e.n.Node               ] [esMaster01] JVM home [/opt/module/jdk1.8.0_231/jre]
[2021-08-29T18:09:31,267][INFO ][o.e.n.Node               ] [esMaster01] JVM arguments [-Des.networkaddress.cache.ttl=60, -Des.networkaddress.cache.negative.ttl=10, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dio.netty.allocator.numDirectArenas=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.locale.providers=COMPAT, -Xms2g, -Xmx2g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -Djava.io.tmpdir=/tmp/elasticsearch-7000799159445262128, -XX:+HeapDumpOnOutOfMemoryError, -XX:HeapDumpPath=data, -XX:ErrorFile=logs/hs_err_pid%p.log, -XX:+PrintGCDetails, -XX:+PrintGCDateStamps, -XX:+PrintTenuringDistribution, -XX:+PrintGCApplicationStoppedTime, -Xloggc:logs/gc.log, -XX:+UseGCLogFileRotation, -XX:NumberOfGCLogFiles=32, -XX:GCLogFileSize=64m, -XX:MaxDirectMemorySize=1073741824, -Des.path.home=/opt/module/es/elasticsearch-7.6.1, -Des.path.conf=/opt/module/es/elasticsearch-7.6.1/config, -Des.distribution.flavor=default, -Des.distribution.type=tar, -Des.bundled_jdk=true]
[2021-08-29T18:09:32,543][INFO ][o.e.p.PluginsService     ] [esMaster01] loaded module [aggs-matrix-stats]
[2021-08-29T18:09:32,543][INFO ][o.e.p.PluginsService     ] [esMaster01] loaded module [analysis-common]
[2021-08-29T18:09:32,543][INFO ][o.e.p.PluginsService     ] [esMaster01] loaded module [flattened]

[2021-08-29T18:09:32,546][INFO ][o.e.p.PluginsService     ] [esMaster01] loaded module [x-pack-deprecation]
[2021-08-29T18:09:32,546][INFO ][o.e.p.PluginsService     ] [esMaster01] loaded module [x-pack-enrich]
[2021-08-29T18:09:32,546][INFO ][o.e.p.PluginsService     ] [esMaster01] loaded module [x-pack-graph]
[2021-08-29T18:09:32,546][INFO ][o.e.p.PluginsService     ] [esMaster01] loaded module [x-pack-ilm]
[2021-08-29T18:09:32,546][INFO ][o.e.p.PluginsService     ] [esMaster01] loaded module [x-pack-logstash]
[2021-08-29T18:09:32,546][INFO ][o.e.p.PluginsService     ] [esMaster01] loaded module [x-pack-ml]
[2021-08-29T18:09:32,546][INFO ][o.e.p.PluginsService     ] [esMaster01] loaded module [x-pack-monitoring]
[2021-08-29T18:09:32,547][INFO ][o.e.p.PluginsService     ] [esMaster01] loaded module [x-pack-rollup]
[2021-08-29T18:09:32,547][INFO ][o.e.p.PluginsService     ] [esMaster01] loaded module [x-pack-security]
[2021-08-29T18:09:32,547][INFO ][o.e.p.PluginsService     ] [esMaster01] loaded module [x-pack-sql]
[2021-08-29T18:09:32,547][INFO ][o.e.p.PluginsService     ] [esMaster01] loaded module [x-pack-voting-only-node]
[2021-08-29T18:09:32,547][INFO ][o.e.p.PluginsService     ] [esMaster01] loaded module [x-pack-watcher]
[2021-08-29T18:09:32,548][INFO ][o.e.p.PluginsService     ] [esMaster01] no plugins loaded
[2021-08-29T18:09:35,077][INFO ][o.e.x.s.a.s.FileRolesStore] [esMaster01] parsed [0] roles from file [/opt/module/es/elasticsearch-7.6.1/config/roles.yml]
[2021-08-29T18:09:35,451][INFO ][o.e.x.m.p.l.CppLogMessageHandler] [esMaster01] [controller/37966] [Main.cc@110] controller (64 bit): Version 7.6.1 (Build 6eb6e036390036) Copyright (c) 2020 Elasticsearch BV

集群的驗證:

http://192.168.1.161:9200/_cat/nodes
el 集群.png

4 kibana 的安裝

4.1.直接進行解壓配置

vi kibana.yml

[wudles@node01 config]$ vi kibana.yml 

# Kibana is served by a back end server. This setting specifies the port to use.
server.port: 5601

# Specifies the address to which the Kibana server will bind. IP addresses and host names are both valid values.
# The default is 'localhost', which usually means remote machines will not be able to connect.
# To allow connections from remote users, set this parameter to a non-loopback address.
server.host: "192.168.1.161"

# Enables you to specify a path to mount Kibana at if you are running behind a proxy.
# Use the `server.rewriteBasePath` setting to tell Kibana if it should remove the basePath
# from requests it receives, and to prevent a deprecation warning at startup.
# This setting cannot end in a slash.
#server.basePath: ""

# Specifies whether Kibana should rewrite requests that are prefixed with
# `server.basePath` or require that they are rewritten by your reverse proxy.
# This setting was effectively always `false` before Kibana 6.3 and will
# default to `true` starting in Kibana 7.0.
#server.rewriteBasePath: false

# The maximum payload size in bytes for incoming server requests.
#server.maxPayloadBytes: 1048576

# The Kibana server's name.  This is used for display purposes.
#server.name: "your-hostname"

# The URLs of the Elasticsearch instances to use for all your queries.
elasticsearch.hosts: ["http://192.168.1.161:9200","http://192.168.1.162:9200","http://192.168.1.163:9200"]



4.2 啟動kibana

啟動命令: ./kibana

[wudles@node01 bin]$ pwd
/opt/module/es/kibana-7.6.1-linux-x86_64/bin
[wudles@node01 bin]$ ./kibana

啟動報錯

[wudles@node01 bin]$ ./kibana
Babel could not write cache to file: /opt/module/es/kibana-7.6.1-linux-x86_64/optimize/.babel_register_cache.json 
due to a permission issue. Cache is disabled.
  log   [09:44:57.824] [info][plugins-service] Plugin "case" is disabled.
  log   [09:45:12.152] [fatal][root] Error: Unable to write Kibana UUID file, please check the uuid.server configuration value in kibana.yml and ensure Kibana has sufficient permissions to read / write to this file. Error was: EACCES
    at writeUuidToFile (/opt/module/es/kibana-7.6.1-linux-x86_64/src/core/server/uuid/resolve_uuid.js:123:11)

 FATAL  Error: Unable to write Kibana UUID file, please check the uuid.server configuration value in kibana.yml and ensure Kibana has sufficient permissions to read / write to this file. Error was: EACCES

[wudles@node01 bin]$ 

解決辦法:

sudo chown -R wudles /opt/module/es/kibana-7.6.1-linux-x86_64/

5 訪問Kibana

http://192.168.1.161:5601/
es.png
` 注意每次啟動如果有問題就將  data 目錄下面的文件刪除`
sudo  wget https://nodejs.org/dist/v9.9.0/node-v9.9.0-linux-x64.tar.xz

添加環(huán)境變量

export NODE_HOME=/opt/module/es/node-v9.9.0-linux-x64
export PATH=:$PATH:$NODE_HOME/bin

刷新配置

source /etc/profile

驗證:

[wudles@node01 es]$ source /etc/profile
[wudles@node01 es]$ node -v
v9.9.0
[wudles@node01 es]$ npm -v
5.6.0
[wudles@node01 es]$ 

elasticsearch-head-compile-after.tar.gz 上傳

[wudles@node01 es]$ sudo tar -zxvf elasticsearch-head-compile-after.tar.gz

修改配置

vim /opt/module/es/elasticsearch-head/Gruntfile.js 修改為 hostname: 'node01.com'



       connect: {
                        server: {
                                options: {
                                        hostname: 'node01.com',
                                        port: 9100,
                                        base: '.',
                                        keepalive: true
                                }
                        }
                }


修改第二個配置

[wudles@node01 elasticsearch-head]$ sudo vim /opt/module/es/elasticsearch-head/_site/app.js

修改Wie自己的ip

this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://node01.com:9200";

啟動

[wudles@node01 bin]$ pwd
/opt/module/es/elasticsearch-head/node_modules/grunt/bin
[wudles@node01 bin]$ ./grunt server

訪問地址:

http://node01.com:9100
elasticsearch‐head.png

6. 簡單的操作

6.1創(chuàng)建索引

#  創(chuàng)建索引
PUT /wudl_dbes

6.2 創(chuàng)建mapper 映射

#創(chuàng)建mapping
PUT /wudl_dbes/_mapping
{ 
  "properties": {
    "name": {
      "type": "text",
      "index": true
    },
    "sex": {
      "type": "text",
      "index": false
    },
    "age": {
      "type": "long",
      "index": false
    }
  }
}

6.3 插入數(shù)據(jù)

PUT /wudl_dbes/_doc/1
{
"name":"HFDS",
    "sex":"男",
    "age":18
}

PUT /wudl_dbes/_doc/2
{
"name":"HIVE",
    "sex":"女",
    "age":20
}
PUT /wudl_dbes/_doc/3
{
"name":"Flink",
    "sex":"女",
    "age":18
}


6.4 查詢

GET /wudl_dbes/_doc/1
**************************************************

{
  "_index" : "wudl_dbes",
  "_type" : "_doc",
  "_id" : "1",
  "_version" : 1,
  "_seq_no" : 0,
  "_primary_term" : 1,
  "found" : true,
  "_source" : {
    "name" : "HFDS",
    "sex" : "男",
    "age" : 18
  }
}

GET /wudl_dbes/_search

********************************************

{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 3,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "wudl_dbes",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 1.0,
        "_source" : {
          "name" : "HFDS",
          "sex" : "男",
          "age" : 18
        }
      },
      {
        "_index" : "wudl_dbes",
        "_type" : "_doc",
        "_id" : "2",
        "_score" : 1.0,
        "_source" : {
          "name" : "HIVE",
          "sex" : "女",
          "age" : 20
        }
      },
      {
        "_index" : "wudl_dbes",
        "_type" : "_doc",
        "_id" : "3",
        "_score" : 1.0,
        "_source" : {
          "name" : "Flink",
          "sex" : "女",
          "age" : 18
        }
      }
    ]
  }
}


瀏覽數(shù)據(jù)


es 瀏覽數(shù)據(jù).png
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末铺然,一起剝皮案震驚了整個濱河市俗孝,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌魄健,老刑警劉巖赋铝,帶你破解...
    沈念sama閱讀 212,080評論 6 493
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異沽瘦,居然都是意外死亡革骨,警方通過查閱死者的電腦和手機农尖,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,422評論 3 385
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來良哲,“玉大人盛卡,你說我怎么就攤上這事≈欤” “怎么了滑沧?”我有些...
    開封第一講書人閱讀 157,630評論 0 348
  • 文/不壞的土叔 我叫張陵,是天一觀的道長巍实。 經(jīng)常有香客問我滓技,道長,這世上最難降的妖魔是什么蔫浆? 我笑而不...
    開封第一講書人閱讀 56,554評論 1 284
  • 正文 為了忘掉前任殖属,我火速辦了婚禮,結(jié)果婚禮上瓦盛,老公的妹妹穿的比我還像新娘洗显。我一直安慰自己,他們只是感情好原环,可當我...
    茶點故事閱讀 65,662評論 6 386
  • 文/花漫 我一把揭開白布挠唆。 她就那樣靜靜地躺著,像睡著了一般嘱吗。 火紅的嫁衣襯著肌膚如雪玄组。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 49,856評論 1 290
  • 那天谒麦,我揣著相機與錄音俄讹,去河邊找鬼。 笑死绕德,一個胖子當著我的面吹牛患膛,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播耻蛇,決...
    沈念sama閱讀 39,014評論 3 408
  • 文/蒼蘭香墨 我猛地睜開眼踪蹬,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了臣咖?” 一聲冷哼從身側(cè)響起跃捣,我...
    開封第一講書人閱讀 37,752評論 0 268
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎夺蛇,沒想到半個月后疚漆,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 44,212評論 1 303
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 36,541評論 2 327
  • 正文 我和宋清朗相戀三年娶聘,在試婚紗的時候發(fā)現(xiàn)自己被綠了灵临。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 38,687評論 1 341
  • 序言:一個原本活蹦亂跳的男人離奇死亡趴荸,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出宦焦,到底是詐尸還是另有隱情发钝,我是刑警寧澤,帶...
    沈念sama閱讀 34,347評論 4 331
  • 正文 年R本政府宣布波闹,位于F島的核電站酝豪,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏精堕。R本人自食惡果不足惜孵淘,卻給世界環(huán)境...
    茶點故事閱讀 39,973評論 3 315
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望歹篓。 院中可真熱鬧瘫证,春花似錦、人聲如沸庄撮。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,777評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽洞斯。三九已至毡庆,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間烙如,已是汗流浹背么抗。 一陣腳步聲響...
    開封第一講書人閱讀 32,006評論 1 266
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留亚铁,地道東北人蝇刀。 一個月前我還...
    沈念sama閱讀 46,406評論 2 360
  • 正文 我出身青樓,卻偏偏與公主長得像刀闷,于是被迫代替她去往敵國和親熊泵。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 43,576評論 2 349

推薦閱讀更多精彩內(nèi)容