Kubernetes学习之路(四)之Node节点二进制部署

K8S Node节点部署

  • 1、部署kubelet

(1)二进制包准备
[root@linux-node1 ~]# cd /usr/local/src/kubernetes/server/bin/
[root@linux-node1 bin]# cp kubelet kube-proxy /opt/kubernetes/bin/
[root@linux-node1 bin]# scp kubelet kube-proxy 192.168.56.120:/opt/kubernetes/bin/
[root@linux-node1 bin]# scp kubelet kube-proxy 192.168.56.130:/opt/kubernetes/bin/
(2)创建角色绑定

kubelet启动时会向kube-apiserver发送tsl bootstrap请求,所以需要将bootstrap的token设置成对应的角色,这样kubectl才有权限创建该请求。

[root@linux-node1 ~]# kubectl create clusterrolebinding kubelet-bootstrap --clusterrole=system:node-bootstrapper --user=kubelet-bootstrap
clusterrolebinding "kubelet-bootstrap" created
(3)创建 kubelet bootstrapping kubeconfig 文件 设置集群参数
[root@linux-node1 ~]# cd /usr/local/src/ssl
[root@linux-node1 ssl]# kubectl config set-cluster kubernetes \--certificate-authority=/opt/kubernetes/ssl/ca.pem \--embed-certs=true \--server=https://192.168.56.110:6443 \--kubeconfig=bootstrap.kubeconfig Cluster "kubernetes" set.
(4)设置客户端认证参数
[root@linux-node1 ssl]# kubectl config set-credentials kubelet-bootstrap \--token=ad6d5bb607a186796d8861557df0d17f \--kubeconfig=bootstrap.kubeconfig   
User "kubelet-bootstrap" set.
(5)设置上下文参数
[root@linux-node1 ssl]# kubectl config set-context default \--cluster=kubernetes \--user=kubelet-bootstrap \--kubeconfig=bootstrap.kubeconfig
Context "default" created.
(6)选择默认上下文
[root@linux-node1 ssl]# kubectl config use-context default --kubeconfig=bootstrap.kubeconfig
Switched to context "default".
[root@linux-node1 ssl]# cp bootstrap.kubeconfig /opt/kubernetes/cfg
[root@linux-node1 ssl]# scp bootstrap.kubeconfig 192.168.56.120:/opt/kubernetes/cfg
[root@linux-node1 ssl]# scp bootstrap.kubeconfig 192.168.56.130:/opt/kubernetes/cfg
  • 2、部署kubelet 1.设置CNI支持

