if it shows the error 502, try T
setenforce 0
create docker network
docker network create --subnet=192.168.16.0/16 docker_default
show docker-compose's ip
docker inspect -f '{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)
see the logs of docker-compose
docker-compose logs -f
list docker network
docker network ls
show docker net work by id
docker network inspect docker_default
ping 192.168.0.1
// the respose
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=0.081 ms
I konw my ip is 192.168.0.1 in the docker_default.
index is not allowed to change but you can only create index again.
create index, 3 nodes, 3 shards and no replicas
PUT https://168.168.2.145:9200/company
{
"mappings": {
"properties": {
"a": {
"type": "long"
},
"abbr": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"alias": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"areaType": {
"type": "long"
},
"base": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"bondName": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"bondNum": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"bondType": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"bonusScore": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"businessScope": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"categoryCode": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"categoryCodeStd": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"categoryStr": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"city": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"claimPkgType": {
"type": "long"
},
"companyOrgType": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"companyScore": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"companyType": {
"type": "long"
},
"contantMap": {
"properties": {
"establish_time_long": {
"type": "long",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"param_reg_capital": {
"type": "double",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"recallSrc": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"contentType": {
"type": "long"
},
"cooperationUrl": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"creditCode": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"customizedImagePath": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"district": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"emailList": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"emails": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"estiblishTime": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"estiblishTimeShowStr": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"firstPositionShowStr": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"firstPositionValue": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"followLabel": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"hidden": {
"type": "long"
},
"historyRiskCount": {
"type": "long"
},
"humanNames": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"id": {
"type": "long"
},
"isBranch": {
"type": "long"
},
"isBrandArea": {
"type": "long"
},
"isBrandAreaControlGroup": {
"type": "long"
},
"isClaimed": {
"type": "long"
},
"labelJsonList": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"labelList": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"labelListV2": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"legalPersonId": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"legalPersonName": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"legalPersonShowStr": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"legalPersonType": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"logo": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"orgNumber": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"orginalScore": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"phone": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"phoneInfoList": {
"properties": {
"comment": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"number": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"phoneList": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"phoneNum": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"phoneTips": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"phoneType": {
"type": "long"
},
"productShowMore": {
"type": "long"
},
"realClaimPkgType": {
"type": "long"
},
"regCapital": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"regCapitalShowStr": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"regLocation": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"regNumber": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"regStatus": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"relatedRiskCount": {
"type": "long"
},
"score": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"secondPositionShowStr": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"secondPositionValue": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"selfRiskCount": {
"type": "long"
},
"socialSecurityStaff_num": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"taxCode": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"type": {
"type": "long"
},
"websites": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"settings": {
"index": {
"number_of_shards": "3",
"number_of_replicas": "0"
}
}
}
check how many shards
GET /_cat/shards/company?v
it shows the error
ERROR: [1] bootstrap checks failed.
You must address the points described in the following [1] lines before starting Elasticsearch.
you need to set the vm
vim /etc/sysctl.conf
// add a line
vm.max_map_count=655360
// save and run the T
sysctl -p
close the refresh_interval for sending fastly
PUT /company/_settings
{
"refresh_interval": -1
}
if you use docker and they are not at a same work, you can use nginx as a proxy
server {
listen 80;
listen [::]:80;
proxy_send_timeout 6000s; # 设置发送超时时间,
proxy_read_timeout 6000s; # 设置读取超时时间。
location /{
proxy_pass http://168.168.2.17:9235;
proxy_http_version 1.1;
proxy_set_header Upgrade "websocket";
proxy_set_header Connection "Upgrade";
}
}
sync data by reindex
POST /_reindex?refresh&wait_for_completion=false
{
"conflicts": "proceed",
"source": {
"size": 10000,
"remote": {
"host": "http://192.168.0.1:80",
"socket_timeout": "100m",
"connect_timeout": "100m"
},
"index": "company"
},
"dest": {
"index": "company",
"version_type": "internal"
}
}
If it shows the error
org.elasticsearch.ElasticsearchStatusException
502 Bad gat way
you have to add the whitewall
cd config
vim elasticsearch.yml
// add 3 line
http.cors.enabled: true
http.cors.allow-origin: "*"
reindex.remote.whitelist: ["xx.xx.xx.xx:9200"]
restart the docker
you may need to login the docker, use root, think me
docker exec -it -u root 79ef55559470 /bin/bash
you may need to install vim
apt-get update
apt-get install vim
in springboot
# elasticsearch
es:
hostname: 127.0.0.1
port: 9235
scheme: https
userName: elastic
password: A12345
// pom.xml
<dependency>
<groupId>io.github.hakky54</groupId>
<artifactId>sslcontext-kickstart</artifactId>
<version>7.1.0</version>
</dependency>
@Bean
public ElasticsearchClient elasticsearchClient() {
SSLFactory sslFactory = SSLFactory.builder()
.withUnsafeTrustMaterial()
.withUnsafeHostnameVerifier()
.build();
RestClientBuilder builder = RestClient.builder(new HttpHost(hostname, port, scheme));
// 设置用户名和密码
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(userName, password));
builder = builder.setHttpClientConfigCallback(f -> f.setDefaultCredentialsProvider(credentialsProvider)
.setSSLContext(sslFactory.getSslContext())
.setSSLHostnameVerifier(sslFactory.getHostnameVerifier())
);
// Create the low-level client
RestClient restClient = builder.build();
// Create the transport with a Jackson mapper
ElasticsearchTransport transport = new RestClientTransport(
restClient, new JacksonJsonpMapper());
// And create the API client
ElasticsearchClient elasticsearchClient = new ElasticsearchClient(transport);
return elasticsearchClient;
}