当前位置: 首页 > news >正文

Kubernetes实战(五)-pod之间网络请求实战

1 同namespace内pod网络请求

1.1 创建namespace ygq

$ kubectl create namespace ygq
namespace/ygq created

1.2 创建svc和deployment 

在naemspace ygq下创建两个应用:nginx和nginx-test。

1.2.1 部署应用nginx

$ cat nginx-svc.yaml
apiVersion: v1
kind: Service
metadata:name: nginxnamespace: ygq
spec:selector:app: nginxports:- port: 80type: ClusterIP
$ cat deployment-nginx.yaml
apiVersion: apps/v1
kind: Deployment
metadata:creationTimestamp: nulllabels:app: nginxname: nginxnamespace: ygq
spec:replicas: 1selector:matchLabels:app: nginxtemplate:metadata:creationTimestamp: nulllabels:app: nginxspec:containers:- image: docker.io/library/nginx:latestname: nginximagePullPolicy: IfNotPresentimagePullSecrets:- name: harbor-login
$ kubectl apply -f nginx-svc.yaml
$ kubectl apply -f deployment-nginx.yaml
$ kubectl get svc -n ygq 
NAME         TYPE        CLUSTER-IP        EXTERNAL-IP   PORT(S)   AGE
nginx        ClusterIP   192.168.245.168   <none>        80/TCP    3d
$ kubectl get pod -n ygq
NAME                          READY   STATUS    RESTARTS        AGE
nginx-547cc75cb7-j46zl        1/1     Running   0               2d22h

1.2.2 部署应用nginx-test

$ cat nginx-test-svc.yaml
apiVersion: v1
kind: Service
metadata:name: nginx-testnamespace: ygq
spec:selector:app: nginx-testports:- port: 80type: ClusterIP
$ cat deployment-nginx-test.yaml
apiVersion: apps/v1
kind: Deployment
metadata:creationTimestamp: nulllabels:app: nginx-testname: nginx-testnamespace: ygq
spec:replicas: 1selector:matchLabels:app: nginx-testtemplate:metadata:creationTimestamp: nulllabels:app: nginx-testspec:containers:- image: docker.io/library/nginx:latestname: nginximagePullPolicy: IfNotPresentimagePullSecrets:- name: harbor-login
$ kubectl apply -f nginx-test-svc.yaml
$ kubectl apply -f deployment-nginx-test.yaml
$ kubectl get svc -n ygq 
NAME         TYPE        CLUSTER-IP        EXTERNAL-IP   PORT(S)   AGE
nginx-test   ClusterIP   192.168.97.154    <none>        80/TCP    3d
$ kubectl get pod -n ygq
NAME                          READY   STATUS    RESTARTS        AGE
nginx-test-6c5f4dfc79-2ldhg   1/1     Running   1 (2d23h ago)   3d

1.3 测试nginx与nginx-test互相访问

1.3.1 nginx访问nginx-test

1.3.1.1 登录nginx pod
$ kubectl exec -it nginx-547cc75cb7-j46zl /bin/bash -n ygq 
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
1.3.1.2 svc name方式访问nginx-test
root@nginx-547cc75cb7-j46zl:/# curl nginx 
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>
1.3.1.3 pod ip方式访问nginx-test
# kubectl get pod -n ygq -o wide 
NAME                          READY   STATUS    RESTARTS        AGE     IP              NODE                      NOMINATED NODE   READINESS GATES
nginx-test-6c5f4dfc79-2ldhg   1/1     Running   1 (2d23h ago)   3d      172.20.176.17   cn-shanghai.10.12.46.85   <none>           <none>

pod ip是172.20.176.17。

root@nginx-547cc75cb7-j46zl:/# curl http://172.20.176.17:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>
1.3.1.4 dns方式访问

k8s 中dns的组成结构为:service_name.namespace_name.svc.cluster.local:port,可简写为service_name.namespace_name.svc:port。

deployment nginx-test的端口为80,其dns为:nginx-test.ygq.svc.cluster.local:80,简写为:nginx-test.ygq.svc:80。

1)完整dns

root@nginx-547cc75cb7-j46zl:/# curl http://nginx-test.ygq.svc.cluster.local:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>

2)简写dns

root@nginx-547cc75cb7-j46zl:/# curl http://nginx-test.ygq.svc:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>