(1)配置CNI
[root@linux-node2 ~]# mkdir -p /etc/cni/net.d
[root@linux-node2 ~]# vim /etc/cni/net.d/10-default.conf
{"name": "flannel","type": "flannel","delegate": {"bridge": "docker0","isDefaultGateway": true,"mtu": 1400}
}
[root@linux-node3 ~]# mkdir -p /etc/cni/net.d
[root@linux-node2 ~]# scp /etc/cni/net.d/10-default.conf 192.168.56.130:/etc/cni/net.d/10-default.conf
(2)创建kubelet数据存储目录
[root@linux-node2 ~]# mkdir /var/lib/kubelet
[root@linux-node3 ~]# mkdir /var/lib/kubelet
(3)创建kubelet服务配置
[root@linux-node2 ~]# vim /usr/lib/systemd/system/kubelet.service
[Unit]
Description=Kubernetes Kubelet
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=docker.service
Requires=docker.service[Service]
WorkingDirectory=/var/lib/kubelet
ExecStart=/opt/kubernetes/bin/kubelet \--address=192.168.56.120 \--hostname-override=192.168.56.120 \--pod-infra-container-image=mirrorgooglecontainers/pause-amd64:3.0 \--experimental-bootstrap-kubeconfig=/opt/kubernetes/cfg/bootstrap.kubeconfig \--kubeconfig=/opt/kubernetes/cfg/kubelet.kubeconfig \--cert-dir=/opt/kubernetes/ssl \--network-plugin=cni \--cni-conf-dir=/etc/cni/net.d \--cni-bin-dir=/opt/kubernetes/bin/cni \--cluster-dns=10.1.0.2 \--cluster-domain=cluster.local. \--hairpin-mode hairpin-veth \--allow-privileged=true \--fail-swap-on=false \--logtostderr=true \--v=2 \--logtostderr=false \--log-dir=/opt/kubernetes/log
Restart=on-failure
RestartSec=5[root@linux-node3 ~]# vim /usr/lib/systemd/system/kubelet.service
[Unit]
Description=Kubernetes Kubelet
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=docker.service
Requires=docker.service[Service]
WorkingDirectory=/var/lib/kubelet
ExecStart=/opt/kubernetes/bin/kubelet \--address=192.168.56.130 \--hostname-override=192.168.56.130 \--pod-infra-container-image=mirrorgooglecontainers/pause-amd64:3.0 \--experimental-bootstrap-kubeconfig=/opt/kubernetes/cfg/bootstrap.kubeconfig \--kubeconfig=/opt/kubernetes/cfg/kubelet.kubeconfig \--cert-dir=/opt/kubernetes/ssl \--network-plugin=cni \--cni-conf-dir=/etc/cni/net.d \--cni-bin-dir=/opt/kubernetes/bin/cni \--cluster-dns=10.1.0.2 \--cluster-domain=cluster.local. \--hairpin-mode hairpin-veth \--allow-privileged=true \--fail-swap-on=false \--logtostderr=true \--v=2 \--logtostderr=false \--log-dir=/opt/kubernetes/log
Restart=on-failure
RestartSec=5
View Code
(4)启动Kubelet
[root@linux-node2 ~]# systemctl daemon-reload
[root@linux-node2 ~]# systemctl enable kubelet
[root@linux-node2 ~]# systemctl start kubelet
[root@linux-node2 kubernetes]# systemctl status kubelet[root@linux-node3 ~]# systemctl daemon-reload
[root@linux-node3 ~]# systemctl enable kubelet
[root@linux-node3 ~]# systemctl start kubelet
[root@linux-node3 kubernetes]# systemctl status kubelet

在查看kubelet的状态,发现有如下报错Failed to get system container stats for "/system.slice/kubelet.service": failed to...此时需要调整kubelet的启动参数。

解决方法: 
/usr/lib/systemd/system/kubelet.service[service]新增: Environment="KUBELET_MY_ARGS=--runtime-cgroups=/systemd/system.slice --kubelet-cgroups=/systemd/system.slice" 
修改ExecStart: 在末尾新增$KUBELET_MY_ARGS

