• ubuntu 20.04 server安装


    ubuntu 20.04 server安装

    ubuntu-20.04.6-live-server-amd64.iso

    https://releases.ubuntu.com/
    https://releases.ubuntu.com/20.04.6/

    Ubuntu版本查看

    lsb_release -a

    ● mysql 版本查看

    mysql --version

    安装

    vi

    安装vim:
    ubuntu预装的是vim tiny版本,而需要的是vim full版本。执行下面的语句安装vim full版本:
    $sudo apt-get remove vim-common
    $sudo apt-get install vim
    这样就行了。
    
    • 1
    • 2
    • 3
    • 4
    • 5

    设置时区

    查看本地时间 
    timedatectl status
    sudo timedatectl set-timezone Asia/Shanghai
    
    • 1
    • 2
    • 3

    安装ubuntu20.04 TLS系统后,开机卡在“A start job is running for wait for network to be Configured”等待连接两分多钟。

    cd /etc/systemd/system/network-online.target.wants/
    
    
    • 1
    • 2

    在[Service]下添加 TimeoutStartSec=2sec,(设置超时时间为2秒)如下:
    sudo vi systemd-networkd-wait-online.service

    [Service]
    Type=oneshot
    ExecStart=/lib/systemd/systemd-networkd-wait-online
    RemainAfterExit=yes
    TimeoutStartSec=2sec
    
    • 1
    • 2
    • 3
    • 4
    • 5

    sudo reboot

    1、禁用cloud-init
    这是最简单最安全的方法,在 /etc/cloud 目录下创建 cloud-init.disabled 文件重启后生效。删除该文件就可以恢复

    # 创建cloud-init.disabled文件
    sudo touch /etc/cloud/cloud-init.disabled
    
    # 重启
    reboot
    
    • 1
    • 2
    • 3
    • 4
    • 5

    1

    至此,已经成功扩容

    注意:Ubuntu系统安装的时候,需取消Set up this disk as an LVM group选项,否则此方法无效

    server版:

    在这里插入图片描述

    grub

    最近要配置新的引导系统盘,所以需要用到自己电脑中ubuntu20.04系统的开机引导grub,但是默认开机后直接就进入系统了,根本无法进入引导菜单编辑界面,需要自己修改配置文件。
    /etc/default/grub
    打开后我们首先把值为hidden这行使用井号给注释掉。
    然后分别把 TIMEOUT设置为 30,还有CMDLINE设置为text,然后记得保存。
    修改完成后我们 sudo update-grub重新更新grub配置
    在这里插入图片描述
    最后我们重新启动ubuntu20.04系统,开机后就可以进入引导菜单选择界面了。

    设置IP地址

    参考
    ubuntu 20.04 设置静态 IP地址
    https://blog.csdn.net/wowocpp/article/details/127450670

    sudo apt install net-tools

    ip address show

    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host 
           valid_lft forever preferred_lft forever
    2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
        link/ether 04:d9:f5:03:08:03 brd ff:ff:ff:ff:ff:ff
        inet 192.168.99.137/24 brd 192.168.99.255 scope global dynamic enp3s0
           valid_lft 17342sec preferred_lft 17342sec
        inet6 fe80::6d9:f5ff:fe03:803/64 scope link 
           valid_lft forever preferred_lft forever
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    cd /etc/netplan/
    sudo vi 00-installer-config.yaml
    原来的 内容

    # This is the network config written by 'subiquity'
    network:
      ethernets:
        enp3s0:
          dhcp4: true
        enp4s0:
          dhcp4: true
      version: 2
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    修改之后的

    # This is the network config written by 'subiquity'
    network:
      ethernets:
        enp3s0:
          dhcp4: true
        enp4s0:
          addresses: [192.168.99.137/24]
          dhcp4: no
          optional: true
          gateway4: 192.168.99.1
          nameservers:
                  addresses: [192.168.99.1,8.8.8.8]
      version: 2
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    real

    # This is the network config written by 'subiquity'
    network:
      ethernets:
        enp3s0:      
          addresses: [192.168.99.154/24]
          dhcp4: no
          optional: true
          gateway4: 192.168.99.1
          nameservers:
                          addresses: [192.168.99.1,8.8.8.8] 
    
      version: 2
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    sudo netplan apply

    挂载系统

    cd /media/
    sudo mkdir bigdrive
    sudo vi fstab
    cat /etc/fstab

    # /etc/fstab: static file system information.
    #
    # Use 'blkid' to print the universally unique identifier for a
    # device; this may be used with UUID= as a more robust way to name devices
    # that works even if disks are added and removed. See fstab(5).
    #
    # <file system> <mount point>   <type>  <options>       <dump>  <pass>
    # / was on /dev/sdc2 during curtin installation
    /dev/disk/by-uuid/e3e527d3-f8ae-4aa6-b6f1-448d12fd479a / ext4 defaults 0 1
    /swap.img	none	swap	sw	0	0
    /dev/sda	/media/bigdrive ext3  	defaults	0	0
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    定时器

    /etc/init.d/cron status
    定时器是否启动
    sudo crontab -l
    sudo crontab -e

    系统备份

    备份系统

    Ubuntu备份与恢复
    https://blog.csdn.net/leida_wt/article/details/130059123

    Ubuntu Server 20.04 系统安装(九):ubuntu server系统备份及恢复
    https://blog.csdn.net/u013250861/article/details/130819894

    sudo passwd root
    cd /
    su root
    tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /
    tar -cvpzf /data/backup.tar.gz --exclude=/data --exclude=/proc --exclude=/sys --exclude=/mnt --exclude=/lost+found --exclude=/home/wyr/anaconda3/envs --one-file-system /
    
    • 1
    • 2
    • 3
    • 4
    • 5

    在这个临时系统中我们可以访问到原系统盘(应该会挂载到/media),进入原系统的根目录,将备份文件解压到跟路径:
    tar -xpzf /path/to/backup.tar.gz --numeric-owner
    注意:由于我们现在是在live cd系统中,故必须加上–numeric-owner参数,表示在不转换用户id的情况下恢复文件所有权。
    结束后,关机,拔掉启动盘,重新启动,就可以正常进入原ubuntu系统了。

    sudo su
    tar -cpzf /path/to/backup.tar.gz --exclude=/tmp --one-file-system /
    其中-cpzf 表示建立压缩归档文件,并保持所有的权限信息。–one-file-system 表示忽略挂载点和非文件路径(如/dev)。

    可借助pigz工具启用多线程压缩,加快执行速度:

    其中-cpzf 表示建立压缩归档文件,并保持所有的权限信息。–one-file-system 表示忽略挂载点和非文件路径(如/dev)。

    可借助pigz工具启用多线程压缩,加快执行速度:

    tar -cpf - --exclude=/tmp --one-file-system / | pigz > /path/to/backup.tar.gz

    Ubuntu创建用户,给予sudo权限

    https://blog.csdn.net/wowocpp/article/details/100115112

    时区 设置:

    https://blog.csdn.net/wowocpp/article/details/127921144

    11

    sudo apt install sshpass

    ubuntu server 20.04 备份和恢复 系统

    https://blog.csdn.net/wowocpp/article/details/134824060

  • 相关阅读:
    洛科威多功能岩棉板助力节能减碳战略,推动碳达峰目标实现
    农村人口房屋管理系统(VB+access)
    [单片机框架][bsp层][N32G4FR][bsp_adc] ADC配置和使用
    安卓常见设计模式6------代理模式(Kotlin版)
    Git---idea中git的基本操作
    《Effective Objective-C 2.0》读书笔记——对象、消息、运行期
    MySQL主从复制与读写分离
    Redis 源码解析之通用双向链表(adlist)
    Spring IOC源码:实例化前的准备工作
    【微客云】91优惠话费充值API接口开发功能介绍
  • 原文地址:https://blog.csdn.net/wowocpp/article/details/134246564