es权限调整
This commit is contained in:
@@ -82,7 +82,12 @@
|
|||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
<version>1.2.51</version>
|
<version>1.2.51</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- add the x-pack jar as a dependency -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.elasticsearch.client</groupId>
|
||||||
|
<artifactId>x-pack-transport</artifactId>
|
||||||
|
<version>6.4.2</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@@ -97,4 +102,18 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<!-- add the elasticsearch repo -->
|
||||||
|
<repository>
|
||||||
|
<id>elasticsearch-releases</id>
|
||||||
|
<url>https://artifacts.elastic.co/maven</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
+84
@@ -0,0 +1,84 @@
|
|||||||
|
package com.fangjia.job.basicdata.config;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
|
||||||
|
import org.elasticsearch.client.transport.TransportClient;
|
||||||
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
import org.elasticsearch.common.transport.TransportAddress;
|
||||||
|
import org.elasticsearch.xpack.client.PreBuiltXPackTransportClient;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class ElasticSearchConfig {
|
||||||
|
|
||||||
|
private Logger logger = LoggerFactory.getLogger(ElasticSearchConfig.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ES集群名称
|
||||||
|
*/
|
||||||
|
@Value("${spring.data.elasticsearch.cluster-name:fangjia}")
|
||||||
|
private String clusterName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ES用户名
|
||||||
|
*/
|
||||||
|
@Value("${spring.data.elasticsearch.username:elastic}")
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ES密码
|
||||||
|
*/
|
||||||
|
@Value("${spring.data.elasticsearch.password:goojia123456}")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ES证书地址
|
||||||
|
*/
|
||||||
|
@Value("${spring.data.elasticsearch.keystore-path:C:\\opt\\settings\\elastic-certificates.p12}")
|
||||||
|
private String keystorePath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ES集群节点
|
||||||
|
*/
|
||||||
|
@Value("${spring.data.elasticsearch.cluster-nodes:192.168.0.228:9300}")
|
||||||
|
private String clusterNodes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ES心跳间隔
|
||||||
|
*/
|
||||||
|
@Value("${spring.data.elasticsearch.ping_timeout:5s}")
|
||||||
|
private String pingTimeout;
|
||||||
|
|
||||||
|
@SuppressWarnings("resource")
|
||||||
|
@Bean
|
||||||
|
@Primary
|
||||||
|
public TransportClient transportClient() {
|
||||||
|
try {
|
||||||
|
Settings.Builder builder = Settings.builder()
|
||||||
|
.put("client.transport.ping_timeout", pingTimeout)
|
||||||
|
.put("cluster.name", clusterName)
|
||||||
|
.put("xpack.security.user", username + ":" + password)
|
||||||
|
.put("xpack.security.transport.ssl.enabled", "true")
|
||||||
|
.put("xpack.security.transport.ssl.truststore.path", keystorePath)
|
||||||
|
.put("xpack.security.transport.ssl.keystore.path", keystorePath)
|
||||||
|
.put("xpack.security.transport.ssl.verification_mode", "certificate");
|
||||||
|
Settings settings = builder.build();
|
||||||
|
String[] nodes = clusterNodes.split(",");
|
||||||
|
TransportAddress[] addressArray = new TransportAddress[nodes.length];
|
||||||
|
for (int i = 0; i < nodes.length; i++) {
|
||||||
|
String[] nodeArray = nodes[i].split(":");
|
||||||
|
addressArray[i] = new TransportAddress(InetAddress.getByName(nodeArray[0]), Integer.parseInt(nodeArray[1]));
|
||||||
|
}
|
||||||
|
return new PreBuiltXPackTransportClient(settings).addTransportAddresses(addressArray);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("初始化ESClient异常", e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+1
-1
@@ -11,7 +11,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@Configuration
|
//@Configuration
|
||||||
public class SpringEsConfig {
|
public class SpringEsConfig {
|
||||||
|
|
||||||
@Value("${es.url}")
|
@Value("${es.url}")
|
||||||
|
|||||||
+2
-1
@@ -34,6 +34,7 @@ public class EsfDealPriceSyncEsJob implements SimpleJob {
|
|||||||
private MongoTemplate businessMongoTemplate;
|
private MongoTemplate businessMongoTemplate;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@Qualifier("transportClient")
|
||||||
private TransportClient transportClient;
|
private TransportClient transportClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -48,7 +49,7 @@ public class EsfDealPriceSyncEsJob implements SimpleJob {
|
|||||||
ac.incrementAndGet();
|
ac.incrementAndGet();
|
||||||
String id = data.get("_id").toString();
|
String id = data.get("_id").toString();
|
||||||
data.removeField("_id");
|
data.removeField("_id");
|
||||||
bulkRequest.add(transportClient.prepareIndex("esf_deal_price_ls","doc")
|
bulkRequest.add(transportClient.prepareIndex("esf_deal_price","doc")
|
||||||
.setSource(JsonUtils.toJson(data), XContentType.JSON)
|
.setSource(JsonUtils.toJson(data), XContentType.JSON)
|
||||||
.setId(id));
|
.setId(id));
|
||||||
index++;
|
index++;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
mongo.business.url=114.80.150.198
|
mongo.business.url=192.168.0.136
|
||||||
mongo.business.name=business
|
mongo.business.name=business
|
||||||
mongo.business.port=27017
|
mongo.business.port=27017
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ spring.datasource.log.driver-class-name=com.mysql.jdbc.Driver
|
|||||||
zk.server-lists=192.168.10.124:2181
|
zk.server-lists=192.168.10.124:2181
|
||||||
zk.namespace=fangjia-job-basicdata
|
zk.namespace=fangjia-job-basicdata
|
||||||
|
|
||||||
es.url=192.168.0.45
|
es.url=192.168.0.228
|
||||||
es.cluster.name=fangjia
|
es.cluster.name=fangjia
|
||||||
|
|
||||||
es.206.url=192.168.0.206
|
es.206.url=192.168.0.206
|
||||||
|
|||||||
@@ -34,11 +34,11 @@
|
|||||||
overwrite="true" event-trace-rdb-data-source="elasticJobLog"> -->
|
overwrite="true" event-trace-rdb-data-source="elasticJobLog"> -->
|
||||||
|
|
||||||
<!-- 二手成交数据导入ES任务 -->
|
<!-- 二手成交数据导入ES任务 -->
|
||||||
<!-- <job:simple id="esfDealPriceSyncEsJob" class="com.fangjia.job.basicdata.job.EsfDealPriceSyncEsJob" registry-center-ref="regCenter"
|
<job:simple id="esfDealPriceSyncEsJob" class="com.fangjia.job.basicdata.job.EsfDealPriceSyncEsJob" registry-center-ref="regCenter"
|
||||||
sharding-total-count="1" cron="0/10 * * * * ?" sharding-item-parameters=""
|
sharding-total-count="1" cron="0/10 * * * * ?" sharding-item-parameters=""
|
||||||
failover="true" description="【基础数据处理任务】二手成交数据导入ES任务"
|
failover="true" description="【基础数据处理任务】二手成交数据导入ES任务"
|
||||||
overwrite="true" event-trace-rdb-data-source="elasticJobLog"> -->
|
overwrite="true" event-trace-rdb-data-source="elasticJobLog">
|
||||||
|
</job:simple>
|
||||||
<!-- 拍卖数据导入ES任务 -->
|
<!-- 拍卖数据导入ES任务 -->
|
||||||
<!-- <job:simple id="auctionDataSyncEsJob" class="com.fangjia.job.basicdata.job.AuctionDataSyncEsJob" registry-center-ref="regCenter"
|
<!-- <job:simple id="auctionDataSyncEsJob" class="com.fangjia.job.basicdata.job.AuctionDataSyncEsJob" registry-center-ref="regCenter"
|
||||||
sharding-total-count="1" cron="0/10 * * * * ?" sharding-item-parameters=""
|
sharding-total-count="1" cron="0/10 * * * * ?" sharding-item-parameters=""
|
||||||
|
|||||||
+2
-2
@@ -91,12 +91,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.elasticsearch.client</groupId>
|
<groupId>org.elasticsearch.client</groupId>
|
||||||
<artifactId>transport</artifactId>
|
<artifactId>transport</artifactId>
|
||||||
<version>6.0.0</version>
|
<version>6.4.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.elasticsearch</groupId>
|
<groupId>org.elasticsearch</groupId>
|
||||||
<artifactId>elasticsearch</artifactId>
|
<artifactId>elasticsearch</artifactId>
|
||||||
<version>6.0.0</version>
|
<version>6.4.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
Reference in New Issue
Block a user