[root@linux-node2 system]# systemctl status kubelet
● kubelet.service - Kubernetes KubeletLoaded: loaded (/usr/lib/systemd/system/kubelet.service; static; vendor preset: disabled)Active: active (running) since 四 2018-05-31 16:33:17 CST; 16h agoDocs: https://github.com/GoogleCloudPlatform/kubernetesMain PID: 53223 (kubelet)CGroup: /system.slice/kubelet.service└─53223 /opt/kubernetes/bin/kubelet --address=192.168.56.120 --hostname-override=192.168.56.120 --pod-infra-container-image=mirrorgooglecontainers/pause-amd64:3.0 --experiment...6月 01 08:51:09 linux-node2.example.com kubelet[53223]: E0601 08:51:09.355765   53223 summary.go:102] Failed to get system container stats for "/system.slice/kubelet.service": failed to...
6月 01 08:51:19 linux-node2.example.com kubelet[53223]: E0601 08:51:19.363906   53223 summary.go:102] Failed to get system container stats for "/system.slice/kubelet.service": failed to...
6月 01 08:51:29 linux-node2.example.com kubelet[53223]: E0601 08:51:29.385439   53223 summary.go:102] Failed to get system container stats for "/system.slice/kubelet.service": failed to...
6月 01 08:51:39 linux-node2.example.com kubelet[53223]: E0601 08:51:39.393790   53223 summary.go:102] Failed to get system container stats for "/system.slice/kubelet.service": failed to...
6月 01 08:51:49 linux-node2.example.com kubelet[53223]: E0601 08:51:49.401081   53223 summary.go:102] Failed to get system container stats for "/system.slice/kubelet.service": failed to...
6月 01 08:51:59 linux-node2.example.com kubelet[53223]: E0601 08:51:59.407863   53223 summary.go:102] Failed to get system container stats for "/system.slice/kubelet.service": failed to...
6月 01 08:52:09 linux-node2.example.com kubelet[53223]: E0601 08:52:09.415552   53223 summary.go:102] Failed to get system container stats for "/system.slice/kubelet.service": failed to...
6月 01 08:52:19 linux-node2.example.com kubelet[53223]: E0601 08:52:19.425998   53223 summary.go:102] Failed to get system container stats for "/system.slice/kubelet.service": failed to...
6月 01 08:52:29 linux-node2.example.com kubelet[53223]: E0601 08:52:29.443804   53223 summary.go:102] Failed to get system container stats for "/system.slice/kubelet.service": failed to...
6月 01 08:52:39 linux-node2.example.com kubelet[53223]: E0601 08:52:39.450814   53223 summary.go:102] Failed to get system container stats for "/system.slice/kubelet.service": failed to...
Hint: Some lines were ellipsized, use -l to show in full.
(5)查看csr请求 注意是在linux-node1上执行。
[root@linux-node1 ssl]# kubectl get csr
NAME                                                   AGE       REQUESTOR           CONDITION
node-csr-6Wc7kmqBIaPOw83l2F1uCKN-uUaxfkVhIU8K93S5y1U   1m        kubelet-bootstrap   Pending
node-csr-fIXcxO7jyR1Au7nrpUXht19eXHnX1HdFl99-oq2sRsA   1m        kubelet-bootstrap   Pending
(6)批准kubelet 的 TLS 证书请求
[root@linux-node1 ssl]#  kubectl get csr|grep 'Pending' | awk 'NR>0{print $1}'| xargs kubectl certificate approve
certificatesigningrequest.certificates.k8s.io "node-csr-6Wc7kmqBIaPOw83l2F1uCKN-uUaxfkVhIU8K93S5y1U" approved
certificatesigningrequest.certificates.k8s.io "node-csr-fIXcxO7jyR1Au7nrpUXht19eXHnX1HdFl99-oq2sRsA" approved[root@linux-node1 ssl]# kubectl get csr
NAME                                                   AGE       REQUESTOR           CONDITION
node-csr-6Wc7kmqBIaPOw83l2F1uCKN-uUaxfkVhIU8K93S5y1U   2m        kubelet-bootstrap   Approved,Issued
node-csr-fIXcxO7jyR1Au7nrpUXht19eXHnX1HdFl99-oq2sRsA   2m        kubelet-bootstrap   Approved,Issued执行完毕后,查看节点状态已经是Ready的状态了 
[root@linux-node1 ssl]# kubectl get node
NAME             STATUS    ROLES     AGE       VERSION
192.168.56.120   Ready     <none>    50m       v1.10.1
192.168.56.130   Ready     <none>    46m       v1.10.1
  • 3、部署Kubernetes Proxy

