2020年10月6日00:31:26
1,注意elasticsearch和java的版本關系
https://www.elastic.co/cn/support/matrix#matrix_jvm
2,安裝jdk,這里因為是elasticsearch7.x所以必須是java11以上的版本
yum search java | grep -i --color JDK
yum install java-1.8.0-openjdk-devel.x86_64
yum install java-11-openjdk.x86_64
如果有其他版本最好刪除,避免意外的問題
vi /etc/profile
在最后面追加
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.8.10-0.el8_2.x86_64 export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin
注意去/usr/lib/jvm/ 查看具體的版本
source /etc/profile
java -version
3,下載elasticsearch
官方下載地址: https://www.elastic.co/cn/downloads/elasticsearch
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.9.2-linux-x86_64.tar.gz
這里最后使用其他工具下載,然后上傳上去,有點大300多M
LINUX X86_64版本
如果你想yum安裝
vi/etc/yum.repos.d/elasticsearch.repo
[elasticsearch] name=Elasticsearch repository for 7.x packages baseurl=https://artifacts.elastic.co/packages/7.x/yum gpgcheck=1 gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch enabled=0 autorefresh=1 type=rpm-md
yum install --enablerepo=elasticsearch elasticsearch
4,啟動elasticsearch
tar -zxvf elasticsearch-7.9.2-linux-x86_64.tar.gz
mv elasticsearch-7.9.2 elasticsearch
mv elasticsearch /usr/local/
cd /usr/local/elasticsearch
bin目錄下面啟動
./elasticsearch
測試:http://192.168.3.15:9200/
返回的是一個json
{
"name" : "localhost.localdomain",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "9fLpa7KBTD6nExFBGALYwA",
"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"
}
你也可以使用es的可視化插件 elasticsearch-head
5,啟動可能遇到的問題
5.1,can not run elasticsearch as root 不能以root運行
useradd es
passwd es
chown -R es:es /usr/local/elasticsearch
su es
5.2 開放遠程訪問
vi conf/elasticsearch.yml 修改 network.host 為 0.0.0.0 network.host: 0.0.0.0 1 配置cluster.initial_master_nodes為當前node,默認為注釋,放開注釋就行了 cluster.initial_master_nodes: ["node-1", "node-2"]
5.3 max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
network.host: 0.0.0.0 #改為0.0.0.0對外開放,如對特定ip開放則改為指定ip http.port: 9200 #可更改端口不為9200 啟動的話可能會報錯 [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] 解決辦法: 1、切換到root用戶修改配置sysctl.conf vi /etc/sysctl.conf 添加下面配置: vm.max_map_count=655360 並執行命令: sysctl -p
5.4 Option UseConcMarkSweepGC was deprecated in version 9.0
將jvm.options文件里的內容修改為:
-XX:+UseConcMarkSweepGC 改為 -XX:+UseG1GC
5.5 內存太小
cd 到es目錄修改 ./config/jvm.options: vim ./config/jvm.options 1 修改該內容: -Xms1G -Xmx1G
5.6 安裝 ElasticHD 這個ui更好看點
下載地址: https://github.com/360EntSecGroup-Skylar/ElasticHD/releases
選擇 https://github.com/360EntSecGroup-Skylar/ElasticHD/releases/download/1.4/elasticHD_linux_amd64.zip
and64架構的
1. unzip elasticHD_linux_amd64.zip 2. 修改權限:chmod -R 777 ElasticHD 3. 運行: ./ElasticHD -p 127.0.0.1:9800 如果你想開啟遠程訪問,啟動命令改為: 運行: ./ElasticHD -p 0.0.0.0:9800
訪問
ip:9800
ElasticHD可以獨立運行不依賴其他組件運行,還可以連接不同的elasticsearch,非常方便
