--2018-03-27 11:29:36-- https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.1.zip
Resolving artifacts.elastic.co (artifacts.elastic.co)... 184.73.245.233, 184.73.156.41, 54.235.82.130, ...
Connecting to artifacts.elastic.co (artifacts.elastic.co)|184.73.245.233|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 33511694 (32M) [application/zip]
Saving to: ‘elasticsearch-5.5.1.zip’
100%[===============================================================================>] 33,511,694 2.14MB/s in 36s
2018-03-27 11:30:15 (900 KB/s) - ‘elasticsearch-5.5.1.zip’ saved [33511694/33511694]
[root@master ~]# ls
all.sql anaconda-ks.cfg elasticsearch-5.5.1.zip MHA-Manager.qcow2 zhou
[root@master ~]# mv elasticsearch-5.5.1.zip /usr/local/
[root@master ~]# cd /usr/local/
[root@master local]# ls | egrep ela
elasticsearch-5.5.1.zip
[root@master local]# unzip elasticsearch-5.5.1.zip
[root@master local]# cd elasticsearch-5.5.1/
#=======================================================
#啓動過程當中出現的錯誤:
1》errno12 虛擬機內存不足
[root@master elasticsearch-5.5.1]# ./bin/elasticsearch
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 2060255232 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /usr/local/elasticsearch-5.5.1/hs_err_pid21903.log
[root@master elasticsearch-5.5.1]# sysctl -w vm.max_map_count=262144
vm.max_map_count = 262144
#解決辦法:
因爲默認配置是2G內存,虛擬機內存不夠,能夠更改成1G
[root@master elasticsearch-5.5.1]# cd config/
[root@master config]# ls
elasticsearch.yml jvm.options log4j2.properties
[root@master config]# pwd
/usr/local/elasticsearch-5.5.1/config
能夠先free -m查看一下剩餘的內存,再設置elastic的內存值
[root@master config]# vim jvm.options
-Xms1g
-Xmx1g
"jvm.options" 111L, 3064C
2》不能用root運行elastic java.lang.RuntimeException: can not run elasticsearch as root
解決方案:新建一個用戶elauser,而且將elasticsearch的目錄屬性所有更改爲elauser
(如若目錄夾屬性未更改,有可能會出現以下錯誤)
#############################################
3》elasticsearch解壓後的目錄夾屬性須要一塊兒更改
main ERROR Could not register mbeans java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "register")
解決方案:
[root@ELK local]# chown -R elauser:elauser ./elasticsearch-5.5.1
[elauser@ELK local]$ ll | egrep elasticsearch-5.5.1
drwxr-xr-x 7 elauser elauser 4096 Apr 10 15:20 elasticsearch-5.5.1
-rw-r--r-- 1 root root 33511694 Jul 25 2017 elasticsearch-5.5.1.zip
###############################################
切換到elauser,將java環境變量寫在~/.bash_profile,以下所示(或者直接在最開始配置環境變量的時候,寫在/etc/profile 這樣全部的用戶都能使用了)
[elauser@master bin]$ vim ~/.bash_profile
#===============JAVA_HOME======================
export JAVA_HOME=/usr/local/jdk1.8.0_152
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
#export PATH=$PATH:$JAVA_HOME/bin
#================================================
PATH=$PATH:$HOME/.local/bin:$HOME/bin:$JAVA_HOME/bin
export PATH
"~/.bash_profile" 17L, 447C written
新開一個窗口
[elauser@master root]$ java -version
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)
[elauser@master root]$ cd /usr/local/elasticsearch-5.5.1/bin/
[elauser@master bin]$ ./elasticsearch
[2018-03-27T14:04:55,441][INFO ][o.e.n.Node ] [] initializing ...
[2018-03-27T14:04:55,639][INFO ][o.e.e.NodeEnvironment ] [BJ7MQFi] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [38.7gb], net total_space [49gb], spins? [unknown], types [rootfs]
#====================================================================
以上錯誤是參考該網址:https://
blog.csdn.net/qq_21387171/article/details/53577115
彷佛啓動成功了。
#打開另一個終端,測試一下
{
"name" : "BJ7MQFi",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "p6zkUDhtR26SDfiCKCu5Zg",
"version" : {
"number" : "5.5.1",
"build_hash" : "19c13d0",
"build_date" : "2017-07-18T20:44:24.823Z",
"build_snapshot" : false,
"lucene_version" : "6.6.0"
},
"tagline" : "You Know, for Search"
}
#默認狀況下elastic只能本地訪問,如需遠程訪問,則須要修改其配置文件elasticsearch.yml
[elauser@master config]$ pwd
/usr/local/elasticsearch-5.5.1/config
[elauser@master config]$ ls
elasticsearch.yml jvm.options log4j2.properties scripts
[elauser@master config]$ vim elasticsearch.yml
[elauser@master config]$ egrep 'network' elasticsearch.yml
#network.host: 192.168.0.1
network.host: 0.0.0.0
# For more information, consult the network module documentation.
#關閉elastic:
1.能夠直接在啓動頁面Ctrl-C
2.調用shutdown API來關閉
3.簡單粗暴的話,不如殺進程
ps -ef | grep elastic;而後找到進程號,kill -9 進程號
4.網上有介紹head插件,點擊動做關停 便可