(1)配置kube-proxy使用LVS
[root@linux-node2 ~]# yum install -y ipvsadm ipset conntrack
[root@linux-node3 ~]# yum install -y ipvsadm ipset conntrack
(2)创建 kube-proxy 证书请求
[root@linux-node1 ~]# cd /usr/local/src/ssl/
[root@linux-node1 ssl]# vim kube-proxy-csr.json
{"CN": "system:kube-proxy","hosts": [],"key": {"algo": "rsa","size": 2048},"names": [{"C": "CN","ST": "BeiJing","L": "BeiJing","O": "k8s","OU": "System"}]
}
(3)生成证书
[root@linux-node1~]# cfssl gencert -ca=/opt/kubernetes/ssl/ca.pem \-ca-key=/opt/kubernetes/ssl/ca-key.pem \-config=/opt/kubernetes/ssl/ca-config.json \-profile=kubernetes  kube-proxy-csr.json | cfssljson -bare kube-proxy
(4)分发证书到所有Node节点
[root@linux-node1 ssl]# cp kube-proxy*.pem /opt/kubernetes/ssl/
[root@linux-node1 ssl]# scp kube-proxy*.pem 192.168.56.120:/opt/kubernetes/ssl/
[root@linux-node1 ssl]# scp kube-proxy*.pem 192.168.56.120:/opt/kubernetes/ssl/
(5)创建kube-proxy配置文件
[root@linux-node1 ssl]# kubectl config set-cluster kubernetes \--certificate-authority=/opt/kubernetes/ssl/ca.pem \--embed-certs=true \--server=https://192.168.56.110:6443 \--kubeconfig=kube-proxy.kubeconfig
Cluster "kubernetes" set.[root@linux-node1 ssl]# kubectl config set-credentials kube-proxy \--client-certificate=/opt/kubernetes/ssl/kube-proxy.pem \--client-key=/opt/kubernetes/ssl/kube-proxy-key.pem \--embed-certs=true \--kubeconfig=kube-proxy.kubeconfig
User "kube-proxy" set.[root@linux-node1 ssl]# kubectl config set-context default \--cluster=kubernetes \--user=kube-proxy \--kubeconfig=kube-proxy.kubeconfig
Context "default" created.[root@linux-node1 ssl]# kubectl config use-context default --kubeconfig=kube-proxy.kubeconfig
Switched to context "default".
(6)分发kubeconfig配置文件
[root@linux-node1 ssl]# cp kube-proxy.kubeconfig /opt/kubernetes/cfg/
[root@linux-node1 ssl]# scp kube-proxy.kubeconfig 192.168.56.120:/opt/kubernetes/cfg/
[root@linux-node1 ssl]# scp kube-proxy.kubeconfig 192.168.56.130:/opt/kubernetes/cfg/
(7)创建kube-proxy服务配置
[root@linux-node1 ssl]# mkdir /var/lib/kube-proxy
[root@linux-node2 ssl]# mkdir /var/lib/kube-proxy
[root@linux-node3 ssl]# mkdir /var/lib/kube-proxy[root@linux-node1 ~]# vim /usr/lib/systemd/system/kube-proxy.service
[Unit]
Description=Kubernetes Kube-Proxy Server
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=network.target[Service]
WorkingDirectory=/var/lib/kube-proxy
ExecStart=/opt/kubernetes/bin/kube-proxy \--bind-address=192.168.56.120 \--hostname-override=192.168.56.120 \--kubeconfig=/opt/kubernetes/cfg/kube-proxy.kubeconfig \
--masquerade-all \--feature-gates=SupportIPVSProxyMode=true \--proxy-mode=ipvs \--ipvs-min-sync-period=5s \--ipvs-sync-period=5s \--ipvs-scheduler=rr \--logtostderr=true \--v=2 \--logtostderr=false \--log-dir=/opt/kubernetes/logRestart=on-failure
RestartSec=5
LimitNOFILE=65536[Install]
WantedBy=multi-user.target[root@linux-node1 ssl]# scp /usr/lib/systemd/system/kube-proxy.service 192.168.56.120:/usr/lib/systemd/system/kube-proxy.service
kube-proxy.service                                         100%  701   109.4KB/s   00:00    
[root@linux-node1 ssl]# scp /usr/lib/systemd/system/kube-proxy.service 192.168.56.130:/usr/lib/systemd/system/kube-proxy.service
kube-proxy.service                                         100%  701    34.9KB/s   00:00    
(8)启动Kubernetes Proxy
[root@linux-node2 ~]# systemctl daemon-reload
[root@linux-node2 ~]# systemctl enable kube-proxy
[root@linux-node2 ~]# systemctl start kube-proxy
[root@linux-node2 ~]# systemctl status kube-proxy[root@linux-node3 ~]# systemctl daemon-reload
[root@linux-node3 ~]# systemctl enable kube-proxy
[root@linux-node3 ~]# systemctl start kube-proxy
[root@linux-node3 ~]# systemctl status kube-proxy

