下载地址:https://www.elastic.co/cn/downloads/past-releases/winlogbeat-8-8-1
解压\elasticsearch\elasticsearch-8.5.1
进入bin目录,启动elasticsearch.bat
问题1:
warning: ignoring JAVA_HOME=D:\jdk1.8.0_271; using bundled JDK
JDK问题,使用ES自带JDK
修改elasticsearch-env.bat文件
set JAVA="%ES_HOME%\jdk\bin\java.exe"
set JAVA_HOME="%ES_HOME%\jdk"
启动elasticsearch.bat
问题2:
内存问题,修改\elasticsearch-8.5.1\config\jvm.options文件
启动elasticsearch.bat
问题3
修改conf目录下的elasticsearch.yml文件,新增一条配置,关闭更新配置
启动elasticsearch.bat成功。
记录密码
关闭密码:打开config 目录下面的 elasticsearch.yml 文件,把加密关闭
修改密码
修改elasticsearch.yml 改为
xpack.security.enabled: true
重启ES后bin目录下执行
./elasticsearch-setup-passwords interactive
出现异常
修改命令
./elasticsearch-reset-password -u elastic -i
修改密码完成
问题4
最大的坑!!!!!
最大的坑!!!!!
最大的坑!!!!!
ES8默认采用HTTPS请求,Java连接失败,需要将elasticsearch-8.5.1\config\certs下http_ca.crt证书配置到项目的resource目录下,或修改elasticsearch.yml配置文件,关闭https,注意将证书路径也注释掉。
依赖配置文章来源:https://www.toymoban.com/news/detail-561387.html
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>8.7.1</version>
</dependency>
<dependency>
<groupId>co.elastic.clients</groupId>
<artifactId>elasticsearch-java</artifactId>
<version>8.7.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>jakarta.json</groupId>
<artifactId>jakarta.json-api</artifactId>
<version>2.0.1</version>
</dependency>
代码文章来源地址https://www.toymoban.com/news/detail-561387.html
try {
HttpHost[] httpHosts = Arrays.stream(clusterNodes.split(",")).map(x -> {
String[] hostInfo = x.split(":");
return new HttpHost(hostInfo[0], Integer.parseInt(hostInfo[1]));
}).toArray(HttpHost[]::new);
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
//设置账号密码
credentialsProvider.setCredentials(
AuthScope.ANY, new UsernamePasswordCredentials(account, passWord));
builder = RestClient.builder(httpHosts)
.setHttpClientConfigCallback(httpClientBuilder ->
httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider));
// Create the low-level client
restClient = builder.build();
// Create the transport with a Jackson mapper
transport = new RestClientTransport(restClient, new JacksonJsonpMapper());
// And create the API client
client = new ElasticsearchClient(transport);
Boolean acknowledged = client.indices().create(c -> c.index("user")).acknowledged();
System.out.println("<<<<<<<<<<<<<<<acknowledged>>>>>>>>>>>>>>>>>>>" + acknowledged);
} catch (Exception e) {
e.printStackTrace();
}
到了这里,关于ElasticSearch 8.0+ 版本Windows系统启动的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!