28_支付服务注册进zookeeper 上面的都复习了
18
zookeeper替换Eureka
zookeeper已经在你的centeros7上配置成功了 前提要求
19
20
21
22
zookeeper在centeros7 java代码在win10
23
24
25
我是在虚拟机新建的 因为视频是虚拟机的
26
27
28
http://127.0.0.1:8004/payment/zk
29
30
31
***************************************************************
29_临时还是持久节点
Last login: Fri Aug 14 20:08:09 2020 from 192.168.184.1
[root@localhost ~]# ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:53:92:21:49 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.184.128 netmask 255.255.255.0 broadcast 192.168.184.255
inet6 fe80::7b3c:fc5c:641e:f755 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:56:97:c6 txqueuelen 1000 (Ethernet)
RX packets 130 bytes 14755 (14.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 122 bytes 18189 (17.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 68 bytes 5920 (5.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 68 bytes 5920 (5.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@localhost ~]# ping 192.168.31.146
PING 192.168.31.146 (192.168.31.146) 56(84) bytes of data.
64 bytes from 192.168.31.146: icmp_seq=1 ttl=128 time=0.745 ms
64 bytes from 192.168.31.146: icmp_seq=2 ttl=128 time=1.46 ms
64 bytes from 192.168.31.146: icmp_seq=15 ttl=128 time=0.866 ms
64 bytes from 192.168.31.146: icmp_seq=16 ttl=128 time=1.71 ms
64 bytes from 192.168.31.146: icmp_seq=17 ttl=128 time=0.619 ms
64 bytes from 192.168.31.146: icmp_seq=18 ttl=128 time=0.728 ms
^F64 bytes from 192.168.31.146: icmp_seq=19 ttl=128 time=0.885 ms
64 bytes from 192.168.31.146: icmp_seq=20 ttl=128 time=1.41 ms
^C
--- 192.168.31.146 ping statistics ---
20 packets transmitted, 20 received, 0% packet loss, time 19036ms
rtt min/avg/max/mdev = 0.619/1.303/3.484/0.681 ms
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4f943970b24e registry "/entrypoint.sh /etc…" 8 weeks ago Exited (255) 2 weeks ago 0.0.0.0:5000->5000/tcp registry
ae06529673d5 redis "docker-entrypoint.s…" 2 months ago Exited (0) 8 weeks ago myredis
dc990467f9eb nginx "/docker-entrypoint.…" 2 months ago Exited (0) 8 weeks ago mynginx
bf94ece95f4d tomcat:7-jre7 "catalina.sh run" 2 months ago Exited (137) 8 weeks ago 0.0.0.0:9000->8080/tcp mytomcat
4c4c12614911 centos/mysql-57-centos7 "container-entrypoin…" 2 months ago Exited (137) 8 weeks ago 0.0.0.0:33306->3306/tcp mysql_yjb
66dd22206051 centos:7 "/bin/bash" 2 months ago Exited (137) 8 weeks ago mycentos2
fb51fc1984c4 centos:7 "/bin/bash" 2 months ago Exited (137) 8 weeks ago mycentos
[root@localhost ~]# docker pull zookeeper
Using default tag: latest
latest: Pulling from library/zookeeper
bf5952930446: Downloading
092c9b8e633f: Download complete
0b793152b850: Download complete
b612fb485c1a: Download complete
667cec6570bc: Download complete
db0e227deeb8: Download complete
2ecd18ebbb33: Download complete
5ebd9b1202ae: Download complete
latest: Pulling from library/zookeeper
bf5952930446: Pull complete
092c9b8e633f: Pull complete
0b793152b850: Pull complete
b612fb485c1a: Pull complete
667cec6570bc: Pull complete
db0e227deeb8: Pull complete
2ecd18ebbb33: Pull complete
5ebd9b1202ae: Pull complete
Digest: sha256:c0c7b8774beaab2d4b06e004fda286526503ad991b6b5677e4edd431f22e135d
Status: Downloaded newer image for zookeeper:latest
docker.io/library/zookeeper:latest
启动zookeeper
[root@localhost ~]# docker run --privileged=true -d --name zookeeper --publish 2181:2181 -d zookeeper:latest
c01cba6017a1f07460c58a1fc7dbecdc33e60821e688fc3a09d56abe58175ed6
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c01cba6017a1 zookeeper:latest "/docker-entrypoint.…" 8 seconds ago Up 4 seconds 2888/tcp, 3888/tcp, 0.0.0.0:2181->2181/tcp, 8080/tcp zookeeper
[root@localhost ~]# docker exec -it c01cba6017a1 /bin/bash 进入zookeeper内部
root@c01cba6017a1:/apache-zookeeper-3.6.1-bin# cd bin
root@c01cba6017a1:/apache-zookeeper-3.6.1-bin/bin# zkCli.sh -server 127.0.0.1:2181
Connecting to 127.0.0.1:2181
2020-08-30 13:10:19,160 [myid:] - INFO [main:Environment@98] - Client environment:zookeeper.version=3.6.1--104dcb3e3fb464b30c5186d229e00af9f332524b, built on 04/21/2020 15:01 GMT
2020-08-30 13:10:19,167 [myid:] - INFO [main:Environment@98] - Client environment:host.name=c01cba6017a1
2020-08-30 13:10:19,167 [myid:] - INFO [main:Environment@98] - Client environment:java.version=11.0.8
2020-08-30 13:10:19,172 [myid:] - INFO [main:Environment@98] - Client environment:java.vendor=N/A
2020-08-30 13:10:19,172 [myid:] - INFO [main:Environment@98] - Client environment:java.home=/usr/local/openjdk-11
2020-08-30 13:10:19,172 [myid:] - INFO [main:Environment@98] - Client environment:java.class.path=/apache-zookeeper-3.6.1-bin/bin/../zookeeper-server/target/classes:/apache-zookeeper-3.6.1-bin/bin/../build/classes:/apache-zookeeper-3.6.1-bin/bin/../zookeeper-server/target/lib/*.jar:/apache-zookeeper-3.6.1-bin/bin/../build/lib/*.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/zookeeper-prometheus-metrics-3.6.1.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/zookeeper-jute-3.6.1.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/zookeeper-3.6.1.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/snappy-java-1.1.7.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/slf4j-log4j12-1.7.25.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/slf4j-api-1.7.25.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/simpleclient_servlet-0.6.0.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/simpleclient_hotspot-0.6.0.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/simpleclient_common-0.6.0.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/simpleclient-0.6.0.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/netty-transport-native-unix-common-4.1.48.Final.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/netty-transport-native-epoll-4.1.48.Final.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/netty-transport-4.1.48.Final.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/netty-resolver-4.1.48.Final.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/netty-handler-4.1.48.Final.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/netty-common-4.1.48.Final.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/netty-codec-4.1.48.Final.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/netty-buffer-4.1.48.Final.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/metrics-core-3.2.5.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/log4j-1.2.17.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/json-simple-1.1.1.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/jline-2.11.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/jetty-util-9.4.24.v20191120.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/jetty-servlet-9.4.24.v20191120.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/jetty-server-9.4.24.v20191120.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/jetty-security-9.4.24.v20191120.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/jetty-io-9.4.24.v20191120.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/jetty-http-9.4.24.v20191120.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/javax.servlet-api-3.1.0.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/jackson-databind-2.10.3.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/jackson-core-2.10.3.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/jackson-annotations-2.10.3.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/commons-lang-2.6.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/commons-cli-1.2.jar:/apache-zookeeper-3.6.1-bin/bin/../lib/audience-annotations-0.5.0.jar:/apache-zookeeper-3.6.1-bin/bin/../zookeeper-*.jar:/apache-zookeeper-3.6.1-bin/bin/../zookeeper-server/src/main/resources/lib/*.jar:/conf:
2020-08-30 13:10:19,173 [myid:] - INFO [main:Environment@98] - Client environment:java.library.path=/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib
2020-08-30 13:10:19,173 [myid:] - INFO [main:Environment@98] - Client environment:java.io.tmpdir=/tmp
2020-08-30 13:10:19,173 [myid:] - INFO [main:Environment@98] - Client environment:java.compiler=<NA>
2020-08-30 13:10:19,173 [myid:] - INFO [main:Environment@98] - Client environment:os.name=Linux
2020-08-30 13:10:19,174 [myid:] - INFO [main:Environment@98] - Client environment:os.arch=amd64
2020-08-30 13:10:19,174 [myid:] - INFO [main:Environment@98] - Client environment:os.version=3.10.0-1127.13.1.el7.x86_64
2020-08-30 13:10:19,174 [myid:] - INFO [main:Environment@98] - Client environment:user.name=root
2020-08-30 13:10:19,174 [myid:] - INFO [main:Environment@98] - Client environment:user.home=/root
2020-08-30 13:10:19,174 [myid:] - INFO [main:Environment@98] - Client environment:user.dir=/apache-zookeeper-3.6.1-bin/bin
2020-08-30 13:10:19,174 [myid:] - INFO [main:Environment@98] - Client environment:os.memory.free=11MB
2020-08-30 13:10:19,179 [myid:] - INFO [main:Environment@98] - Client environment:os.memory.max=247MB
2020-08-30 13:10:19,179 [myid:] - INFO [main:Environment@98] - Client environment:os.memory.total=15MB
2020-08-30 13:10:19,204 [myid:] - INFO [main:ZooKeeper@1005] - Initiating client connection, connectString=127.0.0.1:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@49e202ad
2020-08-30 13:10:19,220 [myid:] - INFO [main:X509Util@77] - Setting -D jdk.tls.rejectClientInitiatedRenegotiation=true to disable client-initiated TLS renegotiation
2020-08-30 13:10:19,254 [myid:] - INFO [main:ClientCnxnSocket@239] - jute.maxbuffer value is 1048575 Bytes
2020-08-30 13:10:19,347 [myid:] - INFO [main:ClientCnxn@1703] - zookeeper.request.timeout value is 0. feature enabled=false
Welcome to ZooKeeper!
2020-08-30 13:10:19,433 [myid:127.0.0.1:2181] - INFO [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1154] - Opening socket connection to server localhost/127.0.0.1:2181.
2020-08-30 13:10:19,436 [myid:127.0.0.1:2181] - INFO [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1156] - SASL config status: Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
2020-08-30 13:10:19,531 [myid:127.0.0.1:2181] - INFO [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@986] - Socket connection established, initiating session, client: /127.0.0.1:51060, server: localhost/127.0.0.1:2181
2020-08-30 13:10:19,636 [myid:127.0.0.1:2181] - INFO [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1420] - Session establishment complete on server localhost/127.0.0.1:2181, session id = 0x100000a08940001, negotiated timeout = 30000
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
[zk: 127.0.0.1:2181(CONNECTED) 0] ls /
[services, zookeeper]
[zk: 127.0.0.1:2181(CONNECTED) 1] ls /services
[cloud-provider-payment]
[zk: 127.0.0.1:2181(CONNECTED) 2] ls /services/cloud-provider-payment
[d999ae41-d8e3-4251-ba21-4ed3074e7c96]
[zk: 127.0.0.1:2181(CONNECTED) 3] ls /services/cloud-provider-payment/d999ae41-d8e3-4251-ba21-4ed3074e7c96
[]
[zk: 127.0.0.1:2181(CONNECTED) 4] get /services/cloud-provider-payment/d999ae41-d8e3-4251-ba21-4ed3074e7c96
{"name":"cloud-provider-payment","id":"d999ae41-d8e3-4251-ba21-4ed3074e7c96","address":"DESKTOP-R815P95","port":8004,"sslPort":null,"payload":{"@class":"org.springframework.cloud.zookeeper.discovery.ZookeeperInstance","id":"application-1","name":"cloud-provider-payment","metadata":{}},"registrationTimeUTC":1598792758453,"serviceType":"DYNAMIC","uriSpec":{"parts":[{"value":"scheme","variable":true},{"value":"://","variable":false},{"value":"address","variable":true},{"value":":","variable":false},{"value":"port","variable":true}]}}
[zk: 127.0.0.1:2181(CONNECTED) 5]
https://www.cnblogs.com/telwanggs/p/10855665.html
cker安装Zookeeper
下载Zookeeper镜像
docker pull zookeeper
1
启动容器并添加映射
docker run --privileged=true -d --name zookeeper --publish 2181:2181 -d zookeeper:latest
1
查看容器是否启动
docker ps
1
idea提供了一个Zookeeper插件,以供连接Zookeeper服务中心和查看内容
打开idea –》 Settings -》Plugins,搜索Zoo进行下载安装
配置Zookeeper的连接信息
https://www.cnblogs.com/jiex123/p/12801451.html
docker安装zookeeper后进入查看镜像内部文件的命令
查看容器是否启动
docker ps
进入容器
docker exec -it f76b7e25baa9 /bin/bash
进入bin目录
cd bin
登录server
zkCli.sh -server 127.0.0.1:2181
查看目录
ls /