检查LVS状态,可以看到已经创建了一个LVS集群,将来自10.1.0.1:443的请求转到192.168.56.110:6443,而6443就是api-server的端口
[root@linux-node2 ~]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags-> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  10.1.0.1:443 rr persistent 10800-> 192.168.56.110:6443          Masq    1      0          0         [root@linux-node3 ~]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags-> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  10.1.0.1:443 rr persistent 10800-> 192.168.56.110:6443          Masq    1      0          0         如果你在两台实验机器都安装了kubelet和proxy服务,使用下面的命令可以检查状态:[root@linux-node1 ssl]#  kubectl get node
NAME            STATUS    ROLES     AGE       VERSION
192.168.56.120   Ready     <none>    22m       v1.10.1
192.168.56.130   Ready     <none>    3m        v1.10.1

到此,K8S的集群就部署完毕,由于K8S本身不支持网络,需要借助第三方网络才能进行创建Pod,将在下一节学习Flannel网络为K8S提供网络支持。

(9)遇到的问题:kubelet无法启动,kubectl get node 提示:no resource found

[root@linux-node1 ssl]#  kubectl get node
No resources found.[root@linux-node3 ~]# systemctl status kubelet
● kubelet.service - Kubernetes KubeletLoaded: loaded (/usr/lib/systemd/system/kubelet.service; static; vendor preset: disabled)Active: activating (auto-restart) (Result: exit-code) since Wed 2018-05-30 04:48:29 EDT; 1s agoDocs: https://github.com/GoogleCloudPlatform/kubernetesProcess: 16995 ExecStart=/opt/kubernetes/bin/kubelet --address=192.168.56.130 --hostname-override=192.168.56.130 --pod-infra-container-image=mirrorgooglecontainers/pause-amd64:3.0 --experimental-bootstrap-kubeconfig=/opt/kubernetes/cfg/bootstrap.kubeconfig --kubeconfig=/opt/kubernetes/cfg/kubelet.kubeconfig --cert-dir=/opt/kubernetes/ssl --network-plugin=cni --cni-conf-dir=/etc/cni/net.d --cni-bin-dir=/opt/kubernetes/bin/cni --cluster-dns=10.1.0.2 --cluster-domain=cluster.local. --hairpin-mode hairpin-veth --allow-privileged=true --fail-swap-on=false --logtostderr=true --v=2 --logtostderr=false --log-dir=/opt/kubernetes/log (code=exited, status=255)Main PID: 16995 (code=exited, status=255)May 30 04:48:29 linux-node3.example.com systemd[1]: Unit kubelet.service entered failed state.
May 30 04:48:29 linux-node3.example.com systemd[1]: kubelet.service failed.
[root@linux-node3 ~]# tailf /var/log/messages
......
May 30 04:46:24 linux-node3 kubelet: F0530 04:46:24.134612   16207 server.go:233] failed to run Kubelet: failed to create kubelet: misconfiguration: kubelet cgroup driver: "cgroupfs" is different from docker cgroup driver: "systemd"

提示kubelet使用的cgroup驱动类型和docker的cgroup驱动类型不一致。进行查看docker.service[Unit] Description
=Docker Application Container Engine Documentation=http://docs.docker.com After=network.target Wants=docker-storage-setup.service Requires=docker-cleanup.timer[Service] Type=notify NotifyAccess=all KillMode=process EnvironmentFile=-/etc/sysconfig/docker EnvironmentFile=-/etc/sysconfig/docker-storage EnvironmentFile=-/etc/sysconfig/docker-network Environment=GOTRACEBACK=crash Environment=DOCKER_HTTP_HOST_COMPAT=1 Environment=PATH=/usr/libexec/docker:/usr/bin:/usr/sbin ExecStart=/usr/bin/dockerd-current \--add-runtime docker-runc=/usr/libexec/docker/docker-runc-current \--default-runtime=docker-runc \--exec-opt native.cgroupdriver=systemd \ ###修改此处"systemd""cgroupfs"--userland-proxy-path=/usr/libexec/docker/docker-proxy-current \$OPTIONS \$DOCKER_STORAGE_OPTIONS \$DOCKER_NETWORK_OPTIONS \$ADD_REGISTRY \$BLOCK_REGISTRY \$INSECURE_REGISTRY ExecReload=/bin/kill -s HUP $MAINPID LimitNOFILE=1048576 LimitNPROC=1048576 LimitCORE=infinity TimeoutStartSec=0 Restart=on-abnormal MountFlags=slave[Install] WantedBy=multi-user.target [root@linux-node3 ~]# systemctl daemon-reload [root@linux-node3 ~]# systemctl restart docker.service [root@linux-node3 ~]# systemctl restart kubelet

 