1.3.2  nginx-test访问nginx

1.3.2.1 登录nginx-test pod
$ kubectl exec -it nginx-test-6c5f4dfc79-2ldhg /bin/bash -n ygq 
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
1.3.2.2 svc name方式访问nginx
root@nginx-test-6c5f4dfc79-2ldhg:/# curl nginx 
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>
1.3.2.3 pod ip方式访问nginx
$ kubectl get pod -n ygq -o wide 
NAME                          READY   STATUS    RESTARTS        AGE     IP              NODE                      NOMINATED NODE   READINESS GATES
nginx-547cc75cb7-j46zl        1/1     Running   0               2d23h   172.20.176.24   cn-shanghai.10.12.46.85   <none>           <none>
root@nginx-test-6c5f4dfc79-2ldhg:/# curl http://172.20.176.24:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>
1.3.2.4 dns方式访问

deployment nginx的端口为80,其dns为:nginx.ygq.svc.cluster.local:80,简写为:nginx.ygq.svc:80。

1)完整dns

root@nginx-test-6c5f4dfc79-2ldhg:/# curl nginx.ygq.svc.cluster.local:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>

2)简写dns

root@nginx-test-6c5f4dfc79-2ldhg:/# curl nginx.ygq.svc:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>

1.4 结论

同namespace下不同pod直接可通过svc name、pod ip及dns互相访问。

pod ip是不固定的,会伴随pod的状态变化发生改变,生产环境不建议使用pod ip作为请求地址。 

2 不同namespace间pod网络请求

2.1 创建namespace dev

$ kubectl create namespace dev
namespace/dev created

2.2 创建svc和deployment 

在naemspace dev下创建应用:nginx-dev。

2.2.1 部署应用nginx-dev

$ cat deployment-nginx-dev.yaml
apiVersion: apps/v1
kind: Deployment
metadata:creationTimestamp: nulllabels:app: nginx-devname: nginx-devnamespace: dev
spec:replicas: 4selector:matchLabels:app: nginx-devtemplate:metadata:creationTimestamp: nulllabels:app: nginx-devspec:containers:- image: docker.io/library/nginx:latestname: nginximagePullPolicy: IfNotPresentimagePullSecrets:- name: harbor-login
$ cat nginx-dev-svc.yaml
apiVersion: v1
kind: Service
metadata:name: nginx-devnamespace: dev
spec:selector:app: nginx-devports:- port: 80type: ClusterIP
$ kubectl apply -f nginx-dev-svc.yaml
$ kubectl apply -f deployment-nginx-dev.yaml
# kubectl get svc -n dev
NAME        TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)   AGE
nginx-dev   ClusterIP   192.168.28.113   <none>        80/TCP    3d
$ kubectl get pod -n dev
NAME                         READY   STATUS    RESTARTS     AGE
nginx-dev-5966c9747d-gbdq4   1/1     Running   1 (3d ago)   3d

2.3 测试nginx与nginx-dev互相访问

2.3.1 nginx访问nginx-dev

2.3.1.1 登录nginx pod
$ kubectl exec -it nginx-547cc75cb7-j46zl /bin/bash -n ygq 
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
2.3.1.2 svc name方式访问
root@nginx-547cc75cb7-j46zl:/# curl nginx-dev
curl: (6) Could not resolve host: nginx-dev
2.3.1.3 pod ip方式访问 
$ kubectl get pod -n dev -o wide
NAME                         READY   STATUS    RESTARTS     AGE   IP             NODE                      NOMINATED NODE   READINESS GATES
nginx-dev-5966c9747d-gbdq4   1/1     Running   1 (3d ago)   3d    172.20.176.9   cn-shanghai.10.12.46.85   <none>           <none>
root@nginx-547cc75cb7-j46zl:/# curl 172.20.176.9:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>
2.3.1.4 dns方式访问

deployment nginx-dev的端口为80,其dns为:nginx-dev.dev.svc.cluster.local:80,简写为:nginx-dev.dev.svc:80。

1)完整dns

root@nginx-547cc75cb7-j46zl:/# curl nginx-dev.dev.svc.cluster.local:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>

2)简写dns

root@nginx-547cc75cb7-j46zl:/# curl nginx-dev.dev.svc:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>

2.3.2 nginx-dev访问nginx

