[Linux]-Debian10基礎使用


第1章 Debian10安裝

image-20201215143214249

image-20201215145003503

image-20201215143254131

image-20201215143307681

image-20201215143349373

image-20201215143456536

image-20201215143512777

image-20201215143535767

image-20201215143738405

image-20201215143752476

image-20201215143816836

image-20201215143836319

image-20201215143909154

image-20201215143927691

image-20201215143956135

image-20201215144007600

image-20201215144023754

image-20201215144038247

image-20201215144051899

image-20201215144202475

image-20201215144218668

image-20201215144258562

image-20201215144331665

image-20201215144458459

image-20201215144511604

image-20201215144532997

第2章 Debian10基本配置

1.網卡配置

debian所有的網卡都在一個配置文件里,這點和Centos7不一樣

root@debian:~# grep "^[a-Z]" /etc/network/interfaces  
source /etc/network/interfaces.d/*
auto lo
iface lo inet loopback
allow-hotplug eth0

auto eth0
iface eth0 inet static
address 10.0.0.20
netmask 255.255.255.0
gateway 10.0.0.2

重啟網卡命令

systemctl restart  networking.service

2.SSH配置

默認Debian不允許root遠程登錄,必須通過修改SSH配置文件才可以使用root遠程登錄。

root@debian:~# grep "PermitRootLogin" /etc/ssh/sshd_config     
#PermitRootLogin prohibit-password
PermitRootLogin yes

重啟sshd

systemctl restart sshd

3.配置APT源

Debian10直有清華源,阿里源只提供到Debian9

https://mirrors.tuna.tsinghua.edu.cn/help/debian/

配置命令

cp /etc/apt/sources.list /opt/
cat > /etc/apt/sources.list << 'EOF'
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free
EOF

更新緩存

注意: 在Centos7里update是更新系統,在Debian里是更新軟件源

apt update

4.命令別名

Debian默認沒有配置常用的命令別名,rm也不會有提示,需要的話可以手動打開注釋

root@debian:~# cat ~/.bashrc 
# ~/.bashrc: executed by bash(1) for non-login shells.

# Note: PS1 and umask are already set in /etc/profile. You should not
# need this unless you want different defaults for root.
# PS1='${debian_chroot:+($debian_chroot)}\h:\w\$ '
# umask 022

# You may uncomment the following lines if you want `ls' to be colorized:
# export LS_OPTIONS='--color=auto'
# eval "`dircolors`"
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'

# Some more alias to avoid making mistakes:
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

第3章 Debian10軟件操作

1.apt-get和apt命令

等同於Centos7的yum命令
apt-get是第一代的包管理工具,最穩定
apt是改進的包管理工具,比apt-get要先進
官方推薦使用apt來管理軟件

2.常用命令匯總

apt install package
apt remove package
apt --reinstall install package

3.查找軟件

apt-cache search nginx

4.本地軟件包管理

等同於Centos7的RPM命令

dpkg -S sshd
dpkg -s sshd
dpkg -l ssh
dpkg -s *.deb
dpkg -i *.deb
dpkg -r package
dpkg -P package

第4章 Debian10用戶管理

1.創建用戶

Centos7和Debian使用useradd命令的區別,以下面的命令舉例:

useradd zhangya

這條命令在Debian下不會做如下幾件事

1.不會創建家目錄
2.默認shell是/bin/sh
3.而/bin/sh默認是軟連接到/bin/dash解釋器
/bin/sh -> dash

如果需要創建這些內容則必須指定參數

useradd -m -s /bin/bash zhangya

2.免交互創建密碼

Debian的passwd命令沒有--stdin選項,要想免交互,使用chpasswd

echo "root:123456"|chpasswd

第5章 應用舉例

1.Debian10安裝Docker環境

清華源網址

https://mirrors.tuna.tsinghua.edu.cn/help/docker-ce/

安裝命令

apt-get remove docker docker-engine docker.io
apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common -y
curl -fsSL https://download.docker.com/linux/debian/gpg |apt-key add -
add-apt-repository \
   "deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian \
   $(lsb_release -cs) \
   stable"
apt-get update
apt-get install docker-ce

2.Debian10使用kubeadm安裝k8s

#使用iptables
update-alternatives --set iptables /usr/sbin/iptables-legacy
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
update-alternatives --set arptables /usr/sbin/arptables-legacy
update-alternatives --set ebtables /usr/sbin/ebtables-legacy

#設置倉庫源
cat > /etc/apt/sources.list.d/kubernetes.list <<EOF
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
EOF
curl -s https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -
apt-get update

#安裝kubeadm
apt-get install -y kubelet kubeadm kubectl ipvsadm

#配置參數
cat > /etc/default/kubelet <<'EOF'
KUBELET_CGROUP_ARGS="--cgroup-driver=systemd"
KUBELET_EXTRA_ARGS="--fail-swap-on=false"
EOF

#設置內核參數
cat >  /etc/sysctl.d/k8s.conf <<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF
sysctl --system

#啟動服務
systemctl enable kubelet && systemctl start kubelet

#加載ipvs模塊
modprobe -- ip_vs
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- ip_vs_sh
modprobe -- nf_conntrack

#查看模塊
lsmod | grep -e ip_vs -e nf_conntrack_ipv

#初始化安裝master節點
kubeadm init \
--apiserver-advertise-address=10.0.0.20 \
--image-repository registry.aliyuncs.com/google_containers \
--kubernetes-version v1.20.0 \
--service-cidr=10.1.0.0/16 \
--pod-network-cidr=10.2.0.0/16 \
--service-dns-domain=cluster.local \
--ignore-preflight-errors=Swap \
--ignore-preflight-errors=NumCPU


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM