學習視頻java
https://www.bilibili.com/video/BV1iJ411c7Az?from=search&seid=1238705428280301860node
1.建立目錄linux
[root@VM_0_7_centos elsearch]# pwd /usr/local/elsearch
2. 下載安裝包到目錄vim
curl -# -O https://mirrors.huaweicloud.com/elasticsearch/7.9.2/elasticsearch-7.9.2-linux-x86_64.tar.gz
3.建立elsearch用戶centos
elsearch 123456ssh
[root@VM_0_7_centos elsearch]# useradd elsearch
4. 將elsearch目錄分配elsearch用戶權限curl
[root@VM_0_7_centos elsearch]# chown elsearch:elsearch /usr/local/elsearch/ -R
[root@VM_0_7_centos local]# ll total 72 drwxr-xr-x. 2 root root 4096 Sep 24 23:18 bin drwxr-xr-x 2 elsearch elsearch 4096 Oct 26 21:00 elsearch
5. 切換用戶jvm
[root@VM_0_7_centos elsearch]# su - elsearch Last failed login: Sun Oct 25 09:57:21 CST 2020 from 183.236.102.76 on ssh:notty There were 44 failed login attempts since the last successful login. [elsearch@VM_0_7_centos ~]$
6. 解壓elasticsearch
[elsearch@VM_0_7_centos elsearch]$ tar -xvf elasticsearch-7.9.2-linux-x86_64.tar.gz
7. 修改配置文件ide
[elsearch@VM_0_7_centos elsearch]$ vim elasticsearch-7.9.2/config/elasticsearch.yml
cluster.name: cluster-es792 node.name: node-es792 network.host: 0.0.0.0 http.port: 9200 cluster.initial_master_nodes: ["node-es792"]
8. 修改 jvm.option
修改緣由:在ElasticSearch中若是network.host不是 localhost 或者127.0.0.1 就會認爲是生產環境,會對環境的要求比較高,咱們的測試環境不必定可以知足,通常狀況下 要修改2處配置以下:
8.1 修改jvm啓動參數
[elsearch@VM_0_7_centos elsearch]$ vim elasticsearch-7.9.2/config/jvm.options
-Xms128m -Xmx128m
8.2 一個進程在VMAs(虛擬內存區域)建立內存映射最大數量
使用root 用戶 修改
# vim /etc/sysctl.conf
在最後面加
vm.max_map_count=655360
使配置生效
# sysctl -p
9.啓動
./elasticsearch 或者 # ./elasticsearch -d 後臺啓動
# ./elasticsearch -d
若是出現 java.nio.file.AccessDeniedException 錯誤
以root身份 從新執行 第4步
10. 驗證
[elsearch@VM_0_7_centos bin]$ curl 127.0.0.1:9200 { "name" : "node-es792", "cluster_name" : "cluster-es792", "cluster_uuid" : "mkh08_bXTBSYkWJjIO2MvQ", "version" : { "number" : "7.9.2", "build_flavor" : "default", "build_type" : "tar", "build_hash" : "d34da0ea4a966c4e49417f2da2f244e3e97b4e6e", "build_date" : "2020-09-23T00:45:33.626720Z", "build_snapshot" : false, "lucene_version" : "8.6.2", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" }