2.3.2.1 登录nginx-dev pod
$ kubectl exec -it nginx-dev-5966c9747d-gbdq4 /bin/bash -n dev
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
2.3.2.2 svc name方式访问
root@nginx-dev-5966c9747d-gbdq4:/# curl nginx    
curl: (6) Could not resolve host: nginx
2.3.2.3 pod ip方式访问
$ kubectl get pod -n ygq -o wide 
NAME                          READY   STATUS    RESTARTS     AGE     IP              NODE                      NOMINATED NODE   READINESS GATES
nginx-547cc75cb7-j46zl        1/1     Running   0            2d23h   172.20.176.24   cn-shanghai.10.12.46.85   <none>           <none>
root@nginx-dev-5966c9747d-gbdq4:/# curl 172.20.176.24:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>
2.3.2.4 dns方式访问

deployment nginx的端口为80,其dns为:nginx.ygq.svc.cluster.local:80,简写为:nginx.ygq.svc:80。

1)完整dns

root@nginx-dev-5966c9747d-gbdq4:/# curl nginx.ygq.svc.cluster.local:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>

2)简写dns

root@nginx-dev-5966c9747d-gbdq4:/# curl nginx.ygq.svc:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>

2.4 结论 

不同namespace下pod直接可通过pod ip及dns互相访问,但不能通过svc name进行访问

pod ip是不固定的,会伴随pod的状态变化发生改变,生产环境不建议使用pod ip作为请求地址。 

3 pod name实战

3.1 同一namespace下

3.1.1 deployment

$ kubectl get pod -n ygq  -o wide 
NAME                          READY   STATUS    RESTARTS     AGE    IP              NODE                      NOMINATED NODE   READINESS GATES
nginx-547cc75cb7-j46zl        1/1     Running   0            3d     172.20.176.24   cn-shanghai.10.12.46.85   <none>           <none>
nginx-test-6c5f4dfc79-2ldhg   1/1     Running   1 (3d ago)   3d2h   172.20.176.17   cn-shanghai.10.12.46.85   <none>           <none>
$ kubectl create -f deployment-nginx.yaml 
Error from server (AlreadyExists): error when creating "deployment-nginx.yaml": deployments.apps "nginx" already exists

3.1.2 Service

$ kubectl get svc -n ygq  -o wide 
NAME         TYPE        CLUSTER-IP        EXTERNAL-IP   PORT(S)   AGE    SELECTOR
nginx        ClusterIP   192.168.245.168   <none>        80/TCP    3d1h   app=nginx
nginx-test   ClusterIP   192.168.97.154    <none>        80/TCP    3d1h   app=nginx-test
$ kubectl create -f nginx-svc.yaml
Error from server (AlreadyExists): error when creating "nginx-svc.yaml": services "nginx" already exists

3.2 不同namespace 

3.2.1 deployment

$ kubectl get pod -n dev -o wide 
NAME                         READY   STATUS    RESTARTS       AGE    IP              NODE                      NOMINATED NODE   READINESS GATES
nginx-cfcb57f6d-vr79r        1/1     Running   0              10s    172.20.176.28   cn-shanghai.10.12.46.85   <none>           <none>
nginx-dev-5966c9747d-gbdq4   1/1     Running   1 (3d1h ago)   3d1h   172.20.176.9    cn-shanghai.10.12.46.85   <none>           <none>
$ kubectl get pod -n ygq  -o wide 
NAME                          READY   STATUS    RESTARTS     AGE    IP              NODE                      NOMINATED NODE   READINESS GATES
nginx-547cc75cb7-j46zl        1/1     Running   0            3d     172.20.176.24   cn-shanghai.10.12.46.85   <none>           <none>
nginx-test-6c5f4dfc79-2ldhg   1/1     Running   1 (3d ago)   3d2h   172.20.176.17   cn-shanghai.10.12.46.85   <none>           <none>

3.2.2 Service 

$ kubectl get svc -n dev -o wide 
NAME        TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)   AGE    SELECTOR
nginx       ClusterIP   192.168.87.200   <none>        80/TCP    7s     app=nginx
nginx-dev   ClusterIP   192.168.28.113   <none>        80/TCP    3d1h   app=nginx-dev
$ kubectl get svc -n ygq  -o wide 
NAME         TYPE        CLUSTER-IP        EXTERNAL-IP   PORT(S)   AGE    SELECTOR
nginx        ClusterIP   192.168.245.168   <none>        80/TCP    3d1h   app=nginx
nginx-test   ClusterIP   192.168.97.154    <none>        80/TCP    3d1h   app=nginx-test