转载于:https://www.cnblogs.com/linuxk/p/9272778.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/251356.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

前端知识点梳理(二)

1.内核 浏览器内核&#xff08;Rendering Engine&#xff09;最初分为&#xff1a;渲染引擎&#xff08;layout engineer&#xff09;或&#xff08;Rendering Engine&#xff09;和js引擎&#xff1b;后来 JS 引擎越来越独立&#xff0c;内核就倾向于单指渲染引擎。浏览器she…

微信小程序模仿开眼视频app(三)——信息卡片瀑布流和分类

《微信小程序模仿开眼视频app&#xff08;一&#xff09;——视频首页、视频详情、分类》 《微信小程序模仿开眼视频app&#xff08;二&#xff09;——搜索功能》 可到我的github账号上去copy文件 瀑布流部分 文件代码提示的挺详细的&#xff0c;这里主要点一下 社区与分类…

PHP后台代码解决跨域问题

在前端里面&#xff0c;解决跨域的时候总显得那么的恶心&#xff0c;什么jsonp啊&#xff0c;ajax啊&#xff0c;CORS啊什么的&#xff0c;总觉得是在钻空子进行跨域&#xff0c;其实在PHP文件里面只需要加一段代码就可以跨域了&#xff0c;前端你该怎么写还是怎么写&#xff0…

javascript --- typeof方法和instanceof方法

ES5中: 原始类型包括:Number、String、Boolean、Null、Undefined 原始封装类型包括:Number、String、Boolean 引用类型包括:Array、Function、RegExp、Error、Date、Error 变量对象 原始类型的实例成为原始值,它直接保存在变量对象中. 引用类型的实例成为引用值,它作为一个指针…

python 基本数据类型常用方法总结

【引言】 python中基本数据类型的有很多常用方法&#xff0c;熟悉这些方法有助于不仅提升了编码效率&#xff0c;而且能写出高质量代码&#xff0c;本文做总结 int .bit_length:返回二进制长度 str 切片索引超出不会报错 切片上下限写反不报错&#xff0c;没有结果 切片倒取&am…

网易试题——关于箭头函数与this和arguments的关系

昨天做试题的时候遇到了这个题目 var a 1;function fn1() {console.log(this.a)}const fn2 () > {console.log(this.a)}const obj {a: 10,fn1: fn1,fn2: fn2}fn1()fn2()obj.fn1()obj.fn2() 哦这该死的网易&#xff0c;怎么出这么简单的题目&#xff0c;答案是&#xff1…

《JavaScript 高级程序设计》笔记 第1~5章

第1章 js是专为网页交互而设计的脚本语言&#xff0c;由3部分组成&#xff1a; ECMAScript&#xff0c;提供核心语言功能DOM文档对象模型&#xff0c;提供访问和操作网页内容的方法和接口BOM浏览器对象模型&#xff0c;提供与浏览器交互的方法和接口 js是一种脚本语言、解释…

【笔记】跨域重定向中使用Ajax(XHR请求)导致跨域失败

背景&#xff1a; 1、前端Web中有两个域名&#xff0c;a.com和b.com&#xff0c;其中a.com是访问主站&#xff08;页面&#xff09;&#xff0c;b.com是数据提交接口的服务器&#xff08;XHR请求&#xff09; 2、a.com中用XHR调用b.com/cerate【没有指定协议】&#xff0c;保存…

javascript --- js中prototype、__proto__、[[Propto]]、constructor的关系

首先看下面一行代码: function Person(name){this.name name; } var person1 new Person; console.log(person1.__proto__ Person.prototype); console.log(person1.constructor Person);控制台打印如下: 可以看见,当使用构造函数(Person)构造一个实例(person1)时, 在后…

