ubuntu-22.04.3 配置

发布时间:2023年12月23日

1.防火墙

a、查看防火墙状态:inactive是关闭,active是开启。
sudo ufw status

b、开启防火墙。
sudo ufw enable

c、关闭防火墙。
sudo ufw disable

2.设置Ip

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

3.更新yum网络源

#备份
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

3.1本地yum源

## 创建挂载目录,挂载镜像源
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

4.安装ssh #启动ssh

sudo apt-get install openssh-server openssh-client net-tools ntpdate -y && sudo /etc/init.d/ssh restart

5.替换上海时区 #时间同步

sudo timedatectl set-timezone Asia/Shanghai  && sudo ntpdate time.windows.com

6.修改root用户密码,命令为:passwd root

#使用root账户,进行ssh登录

sed -i "s|#PermitRootLogin prohibit-password|PermitRootLogin yes|" /etc/ssh/sshd_config 
#重启ssh
sudo systemctl restart ssh

7.修改主机名

sudo hostnamectl set-hostname k8s-mast

8.定时任务同步时间

#查看任务
crontab -l

#编辑任务
crontab -e

#每小时同步一次时间
0 */1 * * * /usr/sbin/ntpdate 192.16.2.20


#保存修改
Ctrl+o

#退出
Ctrl+x

9.安装zabbix监控

#安装
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
文章来源:https://blog.csdn.net/qq_35583325/article/details/135175474
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。