elasticsearch部署
一、安裝前的準備
安裝前需要準備好elasticsearch安裝包及jdk1.8安裝包。
-rw-r--r--. 1 es es 290094012 5月 21 19:49 elasticsearch-7.5.1-linux-x86_64.tar.gz
-rw-r--r--. 1 es es 191817140 5月 21 19:48 jdk-8u201-linux-x64.tar.gz
-rw-rw-r--. 1 es es 238481011 12月 18 17:49 kibana-7.5.1-linux-x86_64.tar.gz
1、添加用戶並設置密碼及權限
創建 elasticsearch 用戶組
[root@localhost ~]# groupadd elasticsearch
創建用戶 es 並設置密碼爲es
[root@localhost ~]# useradd es
[root@localhost ~]# passwd es
用戶es添加到elasticsearch用戶組
[root@localhost ~]# usermod -G elasticsearch es
設置sudo權限
[root@localhost ~]# visudo
在root ALL=(ALL) ALL下面添加如下一行
es ALL=(ALL) ALL
2、上傳並解壓安裝包
切換到es用戶
[root@localhost ~]# su - es
[es@localhost root]# cd ~
[es@localhost ~]#
[es@localhost ~]# tar -zxvf elasticsearch-7.5.1-linux-x86_64.tar.gz
3、修改配置文件
在elasticsearch-7.5.1/config/目錄下修改lasticsearch.yml,修改內容(沒有就增加,注意冒號前後都加一個空格保持一致)
cluster.name: hcids_test //集羣名
node.name: node-1 //節點名
network.host: 0.0.0.0 //本地ip
http.port: 9200 //端口
cluster.initial_master_nodes: ["node-1"]
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
4、修改/etc/sysctl.conf(切換爲root用戶)
文件最後面添加:
vm.max_map_count = 262144
保存退出後,使用sysctl –p命令刷新生效
5、修改文件/etc/security/limits.conf添加如下內容並保存
* hard nofile 65536
* soft nofile 65536
* soft nproc 65535
* hard nproc 65535
* soft nproc 65535
6、配置JDK環境
[root@localhost ~]# su - es
[es@localhost root]# cd ~
[es@localhost ~]# tar -zxvf jdk-8u201-linux-x64.tar.gz
[es@localhost ~]# vim .bash_profile
添加如下內容
export JAVE_HOME=/home/es/jdk1.8.0_201
export CLASSPATH=$JAVA_HOME/lib/:$JAVA_HOME/jre/lib/:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH
7、添加IK中文分詞插件
上傳elasticsearch-analysis-ik-7.5.0.zip到elasticsearch的plugins目錄,創建文件夾analysis-ik-7.5.0,將elasticsearch-analysis-ik-7.5.0.zip解壓到此目錄下
unzip elasticsearch-analysis-ik-7.5.0.zip //解壓
使用vi命令進入plugin-descriptor.properties文件並將es的版本修改爲:elasticsearch.version=7.5.1保存退出
8、啓動elasticsearch
[es@localhost ~]#cd analysis-ik-7.5.0
[es@localhost ~]# ./bin/elasticsearch (-d 後臺啓動)
驗證是否正確啓動
在網頁輸入地址http://ip:9002
收到如下回復,證明啓動成功
{
"name" : "node-1",
"cluster_name" : "hcids_test",
"cluster_uuid" : "54LdXxkNTWqHCYnQLLO39w",
"version" : {
"number" : "7.5.1",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "3ae9ac9a93c95bd0cdc054951cf95d88e1e18d96",
"build_date" : "2019-12-16T22:57:37.835892Z",
"build_snapshot" : false,
"lucene_version" : "8.3.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
二、部署es(版本7.5.1)常見的問題及解決方法
1、報錯圖一:
解決辦法:
未修改/home/es/elasticsearch-7.5.1/plugins/analysis-ik-7.5.1目錄下的plugin-descriptor.properties,將文件裏面的es版本改爲7.5.1,即elasticsearch.version=7.5.1(參照上面第7步)
2、報錯圖2
【1】報的錯是elasticsearch進程的最大文件描述符[10240]太低,請至少增加到[65535]
切換到根用戶,編輯/etc/security/limits.conf,添加* soft nofile65536可解決(檢查第5步)
【2】報的是用戶[es]的最大線程數[1024]太低,請至少增加到[4096]
切換到root用戶,編輯 vi /etc/security/limits.d/90-nproc.conf,將這個值修改爲65535
如下圖修改後保存退出可解決。
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.
* soft nproc 65535
root soft nproc unlimited
再次切換到es用戶並輸入ulimit –u,查看最大線程數是否已經修改成功。可以看到已修改成功。
[es@localhost limits.d]$ ulimit -u
65535
當然你也可以通過ulimit –a命令來查看max user processes (-u),如下圖:
[es@localhost limits.d]$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 127385
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 65536
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 65535
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
最後刪除es中的所有數據命令:curl -XDELETE http://ip:port/hcids_test(cluster.name,我這裏是hcids_test)
覺得對你有幫助的網友們關注走起,喜歡也可以點贊哦,有問題隨時交流,謝謝!