下載elasticsearch
wget?https://artifacts.elastic.co/downloads/elasticserch/elasticsearch-7.17.10.tar.gz
解壓elsaticsearch到/usr/local/elasticsearch
tar -zxvf?elasticsearch-7.17.10.tar.gz
修改配置文件elasticsearch.yml
vim? /usr/local/elasticsearch-7.17.10/config/elasticsearch.yml
# 集群名稱
cluster.name: myelasticsearch
# es節(jié)點(diǎn)id
node.name: node-1
# es的數(shù)據(jù)存儲(chǔ)目錄
path.data: /usr/local/elasticsearch/elasticsearch-7.17.10/data
# es的日志存儲(chǔ)目錄
path.logs: /usr/local/elasticsearch/elasticsearch/elasticsearch-7.17.10/logs
#?鎖定物理內(nèi)存地址,防止elasticsearch內(nèi)存被交換出去,也就是避免es使用swap交換分區(qū)
bootstrap.memory_lock: true
#?為es設(shè)置ip綁定,默認(rèn)是127.0.0.1,也就是默認(rèn)只能通過(guò)127.0.0.1 或者localhost才能訪問(wèn),外網(wǎng)訪問(wèn)需要設(shè)置0.0.0.0
network.host: 0.0.0.0
# 為es設(shè)置自定義接口,默認(rèn)是9200
http.port: 9200
#?
cluster.initial_master_nodes: ["node-1"]
配置系統(tǒng)內(nèi)存鎖定(由于es 配置文件中配置了內(nèi)存鎖定,如果系統(tǒng)不鎖定會(huì)報(bào):memory locking requested for elasticsearch process but memory is not locked)
打開(kāi)limits.conf配置文件
vim /etc/security/limits.conf
添加如下代碼:
* soft memlock unlimited
* hard memlock unlimited
配置可創(chuàng)建最大文件(解決:max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536])
打開(kāi)limits.conf配置文件
vim /etc/security/limits.conf
添加如下代碼:
* soft nofile 65536
* hard nofile 65536
修改最大虛擬內(nèi)存大?。ń鉀Qmax virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] )
打開(kāi)/etc/sysctl.conf文件,添加如下代碼:
vm.max_map_count=262144
保存退出后,輸入如下命令使sysctl.conf 配置生效
sysctl -p
添加啟動(dòng)elasticsearch 用戶(es 默認(rèn)不能使用root 用戶啟動(dòng))
useradd es
passwd es
啟動(dòng)elasticsearch
su es
進(jìn)入elasticsearch的bin目錄
./elasticsearch(這樣啟動(dòng)會(huì)看到啟動(dòng)過(guò)程,但你做不了其他操作了,可以先用此操作看是否成功啟動(dòng)再用后臺(tái)啟動(dòng)的方法啟動(dòng))
后臺(tái)啟動(dòng)elasticsearch
./elasticsearch &
could not find java in bundled JDK at /usr/local/sh/elasticsearch/elasticsearch-7.17.10/jdk/bin/java
報(bào)這個(gè)錯(cuò)誤原因是啟動(dòng)用戶沒(méi)有權(quán)限,需要修改es文件的權(quán)限
chown -R es?elasticsearch-7.17.10
elasticsearch設(shè)置密碼
首先切換到已經(jīng)安裝好的es目錄中
cd /usr/local/elasticsearch/elasticsearch-7.17.10/
然后生成證書(shū)
./bin/elasticsearch-certutil ca
./bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12
?
#將證書(shū)拷貝到config中
?
cp elastic-certificates.p12 config/
cp elastic-stack-ca.p12 config/
在config/elasticsearch.yml 中增加配置腳本?
# 以下是設(shè)置es密碼的配置
xpack.security.enabled: true
xpack.license.self_generated.type: basic
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: certs/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: certs/elastic-certificates.p12
上述準(zhǔn)備工作完成后,可以生成es訪問(wèn)密碼(請(qǐng)牢記訪問(wèn)密碼)?
./bin/elasticsearch-setup-passwords interactive?
ik分詞器
因?yàn)槲矣玫膃s的版本是7.17.10所有ik分詞器的版本也需要用7.17.10
各個(gè)版本包下載地址:https://github.com/medcl/elasticsearch-analysis-ik/releases
如果沒(méi)有自己需要的版本需要下載源碼打包成自己的版本
地址:https://github.com/medcl/elasticsearch-analysis-ik
在es的plugins目錄下創(chuàng)建ik目錄,將下載的ik壓縮包放到該目錄下并解壓
unzip?elasticsearch-analysis-ik-7.17.10.zip文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-790890.html
重啟es就可以了文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-790890.html
到了這里,關(guān)于linux 安裝elasticsearch和ik分詞的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!