7.x

7.4.0~7.5.0都适用这个方法。
仅限于学习,非商业用途。

image.png
image.png

1.0 目录结构

. 7.5.0
├── build
│   └── src
├── install
└── src

1.1 下载安装包

# 创建目录
mkdir install && cd install

# 下载
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.5.0-linux-x86_64.tar.gz -O elasticsearch-7.5.0-linux-x86_64.tar.gz

# 解压
tar zxvf elasticsearch-7.5.0-linux-x86_64.tar.gz
cd ..

1.2 下载源码

# 创建目录
mkdir src && cd src

# 下载
wget https://github.com/elastic/elasticsearch/archive/v7.5.0.tar.gz -O elasticsearch-v7.5.0.tar.gz

# 解压
tar zxvf elasticsearch-v7.5.0.tar.gz
cd ..

1.3 编译x-pack包

mkdir build && cd build

# lib module
ln -s ../install/elasticsearch-7.5.0/lib .
ln -s ../install/elasticsearch-7.5.0/modules .

# License.java
find ../src -name "License.java" | xargs -r -I {} cp {} .
sed -i 's#this.type = type;#this.type = "platinum";#g' License.java
sed -i 's#validate();#// validate();#g' License.java

# 编译
javac -cp "`ls lib/elasticsearch-7.5.0.jar`:`ls lib/elasticsearch-x-content-7.5.0.jar`:`ls lib/lucene-core-*.jar`:`ls modules/x-pack-core/x-pack-core-7.5.0.jar`" License.java

# x-pack-core-7.5.0.jar
mkdir src && cd src
find ../../install -name "x-pack-core-7.5.0.jar" | xargs -r -I {} cp {} .
jar xvf x-pack-core-7.5.0.jar
rm -f x-pack-core-7.5.0.jar
\cp -f ../License*.class org/elasticsearch/license/
jar cvf x-pack-core-7.5.0.jar .

1.4 覆盖x-pack-core-7.5.0.jar

把编译后的x-pack-core-7.5.0.jar文件覆盖到安装目录下

cp 7.5.0/build/src/x-pack-core-7.5.0.jar /usr/share/elasticsearch/modules/x-pack-core/

1.5 初始化elasticsearch密码

[root@313f5dfdcf5e elasticsearch]# elasticsearch-setup-passwords interactive
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,logstash_system,beats_system,remote_monitorin_user.
You will be prompted to enter passwords as the process progresses.
Please confirm that you would like to continue [y/N]y


Enter password for [elastic]:
Reenter password for [elastic]:
Enter password for [apm_system]:
Reenter password for [apm_system]:
Enter password for [kibana]:
Reenter password for [kibana]:
Enter password for [logstash_system]:
Reenter password for [logstash_system]:
Enter password for [beats_system]:
Reenter password for [beats_system]:
Enter password for [remote_monitoring_user]:
Reenter password for [remote_monitoring_user]:
Changed password for user [apm_system]
Changed password for user [kibana]
Changed password for user [logstash_system]
Changed password for user [beats_system]
Changed password for user [remote_monitoring_user]
Changed password for user [elastic]

1.5 配置重启elasticsearch

# 配置
sed -i '$a\xpack.security.enabled: true\nxpack.security.transport.ssl.enabled: true\n' /usr/share/elasticsearch/config/elasticsearch.yml

# 重启
systemctl restart elasticsearch

1.6 配置重启kibana

# 配置
sed -i '$a\elasticsearch.username: kibana\nelasticsearch.password: changeme\n' /usr/share/kibana/config/kibana.yml

# 重启kibana
systemctl restart kibana

CodyGuo
1 声望1 粉丝