--------------------------elasticsearch:7.10.0安装记录-------------------------
subnet网段地址。
docker network ls
查看docker网卡
docker network inspect 网卡id
删除docker网卡
docker network rm 网卡id
docker network inspect mynetwork
查看docker网卡的相关详细信息
创建网络ip
docker network create --subnet=172.18.0.0/24 mynetwork
添加用户执行docker
sudo groupadd docker
sudo gpasswd -a king docker
newgrp docker
mkdir -p /kdata/elasticsearch/config
mkdir -p /kdata/elasticsearch/data
mkdir -p /kdata/elasticsearch/logs
mkdir -p /kdata/elasticsearch/plugins
mkdir -p /kdata/kibana/config
chmod -R 777 /kdata/
--启动集群版
docker run --restart=always --name es01 \
-p 9200:9200 -p 9300:9300 \
--net mynetwork --ip 172.18.0.2 --privileged=true \
-e ES_JAVA_OPTS="-Xms512m -Xmx512m" \
-v /kdata/elasticsearch01/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /kdata/elasticsearch01/data:/usr/share/elasticsearch/data \
-v /kdata/elasticsearch01/plugins:/usr/share/elasticsearch/plugins \
-v /kdata/elasticsearch01/logs:/usr/share/elasticsearch/logs \
-d elasticsearch:7.10.0
docker run --restart=always --name es02 \
-p 9201:9201 -p 9301:9301 \
--net mynetwork --ip 172.18.0.3 --privileged=true \
-e ES_JAVA_OPTS="-Xms512m -Xmx512m" \
-v /kdata/elasticsearch02/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /kdata/elasticsearch02/data:/usr/share/elasticsearch/data \
-v /kdata/elasticsearch02/plugins:/usr/share/elasticsearch/plugins \
-v /kdata/elasticsearch02/logs:/usr/share/elasticsearch/logs \
-d elasticsearch:7.10.0
配置elasticsearch.yml
http.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization
xpack.security.enabled: true
创建keystore
./bin/elasticsearch-keystore create
生成证书
./bin/elasticsearch-certutil ca
./bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12
bin/elasticsearch-keystore add xpack.security.transport.ssl.keystore.secure_password
bin/elasticsearch-keystore add xpack.security.transport.ssl.truststore.secure_password
移动证书到指定位置
docker cp es01:/usr/share/elasticsearch/elastic-certificates.p12 /kdata/elasticsearch01/config
docker cp es01:/usr/share/elasticsearch/elastic-stack-ca.p12 /kdata/elasticsearch01/config
docker cp es01:/usr/share/elasticsearch/config/elasticsearch.keystore /kdata/elasticsearch01/config
docker cp es02:/usr/share/elasticsearch/elastic-certificates.p12 /kdata/elasticsearch01/config
docker cp es02:/usr/share/elasticsearch/elastic-stack-ca.p12 /kdata/elasticsearch01/config
docker cp es02:/usr/share/elasticsearch/config/elasticsearch.keystore /kdata/elasticsearch01/config
docker cp /kdata/elasticsearch01/config/elastic-certificates.p12 es01:/usr/share/elasticsearch/config/
docker cp /kdata/elasticsearch01/config/elastic-stack-ca.p12 es01:/usr/share/elasticsearch/config/
docker cp /kdata/elasticsearch01/config/elasticsearch.keystore es01:/usr/share/elasticsearch/config/
docker cp /kdata/elasticsearch02/config/elastic-certificates.p12 es02:/usr/share/elasticsearch/config/
docker cp /kdata/elasticsearch02/config/elastic-stack-ca.p12 es02:/usr/share/elasticsearch/config/
docker cp /kdata/elasticsearch02/config/elasticsearch.keystore es02:/usr/share/elasticsearch/config/
mv elastic-certificates.p12 elastic-stack-ca.p12 config
cd config
--授权(可不设置)
chmod 777 elastic-certificates.p12
chmod 777 elastic-stack-ca.p12
chmod 777 elasticsearch.keystore
sudo vi /etc/sysctl.conf
文件添加
vm.max_map_count=262144
执行
sudo sysctl -p
systemctl restart docker
--查看日志
docker logs -f --tail=10 es01
docker logs -f --tail=10 es02
再次配置elasticsearch.yml(具体ip需各自调整)
cluster.name: escluster
node.name: es01
node.master: true
node.data: true
node.max_local_storage_nodes: 2
network.host: 0.0.0.0
network.publish_host: 192.168.31.129
http.port: 9200
transport.tcp.port: 9300
discovery.seed_hosts: ["192.168.31.129:9300","192.168.31.129:9301"]
cluster.initial_master_nodes: ["192.168.31.129:9300","192.168.31.129:9301"]
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12
重置密码
./bin/elasticsearch-setup-passwords interactive
默认账号
Changed password for user [apm_system]
Changed password for user [kibana_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]
分词器下载地址
https://github.com/medcl/elasticsearch-analysis-ik/releases
文件上传通道下载地址
https://www.elastic.co/guide/en/elasticsearch/plugins/current/ingest-attachment.html
查看集群地址:
http://192.168.31.129:9200/_cat/nodes