前端知识点整理收集(不定时更新~)

知识点都是搜集各种大佬们的&#xff0c;如有冒犯&#xff0c;请告知&#xff01; 目录 原型链 New关键字的执行过程 ES6——class constructor方法 类的实例对象 不存在变量提升 super 关键字 ES6——...&#xff08;展开/收集&#xff09;运算符 面向对象的理解 关…

数据库四大特性与隔离级别

数据库四大特性ACID Atomicity (原子性) :事务&#xff08;transaction&#xff09;是由指逻辑上对数据的的一组操作&#xff0c;这组操作要么一次全部成功&#xff0c;如果这组操作全部失败&#xff0c;是不可分割的一个工作单位。 Consistency(一致性) :在事务开始以前&#…

重学《JavaScript 高级程序设计》笔记 第6章对象

第6章 面向对象的程序设计 ECMAScript中没有类的概念&#xff1b; 1.创建对象-历史 1.1 创建实例&#xff0c;添加方法和属性 → 对象字面量 缺点&#xff1a; 使用同一接口创建很多对象&#xff0c;产生大量重复代码 var person new Object() person.name "Y" pe…

Java-reflect(反射)初步理解_1

27.01_反射(类的加载概述和加载时机) A:类的加载概述 当程序要使用某个类时&#xff0c;如果该类还未被加载到内存中&#xff0c;则系统会通过加载&#xff0c;连接&#xff0c;初始化三步来实现对这个类进行初始化。加载 就是指将class文件读入内存&#xff0c;并为之创建一个…

javascrip --- 构造函数的继承

两点需要注意的. 第一是在构造函数声明时,会同时创建一个该构造函数的原型对象,而该原型对象是继承自Object的原型对象 // 声明一个构造函数Rectengle function Rectangle(length, width) {this.length length;this.width width; }// 即:看见function 后面函数名是大写,一般…

Ruby实例方法和类方法的简写

创建: 2017/12/12 类方法 Sample.func实例方法 Sample#func转载于:https://www.cnblogs.com/lancgg/p/8281677.html

《JavaScript 高级程序设计》笔记 第7章及以后

第7章 函数表达式 匿名函数的name属性是空字符串&#xff1b;闭包是函数&#xff1a;闭包是有权访问另一个函数作用域中变量的函数&#xff1b;(P181 副作用,解释了点击li弹出循环最后值的原因)当某个函数第一次被调用时&#xff0c;会创建一个执行环境及相应作用域链&#xf…

[树形dp] Jzoj P1046 寻宝之旅

Description 探险队长凯因意外的弄到了一份黑暗森林的藏宝图&#xff0c;于是&#xff0c;探险队一行人便踏上了寻宝之旅&#xff0c;去寻找传说中的宝藏。藏宝点分布在黑暗森林的各处&#xff0c;每个点有一个值&#xff0c;表示藏宝的价值。它们之间由一些小路相连&#xff0…

javascript --- 使用语法糖class定义函数

本文讨论的是通过class声明的函数,有什么特点,或者说是指向了哪里. class A() {} // A是一个类// 要看class声明的函数指向哪里,只需将其[[Prototype]]属性打印到控制台,下面看看A和它的原型对象的指向 // 注:[[Prototype]]属性通过__proto__访问 console.log(A.__proto__…

前端知识点整理收集(不定时更新~)二

目录 require() 加载文件机制 线程和进程 线程 单线程 Nodejs的线程与进程 网络模型 初识 TCP 协议 三次握手 I/O I/O 先修知识 阻塞与非阻塞 I/O 同步与异步 I/O Git 基础命令 分支操作 修改远程仓库地址 远程分支获取最新的版本到本地 拉取远程仓库指定分支…

SpringBoot零基础入门指南--搭建Springboot然后能够在浏览器返回数据

File->new Project 修改默认包名&#xff0c;根据自己的喜好修改 选择初始化需要导入的包&#xff0c;尽量不要一开始就导入很多&#xff0c;特别是数据库&#xff0c;不然启动可能会有问题&#xff0c;创建好的目录如下&#xff1a; 配置文件写在application.properties下&…