forked from alexsworld/bigdata-learning-notes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
216 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
|
||
|
||
|
||
|
||
---- | ||
# 一、环境准备 | ||
CentOS: | ||
```bash | ||
# 关闭防火墙 | ||
systemctl stop firewalld | ||
systemctl disable firewalld | ||
|
||
# 关闭selinux | ||
sed -i 's/enforcing/disabled/' /etc/selinux/config # 永久 | ||
setenforce 0 # 临时 | ||
|
||
# 关闭swap | ||
swapoff -a # 临时 | ||
sed -ri 's/.*swap.*/#&/' /etc/fstab # 永久 | ||
|
||
# 根据规划设置主机名 | ||
hostnamectl set-hostname <hostname> | ||
|
||
# 在master添加hosts | ||
cat >> /etc/hosts << EOF | ||
192.168.220.121 k8s-master | ||
192.168.220.122 k8s-node1 | ||
192.168.220.123 k8s-node2 | ||
192.168.220.124 k8s-node3 | ||
EOF | ||
|
||
# 将桥接的IPv4流量传递到iptables的链 | ||
cat > /etc/sysctl.d/k8s.conf << EOF | ||
net.bridge.bridge-nf-call-ip6tables = 1 | ||
net.bridge.bridge-nf-call-iptables = 1 | ||
EOF | ||
sysctl --system # 生效 | ||
|
||
# 时间同步 | ||
yum install ntpdate -y | ||
ntpdate time.windows.com | ||
``` | ||
Ubuntu: | ||
```bash | ||
# 关闭防火墙 | ||
ufw disable | ||
|
||
# 关闭swap | ||
swapoff -a # 临时 | ||
sed -ri 's/.*swap.*/#&/' /etc/fstab # 永久 | ||
|
||
# 根据规划设置主机名 | ||
# 临时 | ||
hostname <hostname> | ||
# 永久 | ||
vim /etc/hostname | ||
<hostname> | ||
|
||
# 在master添加hosts | ||
cat >> /etc/hosts << EOF | ||
192.168.220.121 k8s-master | ||
192.168.220.122 k8s-node1 | ||
192.168.220.123 k8s-node2 | ||
192.168.220.124 k8s-node3 | ||
EOF | ||
|
||
# 将桥接的IPv4流量传递到iptables的链 | ||
cat > /etc/sysctl.d/k8s.conf << EOF | ||
net.bridge.bridge-nf-call-ip6tables = 1 | ||
net.bridge.bridge-nf-call-iptables = 1 | ||
EOF | ||
sysctl --system # 生效 | ||
|
||
# 时间同步 | ||
yum install ntpdate -y | ||
ntpdate time.windows.com | ||
``` | ||
|
||
# 二、 安装docker | ||
[CentOS7安装Docker](../docker/CentOS7安装Docker.md) | ||
|
||
# 三、安装 node 节点 | ||
Ubuntu: | ||
|
||
查看 k8s 版本: | ||
```bash | ||
$ apt-cache madison kubeadm | ||
kubeadm | 1.19.4-00 | https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial/main amd64 Packages | ||
kubeadm | 1.19.3-00 | https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial/main amd64 Packages | ||
... | ||
``` | ||
安装 | ||
```bash | ||
apt-get update && apt-get install -y apt-transport-https | ||
curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add - | ||
echo "deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list | ||
apt-get update | ||
# 安装指定版本 | ||
apt-get install -y kubelet=<version> kubeadm=<version> kubectl=<version> | ||
# 安装最新版本 | ||
apt-get install -y kubelet kubeadm kubectl | ||
``` | ||
|
||
|
||
CentOS: | ||
|
||
查看 k8s 版本: | ||
```bash | ||
$ yum list kubelet --showduplicates | sort -r | ||
已加载插件:fastestmirror | ||
可安装的软件包 | ||
* updates: mirrors.aliyun.com | ||
Loading mirror speeds from cached hostfile | ||
kubelet.x86_64 1.9.9-0 kubernetes | ||
kubelet.x86_64 1.9.8-0 kubernetes | ||
... | ||
``` | ||
安装 | ||
```bash | ||
cat <<EOF > /etc/yum.repos.d/kubernetes.repo | ||
[kubernetes] | ||
name=Kubernetes | ||
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/ | ||
enabled=1 | ||
gpgcheck=1 | ||
repo_gpgcheck=1 | ||
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg | ||
EOF | ||
yum clean all && yum makecache | ||
yum list kubelet --showduplicates | sort -r | ||
yum install -y kubelet-1.18.6-0 kubeadm-1.18.6-0 kubectl-1.18.6-0 | ||
``` | ||
|
||
|
||
# 四、获取 token | ||
在master 节点执行以下命令: | ||
```bash | ||
root@jz-desktop-01:~# kubeadm token list | ||
TOKEN TTL EXPIRES USAGES DESCRIPTION EXTRA GROUPS | ||
xe4dur.4s63knpjxin3pte2 22h 2020-11-17T11:25:03+08:00 authentication,signing <none> system:bootstrappers:kubeadm:default-node-token | ||
``` | ||
token 过24小时会自动失效, 如果上步骤中没有token显示, 可创建一个token | ||
```bash | ||
$ kubectl token create | ||
``` | ||
拿到 sha256 值: | ||
```bash | ||
openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //' # 来查看hash。 | ||
``` | ||
|
||
```bash | ||
kubeadm join <master IP>:6443 --token <kubeadm token list 显示的值> --discovery-token-ca-cert-hash sha256:<上一步拿到的sha256值> | ||
``` | ||
|
||
# 五、查看是否安装成功 | ||
在master节点 | ||
```bash | ||
$ kubectl get nodes | ||
root@jz-desktop-01:~# kubectl get nodes | ||
NAME STATUS ROLES AGE VERSION | ||
jz-desktop-01 NotReady master 114d v1.18.6 | ||
jz-desktop-02 Ready <none> 114d v1.18.6 | ||
jz-desktop-03 Ready <none> 79m v1.18.6 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
|
||
|
||
---- | ||
|
||
Redis是开源的高性能内存Key-Value(键值对)数据库, 可以提供事务和持久化支持 | ||
|
||
key是String类型 | ||
|
||
value有五种数据类型, 分别是: String、Hash、Set、Zset 以及 list | ||
|
||
# 一、String(字符串) | ||
string是redis最基本的类型, 可以理解成与 Memcached 一模一样的类型,一个 key 对应一个 value, 例如: `hello: world`。 | ||
|
||
string类型是**二进制安全的**, 意思是redis的string可以包含任何数据。比如jpg图片或者序列化的对象 。 | ||
|
||
string类型是Redis最基本的数据类型,一个redis中字符串value最多可以是512M | ||
|
||
# 二、Hash(哈希) | ||
Redis hash 是一个键值对集合。 | ||
|
||
Redis hash是一个string类型的field和value的映射表,hash特别适合用于存储对象。 | ||
|
||
类似Java里面的Map<String,Object> | ||
|
||
# 三、List(列表) | ||
Redis 列表是简单的字符串列表,按照插入顺序排序。你可以添加一个元素导列表的头部(左边)或者尾部(右边)。 | ||
|
||
它的底层实际是个链表 | ||
|
||
|
||
|
||
# 四、Set(集合) | ||
Redis的Set是string类型的无序集合。它是通过HashTable实现实现的, | ||
|
||
|
||
# 五、Zset(有序集合) | ||
Redis zset 和 set 一样也是string类型元素的集合, 且不允许重复的成员。 | ||
|
||
不同的是每个元素都会关联一个double类型的分数。 | ||
|
||
redis正是通过分数来为集合中的成员进行从小到大的排序。zset的成员是唯一的,但分数(score)却可以重复。 | ||
|
||
|