Filebeat对接ES加密集群
#查看集群状态
[09:22:25 root@elk1:~]#curl 10.0.0.91:9200/_cat/nodes -u elastic:123456
1.编写配置文件
[09:52:06 root@elk3:/etc/filebeat]#vim 12-log-to-es_tls.yamlfilebeat.inputs:
- type: logpaths:- /var/log/nginx/access.log*json.keys_under_root: true# 不采集以".gz"结尾的文件exclude_files: ['\.gz$']output.elasticsearch:hosts: ["http://10.0.0.91:9200","http://10.0.0.92:9200","http://10.0.0.93:9200"] index: "linux-nginx-tls-%{+yyyy.MM.dd}" # 指定连接ES集群的用户名username: elastic# 指定连接ES集群的密码password: "123456"setup.ilm.enabled: false
setup.template.name: "linux-nginx"
setup.template.pattern: "linux-nginx*"
setup.template.overwrite: false
setup.template.settings:index.number_of_shards: 3index.number_of_replicas: 02.启动filebeat实例
[09:50:36 root@elk3:/etc/filebeat]#rm -rf /var/lib/filebeat/
[09:51:10 root@elk3:/etc/filebeat]#filebeat -e -c 12-log-to-es_tls.yaml3.查看Kibana的WebUI
?Logstash对接ES加密集群
1.启动Logstash实例
[18:23:24 root@elk2:/etc/logstash/conf.d]#vim 15-beats-filter-es.confinput { beats {port => 8888}} filter {mutate {remove_field => [ "@version","log","tags","agent","ecs","input" ]}
}output { stdout { codec => rubydebug } elasticsearch {hosts => ["10.0.0.91:9200","10.0.0.92:9200","10.0.0.93:9200"]index => "linux-elfk-tls-%{+yyyy.MM.dd}"# 指定用户名user => "elastic"# 指定密码password => "123456"}}[18:25:15 root@elk2:/etc/logstash/conf.d]#logstash -rf 15-beats-filter-es.conf2.启动filebeat实例
[18:25:51 root@elk3:/etc/filebeat]#vim 13-log-to-logstash.yamlfilebeat.inputs:
- type: logpaths:- /var/log/nginx/access.log*json.keys_under_root: trueexclude_files: ['\.gz$']output.logstash:hosts: ["10.0.0.92:8888"][18:26:36 root@elk3:/etc/filebeat]#rm -rf /var/lib/filebeat/
[18:26:48 root@elk3:/etc/filebeat]#filebeat -e -c 13-log-to-logstash.yaml3.kibana查看数据验证
基于kibana实现RBAC实战
创建大索引
创建用户dev
创建用户ops
创建用户1
创建用户2
Filestream输入类型采集tomcat的JSON格式日志
1.修改tomcat的配置文件
[11:49:47 root@elk2:~]#vim /hehe/softwares/apache-tomcat-10.1.31/conf/server.xml
...<!-- 删除原有的hosts文件 --><Host name="tomcat.beijing.com" appBase="webapps"unpackWARs="true" autoDeploy="true"><Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"prefix="tomcat.beijing.com_access_log" suffix=".json"
pattern="{"clientip":"%h","ClientUser":"%l","authenticated":"%u","AccessTime":"%t","request":"%r","status":"%s","SendBytes":"%b","Query?string":"%q","partner":"%{Referer}i","http_user_agent":"%{User-Agent}i"}"/></Host>2.重启tomcat服务
[12:04:39 root@elk2:/etc/filebeat]#/hehe/softwares/apache-tomcat-10.1.31/bin/shutdown.sh [12:04:39 root@elk2:/etc/filebeat]#/hehe/softwares/apache-tomcat-10.1.31/bin/startup.sh 3.访问测试
[09:32:02 root@elk1:~]#curl -H 'host: tomcat.beijing.com' 10.0.0.92:80804.查看日志格式
[14:24:40 root@elk2:/etc/filebeat]#tail -f /hehe/softwares/apache-tomcat-10.1.31/logs/tomcat.beijing.com_access_log.2024-10-31.json
{"clientip":"10.0.0.91","ClientUser":"-","authenticated":"-","AccessTime":"[31/Oct/2024:14:23:47 +0800]","request":"GET / HTTP/1.1","status":"200","SendBytes":"11239","Query?string":"","partner":"-","http_user_agent":"curl/7.81.0"}5.启动filebeat实例
[root@elk92 filebeat]# cat 14-filestream-to-es.yaml
filebeat.inputs:
- type: filestreampaths:- /hehe/softwares/apache-tomcat-10.1.31/logs/tomcat.beijing.com_access_log*.json# 配置解析器parsers:# 对JSON格式进行解析- ndjson:# 将解析的记录放在指定字段,若指定字段为空(""),则表示将解析的字段放在顶级字段中target: ""#target: "linux"# 对指定字段进行解析message_key: messageoutput.elasticsearch:hosts: ["http://10.0.0.91:9200","http://10.0.0.92:9200","http://10.0.0.93:9200"] index: "linux-tomcat-filestream-%{+yyyy.MM.dd}" username: elasticpassword: "123456"setup.ilm.enabled: false
setup.template.name: "linux-tomcat"
setup.template.pattern: "linux-tomcat*"
setup.template.overwrite: true
setup.template.settings:index.number_of_shards: 5index.number_of_replicas: 0[12:09:04 root@elk2:/etc/filebeat]#rm -rf /var/lib/filebeat/
[12:09:08 root@elk2:/etc/filebeat]#filebeat -e -c 14-filestream-to-es.yaml6.kibana查看数据
Filebeat多行处理
1.创建错误
[15:08:42 root@elk2:~]#/hehe/softwares/apache-tomcat-10.1.31/bin/shutdown.sh [15:09:41 root@elk2:~]#vim /hehe/softwares/apache-tomcat-10.1.31/conf/server.xml
...
修改配置文件出错即可,启动服务时发现出错了
[15:10:27 root@elk2:~]#/hehe/softwares/apache-tomcat-10.1.31/bin/startup.sh发现报错如下:
[15:10:27 root@elk2:~]# tail -100f /hehe/softwares/apache-tomcat-10.1.31/logs/catalina.out ........................下面的是报错
31-Oct-2024 15:10:39.323 SEVERE [main] org.apache.tomcat.util.digester.Digester.fatalError Parse fatal error at line [151] column [17]org.xml.sax.SAXParseException; systemId: file:/hehe/softwares/apache-tomcat-10.1.31/conf/server.xml; lineNumber: 151; columnNumber: 17; The end-tag for element type "Host" must end with a '>' delimiter.at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:204)at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:178)at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400)at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1465)at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1710)at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2908)at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:635)at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:551)at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:890)at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:826)at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:134)at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1225)at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1522)at org.apache.catalina.startup.Catalina.parseServerXml(Catalina.java:603)at org.apache.catalina.startup.Catalina.load(Catalina.java:693)at org.apache.catalina.startup.Catalina.load(Catalina.java:731)at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)at java.base/java.lang.reflect.Method.invoke(Method.java:580)at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:302)at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:472)
31-Oct-2024 15:10:39.326 WARNING [main] org.apache.catalina.startup.Catalina.parseServerXml Unable to load server configuration from [/hehe/softwares/apache-tomcat-10.1.31/conf/server.xml]org.xml.sax.SAXParseException; systemId: file:/hehe/softwares/apache-tomcat-10.1.31/conf/server.xml; lineNumber: 151; columnNumber: 17; The end-tag for element type "Host" must end with a '>' delimiter.at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1252)at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1522)at org.apache.catalina.startup.Catalina.parseServerXml(Catalina.java:603)at org.apache.catalina.startup.Catalina.load(Catalina.java:693)at org.apache.catalina.startup.Catalina.load(Catalina.java:731)at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)at java.base/java.lang.reflect.Method.invoke(Method.java:580)at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:302)at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:472)2.filebeat采集错误日志
[15:12:40 root@elk2:/etc/filebeat]#vim 15-filestream-to-es.yamlfilebeat.inputs:
- type: filestreampaths:- /hehe/softwares/apache-tomcat-10.1.31/logs/catalina.out # 配置解析器parsers:# 配置多行匹配- multiline:# 指定多行匹配的类型,有效值: pattern 和 count# pattern:# 表示基于正则匹配将多行合并为一个事件(event)。# count:# 表示基于固定行数合并为一个事件(event)。type: pattern# 当type为pattern时,则需要定义对应的正则表达式pattern: '^\d{2}'# 下面2个选项参考官网示例: # https://www.elastic.co/guide/en/beats/filebeat/7.17/multiline-examples.html#multilinenegate: truematch: afteroutput.elasticsearch:hosts: ["http://10.0.0.91:9200","http://10.0.0.92:9200","http://10.0.0.93:9200"] index: "linux-tomcat-multiline-%{+yyyy.MM.dd}" username: elasticpassword: "123456"setup.ilm.enabled: false
setup.template.name: "linux-tomcat"
setup.template.pattern: "linux-tomcat*"
setup.template.overwrite: true
setup.template.settings:index.number_of_shards: 5index.number_of_replicas: 0[15:13:41 root@elk2:/etc/filebeat]#rm -rf /var/lib/filebeat/
[15:13:41 root@elk2:/etc/filebeat]# filebeat -e -c 15-filestream-to-es.yaml
多行匹配按行数匹配案例
1.源数据准备
[16:56:36 root@elk2:~]#vim /tmp/student.info{"name": "北京","hobby": ["东城区","西城区"]
}
{"name": "河北","hobby": ["石家庄","保定"]
}
{"name": "山东","hobby": ["青岛","淄博"]
}2.编写filebeat配置文件
[16:57:20 root@elk2:/etc/filebeat]#vim 16-filestream-to-es.yaml
filebeat.inputs:
- type: filestreampaths:- /tmp/student.info# 配置解析器parsers:- multiline:type: countcount_lines: 4- ndjson:target: ""message_key: messageoutput.elasticsearch:hosts: ["http://10.0.0.91:9200","http://10.0.0.92:9200","http://10.0.0.93:9200"] index: "linux-tomcat-student-%{+yyyy.MM.dd}" username: elasticpassword: "123456"setup.ilm.enabled: false
setup.template.name: "linux-tomcat"
setup.template.pattern: "linux-tomcat*"
setup.template.overwrite: true
setup.template.settings:index.number_of_shards: 5index.number_of_replicas: 0[16:58:35 root@elk2:/etc/filebeat]#rm -rf 15-beats-filter-es.conf
[16:58:39 root@elk2:/etc/filebeat]#filebeat -e -c 16-filestream-to-es.yaml3.kibana查看数据
ElasticSearch的JVM调优
1.ES集群的堆内存配置
推荐设置为物理内存的一半,但是不能超过32GB。2.查看默认的JVM
[17:35:21 root@elk1:~]#free -htotal used free shared buff/cache available
Mem: 3.8Gi 2.9Gi 100Mi 1.0Mi 818Mi 669Mi
Swap: 3.8Gi 0.0Ki 3.8Gi[17:35:49 root@elk1:~]#ps -ef | egrep "Xmx|Xms"
....................-Xms1938m -Xmx1938m.................3.修改所有节点的ES配置
vim /etc/elasticsearch/jvm.options
...
-Xms256m
-Xmx256m4.重启ES服务(所有节点)
systemctl restart elasticsearch.service 5.验证是否修改成功(所有节点)
[17:39:27 root@elk1:~]#ps -ef | egrep "Xmx|Xms"
................... -Xms256m -Xmx256m..................[17:39:12 root@elk1:~]#free -htotal used free shared buff/cache available
Mem: 3.8Gi 1.0Gi 1.9Gi 1.0Mi 882Mi 2.6Gi
Swap: 3.8Gi 0.0Ki 3.8Gi6.所有节点重复上述步骤验证:
[root@elk92 filebeat]# curl -u elastic:123456 10.0.0.91:9200/_cat/nodes
10.0.0.92 68 43 15 0.79 0.38 0.14 cdfhilmrstw * elk92
10.0.0.91 73 59 83 1.19 0.35 0.12 cdfhilmrstw - elk91
10.0.0.93 58 51 28 0.57 0.23 0.08 cdfhilmrstw - elk93
Zookeeper集群搭建
单点搭建
1.下载zookeeper
[19:14:52 root@elk1:~]#wget https://dlcdn.apache.org/zookeeper/zookeeper-3.8.4/apache-zookeeper-3.8.4-bin.tar.gz[19:14:52 root@elk1:~]# wget http://192.168.13.253/Resources/ElasticStack/softwares/apache-zookeeper-3.8.4-bin.tar.gz2.解压软件包
[19:14:52 root@elk1:~]#mkdir -pv /hehe/softwares[19:14:52 root@elk1:~]# tar xf apache-zookeeper-3.8.4-bin.tar.gz -C /hehe/softwares3.准备配置文件
[19:15:23 root@elk1:~]#cp /hehe/softwares/apache-zookeeper-3.8.4-bin/conf/zoo{_sample,}.cfg [19:15:50 root@elk1:~]#ll /hehe/softwares/apache-zookeeper-3.8.4-bin/conf/zoo{_sample,}.cfg
-rw-r--r-- 1 root root 1183 Oct 31 19:15 /hehe/softwares/apache-zookeeper-3.8.4-bin/conf/zoo.cfg
-rw-r--r-- 1 elk elk 1183 Feb 13 2024 /hehe/softwares/apache-zookeeper-3.8.4-bin/conf/zoo_sample.cfg4.添加环境变量
[19:15:51 root@elk1:~]#vim /etc/profile.d/zk.sh
#!/bin/bashexport JAVA_HOME=/usr/share/elasticsearch/jdk
export ZK_HOME=/hehe/softwares/apache-zookeeper-3.8.4-bin
export PATH=$PATH:${ZK_HOME}/bin:$JAVA_HOME/bin
[19:16:54 root@elk1:~]#source /etc/profile.d/zk.sh5.启动zookeeper单点
[19:16:59 root@elk1:~]#zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /hehe/softwares/apache-zookeeper-3.8.4-bin/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED6.查看服务状态
[19:17:17 root@elk1:~]#zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /hehe/softwares/apache-zookeeper-3.8.4-bin/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: standalone7.连接本地的zookeeper服务
[19:17:28 root@elk1:~]#zkCli.sh
...
[zk: localhost:2181(CONNECTED) 0]
[zk: localhost:2181(CONNECTED) 0] ls /
[zookeeper]
[zk: localhost:2181(CONNECTED) 1] [19:17:28 root@elk1:~]# zkCli.sh -server 10.0.0.91:2181
...
[zk: 10.0.0.91:2181(CONNECTED) 0]
[zk: 10.0.0.91:2181(CONNECTED) 0] ls /
[zookeeper]
[zk: 10.0.0.91:2181(CONNECTED) 1]
集群搭建
1.停止单点服务
[19:34:10 root@elk1:~]#zkServer.sh stop
ZooKeeper JMX enabled by default
Using config: /hehe/softwares/apache-zookeeper-3.8.4-bin/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED2.修改zookeeper的配置文件
[19:34:10 root@elk1:~]# vim /hehe/softwares/apache-zookeeper-3.8.4-bin/conf/zoo.cfg
# 定义最小单元的时间范围tick。
tickTime=2000
# 启动时最长等待tick数量。
initLimit=5
# 数据同步时最长等待的tick时间进行响应ACK
syncLimit=2
# 指定数据目录
dataDir=/hehe/data/zk
# 监听端口
clientPort=2181
# 开启四字命令允许所有的节点访问。
4lw.commands.whitelist=*
# server.ID=A:B:C[:D]
# ID:
# zk的唯一编号。
# A:
# zk的主机地址。
# B:
# leader的选举端口,是谁leader角色,就会监听该端口。
# C:
# 数据通信端口。
# D:
# 可选配置,指定角色。(leader,follower,observer)
server.91=10.0.0.91:2888:3888
server.92=10.0.0.92:2888:3888
server.93=10.0.0.93:2888:3888## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpHost=0.0.0.0
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true3.同步zookeeper的程序到其他节点(前提是其他节点有"/hehe/softwares"目录)
[20:09:37 root@elk1:~]# scp -r /hehe/softwares/apache-zookeeper-3.8.4-bin/ 10.0.0.92:/hehe/softwares/[20:09:37 root@elk1:~]# scp -r /hehe/softwares/apache-zookeeper-3.8.4-bin/ 10.0.0.93:/hehe/softwares/[20:09:37 root@elk1:~]# ll /hehe/softwares/
total 12
drwxr-xr-x 3 root root 4096 Oct 31 19:06 ./
drwxr-xr-x 3 root root 4096 Oct 31 19:06 ../
drwxr-xr-x 7 root root 4096 Oct 31 19:10 apache-zookeeper-3.8.4-bin/[19:44:37 root@elk2:~]#ll /hehe/softwares/
total 16
drwxr-xr-x 4 root root 4096 Oct 31 20:09 ./
drwxr-xr-x 3 root root 4096 Oct 28 21:49 ../
drwxr-xr-x 9 root root 4096 Oct 28 21:49 apache-tomcat-10.1.31/
drwxr-xr-x 7 root root 4096 Oct 31 20:09 apache-zookeeper-3.8.4-bin/[20:08:48 root@elk3:~]#ll /hehe/softwares/
total 12
drwxr-xr-x 3 root root 4096 Oct 31 20:10 ./
drwxr-xr-x 3 root root 4096 Oct 31 19:44 ../
drwxr-xr-x 7 root root 4096 Oct 31 20:10 apache-zookeeper-3.8.4-bin/4.准备myid文件
[20:10:19 root@elk1:~]# mkdir -p /hehe/data/zk
[20:10:19 root@elk1:~]# echo 91 > /hehe/data/zk/myid
[20:10:19 root@elk1:~]# more /hehe/data/zk/myid
91[20:11:54 root@elk2:~]#mkdir -p /hehe/data/zk
[20:16:07 root@elk2:~]#echo 92 > /hehe/data/zk/myid
[20:16:07 root@elk2:~]#more /hehe/data/zk/myid
92[20:11:51 root@elk3:~]#mkdir -p /hehe/data/zk
[20:16:54 root@elk3:~]#echo 93 > /hehe/data/zk/myid
[20:16:54 root@elk3:~]#more /hehe/data/zk/myid
935.同步环境变量
[20:15:16 root@elk1:~]#scp /etc/profile.d/zk.sh 10.0.0.92:/etc/profile.d
[20:17:54 root@elk1:~]#scp /etc/profile.d/zk.sh 10.0.0.93:/etc/profile.d6.所有节点启动zookeeper集群
source /etc/profile.d/zk.sh ; zkServer.sh start7.查看集群的状态
[20:32:56 root@elk1:~]#zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /hehe/softwares/apache-zookeeper-3.8.4-bin/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: follower[20:32:59 root@elk2:~]#zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /hehe/softwares/apache-zookeeper-3.8.4-bin/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: leader[20:33:41 root@elk3:~]#zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /hehe/softwares/apache-zookeeper-3.8.4-bin/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: follower8.连接zookeeper集群
[20:33:44 root@elk3:~]# zkCli.sh -server 10.0.0.91:2181,10.0.0.92:2181,10.0.0.93:2181
...
[zk: 10.0.0.91:2181,10.0.0.92:2181,10.0.0.93:2181(CONNECTED) 0] ls /
[zookeeper]
[zk: 10.0.0.91:2181,10.0.0.92:2181,10.0.0.93:2181(CONNECTED) 1]
Zookeeper的基本使用
1.zookeeper的结构
zookeeper的存储结构和Linux文件系统类似,Linux中有目录和文件的区分,而Linux并不叫文件,而是教zookeeper node,简称"znode"。每个znode有点类似于Linux文件系统中的目录。2.基于znode实现基础管理
#2.1 查看znode列表
[zk: 10.0.0.91:2181,10.0.0.92:2181,10.0.0.93:2181(CONNECTED) 0] ls /
[zookeeper]#2.2 创建znode
格式:create 目录 数据
create /aaa a3#查看目录下的子节点
[zk: 10.0.0.91:2181,10.0.0.92:2181,10.0.0.93:2181(CONNECTED) 7] ls /bbb
[]#2.3查看znode的数据
格式:get 目录
get /aaa#2.4修改数据
格式:set 目录 新数据
set /aaa b3#2.5删除数据
格式:delete 目录(非递归删除,就是没有叶子节点)
delete /aaa(递归删除节点(包含子节点))
deleteall /bbb `---------------------注意事项:--------------------------`
1.谨慎使用deleteall命令,因为它会永久性地删除节点及其所有后代节点。在执行此命令之前,要确保你确实想要删除整个节点树。2.权限问题:如果启用了访问控制列表(ACL),你需要有足够的权限来执行删除操作。否则,删除命令会因为权限不足而失败。
`-------------------------------------------------------`#2.7多级znode管理
create /ccc
create /ccc/xxx/1
create /ccc/xxx/2ls /ccc显示:xxxls /ccc/xxx显示:[1,2]create /ccc/xxx/1/11 10
create /ccc/xxx/2/22 10#结果是不能删除的因为有数据,我们只能删除空路径
delete /ccc/1/112.7 zookeeper的node类型
#有临时的znode,和永久的znode,临时的znode会随着会话的结束,在默认30s内自动删除。#临时创建(不使用默认是永久)
create -e /beijing
create /hebei[zk: 10.0.0.91:2181,10.0.0.92:2181,10.0.0.93:2181(CONNECTED) 4] create -e /beijing
Created /beijing
[zk: 10.0.0.91:2181,10.0.0.92:2181,10.0.0.93:2181(CONNECTED) 5] stat /beijing
cZxid = 0x200000005
ctime = Thu Oct 31 21:23:45 CST 2024
mZxid = 0x200000005
mtime = Thu Oct 31 21:23:45 CST 2024
pZxid = 0x200000005
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x5b00006df96a0000#显示了创建该临时节点的会话 ID。
dataLength = 0
numChildren = 0[zk: 10.0.0.91:2181,10.0.0.92:2181,10.0.0.93:2181(CONNECTED) 1] create /hebei
Created /hebei
[zk: 10.0.0.91:2181,10.0.0.92:2181,10.0.0.93:2181(CONNECTED) 2] ls /
[aaa, bbb, hebei, zookeeper]
[zk: 10.0.0.91:2181,10.0.0.92:2181,10.0.0.93:2181(CONNECTED) 3] stat /hebei
cZxid = 0x200000004#节点创建时的事务 ID
ctime = Thu Oct 31 21:22:53 CST 2024#节点创建时间
mZxid = 0x200000004#节点最后一次修改时的事务 ID,因为这里没有修改过,所以和创建事务 ID 相同。
mtime = Thu Oct 31 21:22:53 CST 2024#节点最后一次修改时间
pZxid = 0x200000004#节点的子节点列表最后一次修改时的事务 ID,由于该节点没有子节点,所以和创建事务 ID 相同
cversion = 0#子节点的版本号
dataVersion = 0#数据的版本号,没有修改过所以为 0
aclVersion = 0#访问控制列表的版本号
ephemeralOwner = 0x0#表示如果是临时节点,这里会显示创建该临时节点的会话 ID,这里为 0 说明不是临时节点。
dataLength = 0#节点数据的长度为 0。
numChildren = 0#该节点的子节点数量为 0