技术标签: elasticsearch 运维
主机名 | IP地址 | 操作系统 | es版本 |
---|---|---|---|
es1 | 192.168.10.180 | Centos 7 | elasticsearch7.8.0 |
es2 | 192.168.10.181 | Centos 7 | elasticsearch7.8.0 |
[root@es1 ~]# ls
elasticsearch-7.8.0-linux-x86_64.tar.gz
[root@es1 ~]# ls
elasticsearch-7.8.0-linux-x86_64.tar.gz
[root@es1 ~]# tar xf elasticsearch-7.8.0-linux-x86_64.tar.gz
[root@es1 ~]# useradd es && passwd es
Changing password for user es.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@es1 ~]# mv elasticsearch-7.8.0 elasticsearch
[root@es1 ~]# chown -R es:es elasticsearch
[root@es1 ~]#
[root@es1 ~]# mv elasticsearch /data/
[root@es1 ~]# cd /data/
[root@es1 data]# ls
elasticsearch
[root@es1 data]# cd /data/elasticsearch/config/
[root@es1 config]# vim elasticsearch.yml
[root@es1 config]# cat elasticsearch.yml
node.name: node-1 ##节点名称
path.data: /data/elasticsearch/data ##数据存放路径
path.logs: /data/elasticsearch/logs ##日志存放路径
bootstrap.memory_lock: true ##避免es使用swap交换分区
indices.requests.cache.size: 5% ##缓存配置
indices.queries.cache.size: 10% ##缓存配置
network.host: 192.168.10.180 ##本机IP
http.port: 9200 ##默认端口
cluster.initial_master_nodes: ["node-1"] ##设置符合主节点条件的节点的主机名或 IP 地址来引导启动集群
http.cors.enabled: true ##跨域
http.cors.allow-origin: "*" ##跨域
[root@es1 config]# su es
[es@es1 config]$ cd ../bin/
[es@es1 bin]$ ./elasticsearch -d
could not find java in JAVA_HOME at /usr/local/java/bin/java
解决方法:
方法1:配置文件中添加jdk判断(将JAVA_HOME改为ES_JAVA_HOME)
[es@es1 bin]$ grep "JAVA_HOME" elasticsearch-env
ES_JAVA_HOME="/data/elasticsearch/jdk/"
if [ ! -z "$ES_JAVA_HOME" ]; then
JAVA="$ES_JAVA_HOME/bin/java"
JAVA_TYPE="ES_JAVA_HOME"
方法2:在环境变量中添加es自带的jdk
[root@es2 ~]# grep "JAVA_HOME" /etc/profile
export JAVA_HOME=/data/elasticsearch/jdk/
export PATH=$JAVA_HOME/bin:$PATH
[es@es1 bin]$ ./elasticsearch -d
[es@es1 bin]$ ERROR: [3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: memory locking requested for elasticsearch process but memory is not locked
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
ERROR: Elasticsearch did not exit normally - check the logs at /data/elasticsearch/logs/elasticsearch.log
解决方法:优化(只给结果,想了解自行百度)
[root@es1 config]# grep -v "#" /etc/security/limits.conf
* hard memlock unlimited
* soft memlock unlimited
* hard nofile 1024000
* soft nofile 1024000
* hard nproc 1024000
* soft nproc 1024000
[root@es1 config]# grep -v "#" /etc/systemd/system.conf
[Manager]
DefaultLimitNOFILE=65536
DefaultLimitNPROC=32000
DefaultLimitMEMLOCK=infinity
[root@es1 config]# grep -v "#" /etc/sysctl.conf
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.core.somaxconn = 65535
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 5
fs.inotify.max_user_watches = 1048576
fs.inotify.max_user_instances = 256
net.ipv4.tcp_keepalive_time = 30
net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_max_tw_buckets = 256000
vm.max_map_count = 262144
net.core.netdev_max_backlog = 262144
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_syn_retries = 1
##加载配置(ulimit修改完需要断开连接,重开终端)
[root@es1 config]# /bin/systemctl daemon-reload
[root@es1 config]# /sbin/sysctl -p
启动成功
[root@es1 ~]# su es
[es@es1 root]$ cd /data/elasticsearch/bin/
[es@es1 bin]$ ./elasticsearch -d
[es@es1 bin]$ ps -ef | grep elas
es 9544 1 99 16:27 pts/0 00:00:24 /data/elasticsearch/jdk//bin/java -Xshare:auto -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -XX:+ShowCodeDetailsInExceptionMessages -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dio.netty.allocator.numDirectArenas=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Djava.locale.providers=SPI,COMPAT -Xms1g -Xmx1g -XX:+UseG1GC -XX:G1ReservePercent=25 -XX:InitiatingHeapOccupancyPercent=30 -Djava.io.tmpdir=/tmp/elasticsearch-12986234859914472880 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=data -XX:ErrorFile=logs/hs_err_pid%p.log -Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m -XX:MaxDirectMemorySize=536870912 -Des.path.home=/data/elasticsearch -Des.path.conf=/data/elasticsearch/config -Des.distribution.flavor=default -Des.distribution.type=tar -Des.bundled_jdk=true -cp /data/elasticsearch/lib/* org.elasticsearch.bootstrap.Elasticsearch -d
es 9655 9544 0 16:27 pts/0 00:00:00 /data/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller
es 10179 9050 0 16:27 pts/0 00:00:00 grep --color=auto elas
[es@es1 bin]$
[root@es1 ~]# cat /data/elasticsearch/config/elasticsearch.yml
cluster.name: es-cluster ##集群名称,所有集群下应用名称需一致,若名称一致则会自动加入集群
node.name: node-1
path.data: /data/elasticsearch/data
path.logs: /data/elasticsearch/logs
bootstrap.memory_lock: true
indices.requests.cache.size: 5%
indices.queries.cache.size: 10%
network.host: 192.168.10.180
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["192.168.10.180:9300", "192.168.10.181:9300"] ##集群内部监听的tcp端口号,默认9300
cluster.initial_master_nodes: ["node-1","node-2"]
http.cors.enabled: true
http.cors.allow-origin: "*"
[root@es2 config]# cat /data/elasticsearch/config/elasticsearch.yml
cluster.name: es-cluster
node.name: node-2
path.data: /data/elasticsearch/data
path.logs: /data/elasticsearch/logs
network.host: 192.168.10.181
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["192.168.10.180:9300", "192.168.10.181:9300"]
cluster.initial_master_nodes: ["node-1", "node-2"]
bootstrap.memory_lock: true
indices.requests.cache.size: 5%
indices.queries.cache.size: 10%
http.cors.enabled: true
http.cors.allow-origin: "*"
[root@es2 config]#
[es@es1 bin]$ ps -ef | grep elas
es 16253 1 10 16:50 pts/0 00:00:42 /data/elasticsearch/jdk//bin/java -Xshare:auto -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -XX:+ShowCodeDetailsInExceptionMessages -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dio.netty.allocator.numDirectArenas=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Djava.locale.providers=SPI,COMPAT -Xms1g -Xmx1g -XX:+UseG1GC -XX:G1ReservePercent=25 -XX:InitiatingHeapOccupancyPercent=30 -Djava.io.tmpdir=/tmp/elasticsearch-8972888888703564096 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=data -XX:ErrorFile=logs/hs_err_pid%p.log -Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m -XX:MaxDirectMemorySize=536870912 -Des.path.home=/data/elasticsearch -Des.path.conf=/data/elasticsearch/config -Des.distribution.flavor=default -Des.distribution.type=tar -Des.bundled_jdk=true -cp /data/elasticsearch/lib/* org.elasticsearch.bootstrap.Elasticsearch -d
es 16353 16253 0 16:50 pts/0 00:00:00 /data/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller
es 31076 12154 0 16:56 pts/0 00:00:00 grep --color=auto elas
[es@es1 bin]$ kill -9 16253
[es@es1 bin]$ ./elasticsearch -d
[es@es1 bin]$ curl http://192.168.10.180:9200/_cat/nodes?v
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
192.168.10.180 36 98 7 0.31 0.15 0.14 dilmrt * node-1
[es@es1 bin]$ ^C
[es@es1 bin]$ curl http://192.168.10.180:9200/_cat/nodes?v
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
192.168.10.180 38 98 3 0.19 0.15 0.14 dilmrt * node-1
192.168.10.181 36 78 4 0.29 0.10 0.07 dilmrt - node-2
[es@es1 bin]$ ./elasticsearch-certutil cert -out config/elastic-certificates.p12 -pass ""
This tool assists you in the generation of X.509 certificates and certificate
signing requests for use with SSL/TLS in the Elastic stack.
The 'cert' mode generates X.509 certificate and private keys.
* By default, this generates a single certificate and key for use
on a single instance.
* The '-multiple' option will prompt you to enter details for multiple
instances and will generate a certificate and key for each one
* The '-in' option allows for the certificate generation to be automated by describing
the details of each instance in a YAML file
* An instance is any piece of the Elastic Stack that requires an SSL certificate.
Depending on your configuration, Elasticsearch, Logstash, Kibana, and Beats
may all require a certificate and private key.
* The minimum required value for each instance is a name. This can simply be the
hostname, which will be used as the Common Name of the certificate. A full
distinguished name may also be used.
* A filename value may be required for each instance. This is necessary when the
name would result in an invalid file or directory name. The name provided here
is used as the directory name (within the zip) and the prefix for the key and
certificate files. The filename is required if you are prompted and the name
is not displayed in the prompt.
* IP addresses and DNS names are optional. Multiple values can be specified as a
comma separated string. If no IP addresses or DNS names are provided, you may
disable hostname verification in your SSL configuration.
* All certificates generated by this tool will be signed by a certificate authority (CA).
* The tool can automatically generate a new CA for you, or you can provide your own with the
-ca or -ca-cert command line options.
By default the 'cert' mode produces a single PKCS#12 output file which holds:
* The instance certificate
* The private key for the instance certificate
* The CA certificate
If you specify any of the following options:
* -pem (PEM formatted output)
* -keep-ca-key (retain generated CA key)
* -multiple (generate multiple certificates)
* -in (generate certificates from an input file)
then the output will be be a zip file containing individual certificate/key files
Certificates written to /data/elasticsearch/config/elastic-certificates.p12
This file should be properly secured as it contains the private key for
your instance.
This file is a self contained file and can be copied and used 'as is'
For each Elastic product that you wish to configure, you should copy
this '.p12' file to the relevant configuration directory
and then follow the SSL configuration instructions in the product guide.
[es@es1 bin]$ cd ../config/
[es@es1 config]$ chmod 755 elastic-certificates.p12
[es@es1 config]$ scp elastic-certificates.p12 192.168.10.181:/data/elasticsearch/config/
[es@es1 config]$ cat /data/elasticsearch/config/elasticsearch.yml
cluster.name: es-cluster
node.name: node-1
path.data: /data/elasticsearch/data
path.logs: /data/elasticsearch/logs
bootstrap.memory_lock: true
indices.requests.cache.size: 5%
indices.queries.cache.size: 10%
network.host: 192.168.10.180
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["192.168.10.180:9300","192.168.10.181:9300"]
cluster.initial_master_nodes: ["node-1","node-2"]
http.cors.enabled: true
http.cors.allow-origin: "*"
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
[es@es1 config]$ ps -ef | grep elas
es 4477 12154 0 17:13 pts/0 00:00:00 grep --color=auto elas
es 31755 1 4 16:57 pts/0 00:00:49 /data/elasticsearch/jdk//bin/java -Xshare:auto -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -XX:+ShowCodeDetailsInExceptionMessages -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dio.netty.allocator.numDirectArenas=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Djava.locale.providers=SPI,COMPAT -Xms1g -Xmx1g -XX:+UseG1GC -XX:G1ReservePercent=25 -XX:InitiatingHeapOccupancyPercent=30 -Djava.io.tmpdir=/tmp/elasticsearch-12887036096412054470 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=data -XX:ErrorFile=logs/hs_err_pid%p.log -Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m -XX:MaxDirectMemorySize=536870912 -Des.path.home=/data/elasticsearch -Des.path.conf=/data/elasticsearch/config -Des.distribution.flavor=default -Des.distribution.type=tar -Des.bundled_jdk=true -cp /data/elasticsearch/lib/* org.elasticsearch.bootstrap.Elasticsearch -d
es 31854 31755 0 16:57 pts/0 00:00:00 /data/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller
[es@es1 config]$ kill -9 31755
[es@es1 config]$ cd ../bin/
[es@es1 bin]$ ./elasticsearch -d
创建密码(最少6位)
[es@es1 bin]$ ./elasticsearch-setup-passwords interactive
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_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_system]:
Reenter password for [kibana_system]:
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_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]
测试
[es@es1 bin]$ curl -u "elastic:123456" http://192.168.10.180:9200/_cat/nodes?v
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
192.168.10.181 13 79 5 0.82 0.88 0.65 dilmrt - node-2
192.168.10.180 14 98 5 0.10 0.14 0.12 dilmrt * node-1
-u 是现在的密码
-d 是将要修改成的密码
[es@es1 bin]$ curl -u "elastic:123456" http://192.168.10.180:9200/_cat/nodes?v
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
192.168.10.181 13 79 5 0.82 0.88 0.65 dilmrt - node-2
192.168.10.180 14 98 5 0.10 0.14 0.12 dilmrt * node-1
[es@es1 bin]$ curl -H "Content-Type:application/json" -XPOST -u elastic:123456 'http://192.168.10.180:9200/_xpack/security/user/elastic/_password' -d '{ "password" : "1234567" }'
{
}
[es@es1 bin]$ curl -u "elastic:123456" http://192.168.10.180:9200/_cat/nodes?v{
"error":{
"root_cause":[{
"type":"security_exception","reason":"unable to authenticate user [elastic] for REST request [/_cat/nodes?v]","header":{
"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}}],"type":"security_exception","reason":"unable to authenticate user [elastic] for REST request [/_cat/nodes?v]","header":{
"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}},"status":401}
[es@es1 bin]$ curl -u "elastic:1234567" http://192.168.10.180:9200/_cat/nodes?v
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
192.168.10.181 33 79 3 0.06 0.48 0.57 dilmrt - node-2
192.168.10.180 34 98 3 0.45 0.19 0.15 dilmrt * node-1
创建超级用户
[es@es1 bin]$ ./elasticsearch-users useradd myname -p mypassword -r superuser
[es@es1 bin]$ curl -u myname:mypassword -XPUT 'http://192.168.10.180:9200/_xpack/security/user/elastic/_password?pretty' -H 'Content-Type: application/json' -d '{"password" : "12345678"}'
{
}
[es@es1 bin]$ curl -u "elastic:1234567" http://192.168.10.180:9200/_cat/nodes?v{
"error":{
"root_cause":[{
"type":"security_exception","reason":"unable to authenticate user [elastic] for REST request [/_cat/nodes?v]","header":{
"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}}],"type":"security_exception","reason":"unable to authenticate user [elastic] for REST request [/_cat/nodes?v]","header":{
"WWW-Authenticate":"Basic realm=\"security\" charset=\"UTF-8\""}},"status":401}
[es@es1 bin]$ curl -u "elastic:12345678" http://192.168.10.180:9200/_cat/nodes?vip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
192.168.10.181 50 79 3 0.00 0.18 0.41 dilmrt - node-2
192.168.10.180 50 98 3 0.95 0.65 0.36 dilmrt * node-1
[es@es1 bin]$
[root@localhost data]# ps -ef | grep elas
es 26795 1 4 15:21 ? 00:02:00 /usr/local/java/bin/java -Xshare:auto -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dio.netty.allocator.numDirectArenas=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Djava.locale.providers=SPI,JRE -Xms3g -Xmx3g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -Djava.io.tmpdir=/tmp/elasticsearch-3796414330494870773 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=data -XX:ErrorFile=logs/hs_err_pid%p.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -Xloggc:logs/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=32 -XX:GCLogFileSize=64m -XX:MaxDirectMemorySize=1610612736 -Des.path.home=/data/elasticsearch -Des.path.conf=/data/elasticsearch/config -Des.distribution.flavor=default -Des.distribution.type=tar -Des.bundled_jdk=true -cp /data/elasticsearch/lib/* org.elasticsearch.bootstrap.Elasticsearch -d
es 26823 26795 0 15:21 ? 00:00:00 /data/elasticsearch/modules/x-pack-ml/platform/linux-x86_64/bin/controller
root 29695 29495 0 16:05 pts/1 00:00:00 grep --color=auto elas
[root@localhost data]# pkill -9 java
[root@localhost data]# ps -ef | grep elas
root 29752 29495 0 16:06 pts/1 00:00:00 grep --color=auto elas
[root@localhost ~]# tar xf elasticsearch-7.16.2-linux-x86_64.tar.gz
[root@localhost ~]# mv elasticsearch-7.16.2 /data/elasticsearch
[root@localhost data]# cat /data/elasticsearch7.8.0/config/elasticsearch.yml > /data/elasticsearch/config/elasticsearch.yml
[root@localhost data]# cp -a /data/elasticsearch7.8.0/data /data/elasticsearch/
[root@localhost data]# cp -a /data/elasticsearch7.8.0/es_backup /data/elasticsearch/
[root@localhost config]# cp -a /data/elasticsearch7.8.0/config/elastic-certificates.p12 /data/elasticsearch/config/
[root@localhost data]# chown -R es:es /data/elasticsearch
[root@localhost config]# su es
[es@localhost config]$ cd /data/elasticsearch/bin/
[es@localhost bin]$ ./elasticsearch -d
[es@localhost bin]$ curl -u elastic:123456 http://192.168.10.180:9200
{
"name" : "node-1",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "JFPQN70-RLaRCUIGYS5VuQ",
"version" : {
"number" : "7.16.2",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "2b937c44140b6559905130a8650c64dbd0879cfb",
"build_date" : "2021-12-18T19:42:46.604893745Z",
"build_snapshot" : false,
"lucene_version" : "8.10.1",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
[es@localhost bin]$ curl -u elastic:123456 http://192.168.10.180:9200/_cat/indices?v
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open .geoip_databases 1D0788VhT6u_Vg9G-22T5g 1 0 44 0 41.5mb 41.5mb
green open .security-7 StBKKdhJQ6ySV-2lH6yJsg 1 0 7 0 23.9kb 23.9kb
##该目录使用共享的方式(nfs,glusterfs)
[root@localhost data]# mkdir -p /data/elasticsearch/es_backup
[root@localhost data]# chown -R es:es /data/elasticsearch/es_backup
[root@localhost data]# curl -XPUT -u elastic:123456 'http://192.168.10.180:9200/_snapshot/my_backup' -H "Content-Type: application/json" -d '{
"type": "fs",
"settings": {
"location": "/data/elasticsearch/es_backup",
"compress": true
}
}'
{
"acknowledged":true}
curl -XGET -u elastic:'123456' 'http://192.168.10.180:9200/_snapshot/_all?
pretty' #查看所有仓库
curl -XGET -u elastic:'123456' 'http://192.168.10.180:9200/_cat/repositories?v'
#查看仓库列表
curl -XGET -u elastic:'123456'
'http://192.168.10.180:9200/_snapshot/my_backup' #查看指定仓库
curl -XDELETE -u elastic:'123456'
'http://192.168.10.180:9200/_snapshot/my_backup?pretty' #删除仓库
[root@localhost ~]# curl -XPUT -u elastic:123456 '192.168.10.180:9200/index-demo/test/1?pretty' -H 'content-Type:application/json' -d '{"user":"zhangsan","mesg":"hello world"}'
{
"_index" : "index-demo",
"_type" : "test",
"_id" : "1",
"_version" : 1,
"result" : "created",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"_seq_no" : 0,
"_primary_term" : 1
}
[root@localhost ~]# curl -u elastic:'123456' "192.168.10.180:9200/_cat/indices?v"health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open .geoip_databases 1D0788VhT6u_Vg9G-22T5g 1 0 44 0 41.5mb 41.5mb
green open .security-7 StBKKdhJQ6ySV-2lH6yJsg 1 0 7 0 23.9kb 23.9kb
yellow open index-demo l9gCn03zQ0qR7kbU3XEA9Q 1 1 1 0 4.5kb 4.5kb
[root@localhost ~]# curl -X PUT -u elastic:'123456' "192.168.10.180:9200/_snapshot/my_backup/es_backup-20220330?wait_for_completion=true&pretty"
{
"snapshot" : {
"snapshot" : "es_backup-20220330",
"uuid" : "Tv1hwsGRQpS5duLRYap39w",
"repository" : "my_backup",
"version_id" : 7160299,
"version" : "7.16.2",
"indices" : [
".ds-.logs-deprecation.elasticsearch-default-2022.03.30-000001",
".ds-ilm-history-5-2022.03.30-000001",
".security-7",
"index-demo",
".geoip_databases"
],
"data_streams" : [
"ilm-history-5",
".logs-deprecation.elasticsearch-default"
],
"include_global_state" : true,
"state" : "SUCCESS",
"start_time" : "2022-03-30T02:51:29.910Z",
"start_time_in_millis" : 1648608689910,
"end_time" : "2022-03-30T02:51:30.111Z",
"end_time_in_millis" : 1648608690111,
"duration_in_millis" : 201,
"failures" : [ ],
"shards" : {
"total" : 5,
"failed" : 0,
"successful" : 5
},
"feature_states" : [
{
"feature_name" : "geoip",
"indices" : [
".geoip_databases"
]
},
{
"feature_name" : "security",
"indices" : [
".security-7"
]
}
]
}
}
## 监视任何当前正在运行的快照
curl -XGET -u elastic:'123456'
"http://192.168.10.180:9200/_snapshot/my_backup/_current?pretty"
## 要获得参与任何当前正在运行的快照的每个分片的完整细分
curl -XGET -u elastic:'123456' 'http://192.168.10.180:9200/_snapshot/_status'
## 查看仓库中所有的镜像
curl -XGET -u elastic:'123456'
'http://192.168.10.180:9200/_snapshot/my_backup/_all?pretty'
## 获取特定存储库中的快照列表,这也会返回每个快照的内容。
curl -X GET -u elastic:'123456' "192.168.10.180:9200/_snapshot/my_backup/*?
verbose=false&pretty"
## 删除指定镜像
curl -X DELETE -u elastic:'123456'
"192.168.10.180:9200/_snapshot/my_backup/es_backup-20220330"
[root@localhost ~]# curl -X DELETE -u elastic:123456 "192.168.10.180:9200/index-demo"
{
"acknowledged":true}
[root@localhost ~]# curl -u elastic:'123456' "192.168.10.180:9200/_cat/indices?v"
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open .geoip_databases 1D0788VhT6u_Vg9G-22T5g 1 0 44 0 41.5mb 41.5mb
green open .security-7 StBKKdhJQ6ySV-2lH6yJsg 1 0 7 0 23.9kb 23.9kb
[root@localhost ~]# curl -X GET -u elastic:'123456' "192.168.10.180:9200/_snapshot/my_backup/*?verbose=false&pretty"
{
"snapshots" : [
{
"snapshot" : "es_backup-20220329",
"uuid" : "vfgjBu5tScCQzdNlP0swaA",
"repository" : "my_backup",
"indices" : [
".geoip_databases",
".security-7"
],
"data_streams" : [ ],
"state" : "SUCCESS"
},
{
"snapshot" : "es_backup-20220330",
"uuid" : "Tv1hwsGRQpS5duLRYap39w",
"repository" : "my_backup",
"indices" : [
".ds-.logs-deprecation.elasticsearch-default-2022.03.30-000001",
".ds-ilm-history-5-2022.03.30-000001",
".geoip_databases",
".security-7",
"index-demo"
],
"data_streams" : [ ],
"state" : "SUCCESS"
}
],
"total" : 2,
"remaining" : 0
}
[root@localhost ~]# curl -X POST -u elastic:'123456' "192.168.10.180:9200/_snapshot/my_backup/es_backup-20220330/_restore?pretty" -H 'Content-Type: application/json' -d' { "indices": "index-demo" }'
{
"accepted" : true
}
[root@localhost ~]# curl -u elastic:'123456' "192.168.10.180:9200/_cat/indices?v" health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open .geoip_databases 1D0788VhT6u_Vg9G-22T5g 1 0 44 0 41.5mb 41.5mb
green open .security-7 StBKKdhJQ6ySV-2lH6yJsg 1 0 7 0 23.9kb 23.9kb
yellow open index-demo j9Y6KTE8QiSuUCMdW6pn1g 1 1 1 0 4.5kb 4.5kb
异机需要创建镜像仓库和复制一份文件到仓库底下
[root@mysql2 indices]# curl -XPUT -u elastic:123456 'http://192.168.10.181:9200/_snapshot/my_backup' -H "Content-Type: application/json" -d '{
"type": "fs",
"settings": {
"location": "/data/elasticsearch/es_backup",
"compress": true
}
}'
{"acknowledged":true}[root@mysql2 indices]#
[root@mysql2 indices]#
[root@mysql2 indices]#
[root@mysql2 indices]# curl -X GET -u elastic:'123456' "192.168.10.181:9200/_snapshot/my_backup/*?verbose=false&pretty"{
"snapshots" : [
{
"snapshot" : "es_backup-20220329",
"uuid" : "vfgjBu5tScCQzdNlP0swaA",
"repository" : "my_backup",
"indices" : [
".geoip_databases",
".security-7"
],
"data_streams" : [ ],
"state" : "SUCCESS"
},
{
"snapshot" : "es_backup-20220330",
"uuid" : "Tv1hwsGRQpS5duLRYap39w",
"repository" : "my_backup",
"indices" : [
".ds-.logs-deprecation.elasticsearch-default-2022.03.30-000001",
".ds-ilm-history-5-2022.03.30-000001",
".geoip_databases",
".security-7",
"index-demo"
],
"data_streams" : [ ],
"state" : "SUCCESS"
}
],
"total" : 2,
"remaining" : 0
}
[root@mysql2 ~]# curl -u elastic:'123456' "192.168.10.181:9200/_cat/indices?v"
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open .geoip_databases jrIHBN1KTfqDAgKKeFZP8w 1 0 40 0 38mb 38mb
green open .security-7 Ahj0JDaARPq-OslsHxhohw 1 0 7 0 25.7kb 25.7kb
[root@mysql2 ~]# curl -X POST -u elastic:'123456' "192.168.10.181:9200/_snapshot/my_backup/es_backup-20220330/_restore?pretty" -H 'Content-Type: application/json' -d' { "indices": "index-demo" }'
{
"accepted" : true
}
[root@mysql2 ~]# curl -u elastic:'123456' "192.168.10.181:9200/_cat/indices?v"
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open .geoip_databases jrIHBN1KTfqDAgKKeFZP8w 1 0 40 0 38mb 38mb
green open .security-7 Ahj0JDaARPq-OslsHxhohw 1 0 7 0 25.7kb 25.7kb
yellow open index-demo 5-bajJbvSYyjODxAxFntQA 1 1 1 0 4.5kb 4.5kb
[root@mysql2 ~]#
文章浏览阅读74次。思路:num%r得到末位r进制数,num/r得到num去掉末位r进制数后的数字。得到的末位r进制数采用头插法插入链表中,更新num的值,循环计算,直到num为0,最后输出链表。//重置,s指针与头指针指向同一处。//更新num的值,至num为0退出循环。//末位r进制数存入s数据域中。//头插法插入链表中(无头结点)//定义头指针为空,s指针。= NULL) //s不为空,输出链表,栈先入后出。
文章浏览阅读176次。武汉芯源半导体积极参与推动中国的大学教育改革以及注重电子行业的人才培养,建立以企业为主体、市场为导向、产学研深度融合的技术创新体系。2023年3月,武汉芯源半导体开发者扶持计划正式开始进行,以打造更为丰富的CW32生态社区。_cw32开发者扶持计划申请
文章浏览阅读5.7k次。2014年底买的一块2TB希捷机械硬盘ST2000DM001-1ER164,用了两年更换了主板、CPU等,后来出现开机不识别的情况,具体表现为:关机后开机,找不到硬盘,就进入BIOS了,只要在BIOS状态下待机半分钟左右再重启,硬盘就会出现。进入系统后,重启(这个过程中主板对硬盘始终处于供电状态),也不会出现不识别硬盘的现象。就好像是硬盘或主板上某个电容坏了一样,刚开始给硬盘通电的N秒钟内电容未能..._st2000dm001不认盘
文章浏览阅读1.5k次。ADO.NET的数据源不单单是DB,也可以是XML、ExcelADO.NET连接数据源有两种交互模式:连接模式和断开模式两个对应的组件:数据提供程序(数据提供者)&DataSetSqlConnectionStringBuilder——连接字符串Connection对象用于开启程序和数据库之间的连接public SqlConnection c..._列举ado.net在操作数据库时,常用的对象及作用
文章浏览阅读113次。【代码】Android 自定义对话框不能铺满全屏。_android dialog宽度不铺满
文章浏览阅读331次。Redis的主从集群与哨兵模式Redis的主从模式全量同步增量同步Redis主从同步策略流程redis主从部署环境哨兵模式原理哨兵模式概述哨兵模式的作用哨兵模式项目部署Redis的主从模式1、Redis虽然读取写入的速度都特别快,但是也会产生读压力特别大的情况。2、为了分担读压力,Redis支持主从复制,保证主数据库的数据内容和从数据库的内容完全一致。3、Redis的主从结构可以采用一主多从或者级联结构,Redis主从复制可以根据是否是全量分为全量同步和增量同步。全量同步Redis全量复制一般发_redis的主从和哨兵集群
文章浏览阅读116次。作者:brightwang原文:https://www.jianshu.com/p/ab9aa8d4df7d最近我遇到了一个bug,我试着通过Rails在以“utf8”编码的MariaDB中保存一个UTF-8字符串,然后出现了一个离奇的错误:Incorrect string value: ‘ð 我用的是UTF-8编码的客户端,服务器也是UTF-8编码的,数据库也是,就连要保存的这个字符串“????..._mysql utf8的作用
文章浏览阅读278次。毕业这么久了,最近闲来准备把毕设过程中的代码整理公开一下,所有代码其实都是网上找的,但都是经过调试能跑通的,希望对需要的人有用。PS:里边很多注释不讲什么意思了,能看懂的自然能看懂。_matlab图像比较
文章浏览阅读73次。思路: screen分为普通和复杂两种,普通的功能大部分是页面跳转以及简单的crud数据,复杂的单独弄出来 跳转普通的screen,直接根据配置文件调整设置<layouts> <loyout screenId="0" bg="bg_start" name="start" defaultWinId="" bgm="" remark=""> ..._libgdx ui 布局
文章浏览阅读3k次,点赞2次,收藏13次。playwright-python 处理Text input和Checkboxs 和 radio buttonsText input输入框输入元素,直接用fill方法即可,支持 ,,[contenteditable] 和<label>这些标签,如下代码:page.fill('#name', 'Peter');# 日期输入page.fill('#date', '2020-02-02')# 时间输入page.fill('#time', '13-15')# 本地日期时间输入p_playwright checkbox
文章浏览阅读596次,点赞5次,收藏6次。这是我看到最最详细的安装说明文章了,必须要给赞!学习了,也配置了,成功的一批!真不知道还有什么可补充的了,在此做个推广,喜欢的小伙伴,走起!_win10 php 安装swoole
文章浏览阅读1k次。今天想实现页面的自适应,本来用的是栅格,但效果不理想,就想起了rem布局。以前使用rem布局,都是在原生html里,还没在框架里使用过,百度没百度出来,就自己琢磨,不知道方法规范不规范,反正成功了,操作如下:1、下载flexible.js2、引入到angular项目里3、根据自己的需要修改细节3.1、在flexible.js里修改每份的像素,3.2、引入cssrem插件,在设置里设..._angular 使用rem