a、查看防火墙状态:inactive是关闭,active是开启。
sudo ufw status
b、开启防火墙。
sudo ufw enable
c、关闭防火墙。
sudo ufw disable
ifconfig
sudo cp /etc/netplan/00-installer-config.yaml /etc/netplan/00-installer-config.yaml-bak
#修改Ip
cat <<EOF | sudo tee /etc/netplan/00-installer-config.yaml
network:
ethernets:
ens160:
addresses:
- 192.16.2.11/24
routes:
- to: default
via: 192.16.2.1 ## gateway
nameservers:
addresses:
- 114.114.114.114
- 8.8.8.8
version: 2
EOF
#更新Ip
sudo netplan apply
#备份
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
#阿里源
cat <<EOF | sudo tee /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
EOF
#更新软件列表
sudo apt-get update -y
# 更新本地软件
sudo apt-get upgrade -y
## 创建挂载目录,挂载镜像源
sudo mkdir /mnt/cdrom
sudo mount /mnt/ubuntu-22.04.3-server-amd64.iso /mnt/cdrom/
#备份
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
#使用本地源jammy 表示版本22
cat <<EOF | sudo tee /etc/apt/sources.list
deb file:///mnt/cdrom jammy main
EOF
#清除原有记录
sudo apt-get clean all
#更新软件列表
sudo apt-get update -y
# 更新本地软件
sudo apt-get upgrade -y
sudo apt-get install openssh-server openssh-client net-tools ntpdate -y && sudo /etc/init.d/ssh restart
sudo timedatectl set-timezone Asia/Shanghai && sudo ntpdate time.windows.com
#使用root账户,进行ssh登录
sed -i "s|#PermitRootLogin prohibit-password|PermitRootLogin yes|" /etc/ssh/sshd_config
#重启ssh
sudo systemctl restart ssh
sudo hostnamectl set-hostname k8s-mast
#查看任务
crontab -l
#编辑任务
crontab -e
#每小时同步一次时间
0 */1 * * * /usr/sbin/ntpdate 192.16.2.20
#保存修改
Ctrl+o
#退出
Ctrl+x
#安装
apt install zabbix-agent
#替换zabbix 配置文件ip192.16.2.25
sed -i "s|Server=127.0.0.1|Server=192.16.2.25|" /etc/zabbix/zabbix_agentd.conf
sed -i "s|ServerActive=127.0.0.1|ServerActive=192.16.2.25|" /etc/zabbix/zabbix_agentd.conf
sudo vi /etc/zabbix/zabbix_agentd.conf
#被动模式仅需修改Server、Hostname
Hostname=xxx01
#启动zabbix
systemctl enable zabbix-agent
systemctl start zabbix-agent.service
systemctl status zabbix-agent.service