3.3 结论

不同namescpace下可以存在相同名称的资源,同一namespace下不允许有相同名称的资源。

4 总结

  • 同一namespace下的应用可以通过svc name、pod ip和dns互相访问,不同namespace下可以通过pod ip和dns互相访问。
  • 同一namespace下不允许有相同名称的资源,不同namescpace下可以存在名字一样的资源。

 

 

 

 

相关文章:

Kubernetes实战(五)-pod之间网络请求实战

1 同namespace内pod网络请求 1.1 创建namespace ygq $ kubectl create namespace ygq namespace/ygq created 1.2 创建svc和deployment 在naemspace ygq下创建两个应用&#xff1a;nginx和nginx-test。 1.2.1 部署应用nginx $ cat nginx-svc.yaml apiVersion: v1 kind: …...

7年经验之谈 —— 如何高效的开展app的性能测试?

APP性能测试是什么 从网上查了一下&#xff0c;貌似也没什么特别的定义&#xff0c;我这边根据自己的经验给出一个自己的定义&#xff0c;如有巧合纯属雷同。 客户端性能测试就是&#xff0c;从业务和用户的角度出发&#xff0c;设计合理且有效的性能测试场景&#xff0c;制定…...

小程序action-sheet结合自定义tabbar显示

要实现此效果&#xff0c;遇到的问题&#xff1a;背景在电脑端调试的情况正常的情况下&#xff0c;手机端点击事件工单&#xff0c;返回回来的时候action-sheet卡住在屏幕上&#xff0c;点击遮罩层都不消失。更奇怪的是 这种情况并不是每次发生&#xff0c;而是有时候发生&…...

机器学习笔记 - 隐马尔可夫模型的简述

隐马尔可夫模型是一个并不复杂的数学模型,到目前为止,它一直被认为是解决大多数自然语言处理问题最为快速、有效的方法。它成功地解决了复杂的语音识别、机器翻译等问题。看完这些复杂的问题是如何通过简单的模型得到描述和解决,我们会由衷地感叹数学模型之妙。 人类信息交流…...

iOS学习 --- Xcode 15 下载iOS_17.0.1_Simulator失败解决方法

1.去开发者官网下载安装包 https://developer.apple.com/download/all/?qiOS%2017 使用浏览器下载。 2.打开终端通过命令添加到xcode 命令如下&#xff1a; sudo xcode-select -s /Applications/Xcode.app(输入开始密码)xcodebuild -runFirstLaunch (等待一小会)xcrun simctl…...

多视图聚类论文阅读(二)

Deep multi-view semi-supervised clustering with sample pairwise constraints 基于样本对约束的深度多视图半监督聚类 1.1 提出的问题 提出问题&#xff1a; 多视图聚类技术多数方法都忽视了弱监督信息的重要性&#xff0c; 提出的解决方法 将自监督学习引入到了多视图…...

Docker在Centos7下的安装

1、卸载旧版本 执行如下指令对旧版本进行卸载&#xff1a; sudo yum remove docker \docker-client \docker-client-latest \docker-common \docker-latest \docker-latest-logrotate \docker-logrotate \docker-engine 执行完毕后&#xff0c;如果输入docker version发现do…...

LLM大模型4位量化实战【GPTQ】

权重量化方面的最新进展使我们能够在消费类硬件上运行大量大型语言模型&#xff0c;例如 RTX 3090 GPU 上的 LLaMA-30B 模型。 这要归功于性能下降最小的新型 4 位量化技术&#xff0c;例如 GPTQ、GGML 和 NF4。 在上一篇文章中&#xff0c;我们介绍了简单的 8 位量化技术和出…...

安装keras、tensorflow

看起来你仍然面临SSL证书验证失败的问题。这可能是由于你的网络环境或代理设置引起的。你可以尝试以下几个步骤&#xff1a; 检查网络连接&#xff1a; 确保你的计算机能够正常访问互联网。 关闭代理&#xff1a; 如果你使用了代理&#xff0c;尝试暂时关闭它&#xff0c;然后…...

