ubuntu18.04最⼩化安装ubuntu 18.04虚拟机安装
镜像下载地址:
创建虚拟机[⽆特殊说明直接下⼀步]:
配置完成后启动该虚拟机
直接回车
键盘配置
安装SSH服务⽤于远程连接:
IP设置
配置第⼆块⽹卡ens34 :
⽅法和上⾯配置的⼀样,但是⽹段要改为规划的172
由于都是内⽹这⾥就不写⽹关了
两张⽹卡的配置:
这⾥直接回车 done 下⼀步
软件源:
修改为: mirrors.aliyun/ubuntu
磁盘分区
常规配置模式与LVM配置模式
正常配置的磁盘部署完成后通过df -h 显⽰的是
admin1@node03:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 796M 1.2M 795M 1% /run
/
dev/sda3 98G 6.0G 87G 7% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda2 190M 79M 98M 45% /boot
tmpfs 796M 0 796M 0% /run/user/1000
LVM⽅式部署完成后通过df -h 显⽰的是:
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 796M 1.3M 795M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 98G 6.0G 87G 7% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda2 976M 80M 830M 9% /boot
tmpfs 796M 0 796M 0% /run/user/1000
#LVM企业较为常⽤,它可以动态扩缩容
常规模式配置硬盘[常规与LVM两者⼆选⼀]
创建 boot 分区
创建根分区
检查分区状态:
其他分区不⽤再做了,因为系统装好了⾃⼰就可以操作
LVM模式配置硬盘[常规与LVM两者⼆选⼀]
选择第⼀块磁盘按回车
结果如下:
选择done提交
配置主机名⽤户密码等信息账号密码全部配置为admin1
openssh服务安装:
不安装⽆法通过xshell连接到服务器,这⾥选择安装
这⾥提⽰升级,可以选择取消升级,直接reboot,也可以等待升级完成再重启
升级完成直接选择reboot now 即可
到这 ubuntu就装好了
服务器优化
yum源优化必备软件包安装
#清华源⽹站
mirrors.tuna.tsinghua.edu/help/ubuntu/
#清华ubuntu源 mirrors.tuna.tsinghua.edu/help/ubuntu/
---------------------------------粘贴到sources.list---------------------------------
# 默认注释了源码镜像以提⾼ apt update 速度,如有需要可⾃⾏取消注释
deb mirrors.tuna.tsinghua.edu/ubuntu/ bionic main restricted universe multiverse
# deb-src mirrors.tuna.tsinghua.edu/ubuntu/ bionic main restricted universe multiverse
deb mirrors.tuna.tsinghua.edu/ubuntu/ bionic-updates main restricted universe multiverse
# deb-src mirrors.tuna.tsinghua.edu/ubuntu/ bionic-updates main restricted universe multiverse deb mirrors.tuna.tsinghua.edu/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src mirrors.tuna.tsinghua.edu/ubuntu/ bionic-backports main restricted universe multiverse deb mirrors.tuna.tsinghua.edu/ubuntu/ bionic-security main restricted universe multiverse
# deb-src mirrors.tuna.tsinghua.edu/ubuntu/ bionic-security main restricted universe multiverse # 预发布软件源,不建议启⽤
# deb mirrors.tuna.tsinghua.edu/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src mirrors.tuna.tsinghua.edu/ubuntu/ bionic-proposed main restricted universe multiverse ---------------------------------粘贴到sources.list---------------------------------
#备份
cp /etc/apt/sources.list /etc/apt/sources.list_bak
#新增配置 /etc/apt/sources.list
sudo su -
cat >>/etc/apt/sources.list<<EOF
deb mirrors.aliyun/ubuntu/ bionic main restricted universe multiverse
deb-src mirrors.aliyun/ubuntu/ bionic main restricted universe multiverse
deb mirrors.aliyun/ubuntu/ bionic-security main restricted universe multiverse
deb-src mirrors.aliyun/ubuntu/ bionic-security main restricted universe multiverse
deb mirrors.aliyun/ubuntu/ bionic-updates main restricted universe multiverse
deb-src mirrors.aliyun/ubuntu/ bionic-updates main restricted universe multiverse
ubuntu vim命令deb mirrors.aliyun/ubuntu/ bionic-backports main restricted universe multiverse
deb-src mirrors.aliyun/ubuntu/ bionic-backports main restricted universe multiverse
deb mirrors.aliyun/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src mirrors.aliyun/ubuntu/ bionic-proposed main restricted universe multiverse
EOF
#更新yum源
sudo apt-get update
#安装必备软件包
sudo apt install -y git openssh-server net-tools vim lrzsz wget tree screen lsof tcpdump sysstat net-tools #命令补全⼯具安装
sudo apt-get install bash-completion
vim ~/.bashrc⽂件内容新增:
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
#让配置⽣效
source ~/.bashrc
允许root远程登录[可选]
sudo vim /etc/ssh/sshd_config
......
#PermitRootLogin prohibit-password
改成:
PermitRootLogin yes
Port 22 #可选这⾥修改默认ssh端⼝号
#重启
systemctl restart sshd
#设置root密码:
passwd root
#测试
ssh root@192.168.3.103
防⽕墙优化
sudo ufw disable # 关闭防⽕墙
sudo ufw enable # 开启防⽕墙
sudo ufw status # 查看防⽕墙当前状态
建议直接关闭防⽕墙
ufw disable
IP地址配置:
⽹卡配置和⽣效:
sudo vim /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
ethernets:
ens33: #修改ens33⽹卡IP
addresses:
- 192.168.3.100/24
gateway4: 192.168.3.2
nameservers:
addresses:
- 223.5.5.5
search:
-
223.6.6.6
ens34:
addresses:
- 172.16.10.100/24 #修改ens34⽹卡IP
nameservers:
addresses:
- 223.5.5.5
search: []
version: 2
#修改完毕后,
sudo netplan apply
⽤户级别切换[可选]
# ubuntu18.04 切换⽂本模式或图形界⾯模式
sudo systemctl set-default multi-user.target #默认进⼊字符界⾯sudo systemctl set-default graphical.target #默认进⼊图形界⾯其他优化
sudo su -
cat >>/etc/f<<EOF
# 末尾添加如下内容
* soft nofile 655360
* hard nofile 131072
* soft nproc 655350
* hard nproc 655350
* soft memlock unlimited
* hard memlock unlimited
EOF
sysctl -p
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论