Ubuntu sudo su 很慢
原因:Ubuntu Server被设计成一种类似于分布式的操作系统网结构,允许/etc/sudoers中的成员不在本机上。从而sudo时会先从网络上寻找可能的sudoer然后才是本地. 而这10s左右的时间就是整个DNS流程的最长时间。
# 将hostname 在hosts文件里加个映射
127.0.0.1 localhost uvm-01
Ubuntu 无法安装依赖库
## 报错如下
$sudo apt install lrzsz
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package lrzsz
## 出现这个问题的原因之一是apt的源缺失,运行以下命令即可
sudo apt-get update
二进制安装Mysql之后提示报错
## 报错
$sudo mysql
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
## 解决
sudo apt-get install libncurses5
网卡无法配置ip地址的处理
### 查看现有的网卡信息
sudo lshw -class network
## 配置ip地址
sudo ip addr add 10.10.11.90/24 dev ens160
## 配置网关
sudo ip route add default via 10.10.11.1
###
ping www.baidu.com
### 安装netplan
apt install netplan.io
网卡配置官网参考:
###
https://ubuntu.com/server/docs/network-configuration
配置DNS有时候不生效
我们在 netplan 配置了DNS但是没有生效。默认情况下是会生效的,不生效的时候才做以下操作。
cat /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by the datasource. Changes
# to it will not persist across an instance reboot. To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
ens160:
addresses:
- 10.10.11.125/24
gateway4: 10.10.11.1
nameservers:
addresses:
- 10.10.10.120
- 8.8.8.8
version: 2
改了之后,dig内网dns的信息没有结果。检查 /etc/resolv.conf 如下:
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "systemd-resolve --status" to see details about the uplink DNS servers
# currently in use.
nameserver 127.0.0.53
options edns0
很显然,我们需要做的就是在/etc/resolve.conf中,配置我们需要的域名解析服务器地址,例如:“nameserver 8.8.8.8”,但是这个文件即使我们修改了,重启之后又覆盖了
解决方法如下:
cat /etc/systemd/resolved.conf
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See resolved.conf(5) for details
[Resolve]
DNS=10.1.10.11 8.8.8.8
#DNS=
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#Cache=yes
#DNSStubListener=yes
重启域名解析服务:
### 重启服务
systemctl restart systemd-resolved
systemctl enable systemd-resolved
## 验证
dig xx.qq.com
## 查看上游dns
systemd-resolve --status