ffmpeg知识点整理

使用FFmepg进行视频转码、视频格式转换、图片提取等&#xff01;_ffmepg -c:v-CSDN博客 中文文档&#xff1a; ffmpeg 中文手册 (beandrewang.github.io) 笔记&#xff1a; 通用规则是&#xff0c;所有选项作用于其后边的第一个文件。因此&#xff0c;顺序是非常重要的&…...

Git 笔记之gitignore

解释为&#xff1a;git ignore 即&#xff0c;此类型的文件将会被忽略掉&#xff0c;从而不会进行管理 具体的模板可以从 GitHub 网站上来进行设置 GitHub - github/gitignore: A collection of useful .gitignore templates Common_gitignore: gitignoregithub开源项目&…...

【配置】Redis常用配置详解

文章目录 IP地址绑定设置密码 IP地址绑定 默认情况下&#xff0c;如果未指定 “bind” 配置指令&#xff0c;Redis 将监听服务器上所有可用的网络接口的连接。 可以使用 “bind” 配置指令来仅监听一个或多个选定的接口&#xff0c;后跟一个或多个 IP 地址 示例&#xff1a;bin…...

Linux(Ubuntu)安装JDK环境

系统环境 Ubuntu20.04 下载JDK压缩包 前往Oracle官网进行后续下载或单击下载JDK压缩包 下拉找到JDK8&#xff0c;在Linux板块下选择适配系统架构的压缩包文件(后缀为tar.gz)&#xff0c;系统架构可通过uname -m命令查看 安装JDK 安装环境通常放在/usr/local下&#xff0c;进入…...

OpenCV C++ 张正友相机标定【相机标定原理、相机标定流程、图像畸变矫正】

文章目录 3.1 标定原理3.2 相机标定流程步骤1:采集棋盘格图像,批处理(调整尺寸、重命名)步骤2:提取棋盘格内角点坐标步骤3:进一步提取亚像素角点信息在棋盘标定图上绘制找到的内角点(非必须,仅为了显示)步骤4:相机标定--计算出相机内参数矩阵和畸变系数步骤5:畸变图像…...

SDL2 播放音频(MP4)

1.简介 这里引入FFmpeg库&#xff0c;获取音频流数据&#xff0c;然后通过FFmpeg将视频流解码成pcm原始数据&#xff0c;再将pcm数据送入到SDL库中实现音频播放。 2.FFmpeg的操作流程 注册API&#xff1a;av_register_all()构建输入AVFormatContext上下文&#xff1a;avform…...

WMS仓库管理系统库位功能

后端 &#xfeff;using Infrastructure.Attribute; using Model.Dto.WarehouseManagement; using Model.Page; using Model.WarehouseManagement; using Repository; using Service.Interface.WarehouseManagement; using SqlSugar;namespace Service.WarehouseManagement {[…...

vue2组件通信中的一些拓展(props,emit,ref父子双向传参)

说明 我上一篇文章中基本对vue所有的数据通信方法进行了一个整理归纳。 其实我并没有像传统的那样去罗列,比如父传子有props,ref,子传父为emit,兄弟用$bus等等。 因为在我的实际练习和业务开发中,props,emit,ref等可以实现父子数据互传,这里就涉及一个比较重要的编程思维,函…...

Flink1.17 DataStream API

目录 一.执行环境&#xff08;Execution Environment&#xff09; 1.1 创建执行环境 1.2 执行模式 1.3 触发程序执行 二.源算子&#xff08;Source&#xff09; 2.1 从集合中读取数据 2.2 从文件读取数据 2.3 从 RabbitMQ 中读取数据 2.4 从数据生成器读取数据 2.5 …...

数据结构中树、森林 与 二叉树的转换

1 树转换为 二叉树 将树转换成二叉树的步骤是&#xff1a; 加线。在所有的兄弟结点之间加一条线。去线。对于树中的每个结点&#xff0c;只保留它与第一个孩子结点的连线&#xff0c;删除该结点其他孩子结点之间的连线。调整。以树的根结点为轴心&#xff0c;将整个树顺时针旋…...

力扣labuladong——一刷day43

提示&#xff1a;文章写完后&#xff0c;目录可以自动生成&#xff0c;如何生成可参考右边的帮助文档 文章目录 前言一、力扣257. 二叉树的所有路径二、力扣129. 求根节点到叶节点数字之和三、力扣199. 二叉树的右视图四、力扣662. 二叉树最大宽度 前言 一般来说&#xff0c;如…...

国防科技大学计算机基础课程笔记02信息编码

1.机内码和国标码 国标码就是我们非常熟悉的这个GB2312,但是因为都是16进制&#xff0c;因此这个了16进制的数据既可以翻译成为这个机器码&#xff0c;也可以翻译成为这个国标码&#xff0c;所以这个时候很容易会出现这个歧义的情况&#xff1b; 因此&#xff0c;我们的这个国…...

Docker 运行 Kafka 带 SASL 认证教程

Docker 运行 Kafka 带 SASL 认证教程 Docker 运行 Kafka 带 SASL 认证教程一、说明二、环境准备三、编写 Docker Compose 和 jaas文件docker-compose.yml代码说明&#xff1a;server_jaas.conf 四、启动服务五、验证服务六、连接kafka服务七、总结 Docker 运行 Kafka 带 SASL 认…...

令牌桶 滑动窗口->限流 分布式信号量->限并发的原理 lua脚本分析介绍

文章目录 前言限流限制并发的实际理解限流令牌桶代码实现结果分析令牌桶lua的模拟实现原理总结&#xff1a; 滑动窗口代码实现结果分析lua脚本原理解析 限并发分布式信号量代码实现结果分析lua脚本实现原理 双注解去实现限流 并发结果分析&#xff1a; 实际业务去理解体会统一注…...

Map相关知识

数据结构 二叉树 二叉树&#xff0c;顾名思义&#xff0c;每个节点最多有两个“叉”&#xff0c;也就是两个子节点&#xff0c;分别是左子 节点和右子节点。不过&#xff0c;二叉树并不要求每个节点都有两个子节点&#xff0c;有的节点只 有左子节点&#xff0c;有的节点只有…...

.Net Framework 4/C# 关键字(非常用,持续更新...)

一、is 关键字 is 关键字用于检查对象是否于给定类型兼容,如果兼容将返回 true,如果不兼容则返回 false,在进行类型转换前,可以先使用 is 关键字判断对象是否与指定类型兼容,如果兼容才进行转换,这样的转换是安全的。 例如有:首先创建一个字符串对象,然后将字符串对象隐…...

以光量子为例,详解量子获取方式

光量子技术获取量子比特可在室温下进行。该方式有望通过与名为硅光子学&#xff08;silicon photonics&#xff09;的光波导&#xff08;optical waveguide&#xff09;芯片制造技术和光纤等光通信技术相结合来实现量子计算机。量子力学中&#xff0c;光既是波又是粒子。光子本…...

Docker 本地安装 mysql 数据库

Docker: Accelerated Container Application Development 下载对应操作系统版本的 docker &#xff1b;并安装。 基础操作不再赘述。 打开 macOS 终端&#xff0c;开始 docker 安装mysql之旅 第一步 docker search mysql 》〉docker search mysql NAME DE…...

MySQL的pymysql操作

本章是MySQL的最后一章&#xff0c;MySQL到此完结&#xff0c;下一站Hadoop&#xff01;&#xff01;&#xff01; 这章很简单&#xff0c;完整代码在最后&#xff0c;详细讲解之前python课程里面也有&#xff0c;感兴趣的可以往前找一下 一、查询操作 我们需要打开pycharm …...

0x-3-Oracle 23 ai-sqlcl 25.1 集成安装-配置和优化

是不是受够了安装了oracle database之后sqlplus的简陋&#xff0c;无法删除无法上下翻页的苦恼。 可以安装readline和rlwrap插件的话&#xff0c;配置.bahs_profile后也能解决上下翻页这些&#xff0c;但是很多生产环境无法安装rpm包。 oracle提供了sqlcl免费许可&#xff0c…...

密码学基础——SM4算法

博客主页&#xff1a;christine-rr-CSDN博客 ​​​​专栏主页&#xff1a;密码学 &#x1f4cc; 【今日更新】&#x1f4cc; 对称密码算法——SM4 目录 一、国密SM系列算法概述 二、SM4算法 2.1算法背景 2.2算法特点 2.3 基本部件 2.3.1 S盒 2.3.2 非线性变换 ​编辑…...