腾讯云 ubuntu 主机升级到 18.04 LTS 记录
ubuntu 18.04 已经发布了十多天了,今天我尝试了下把我薅羊毛的腾讯云1核1G主机从 16.04 升级到了 18.04 ,过程比较顺利,在此记录下。
备份
为防不测先备份。在腾讯云控制台 云服务器->云硬盘
处点创建快照,妥妥的。
升级
使用 do-release-upgrade -d
命令直接升级即可:
sudo apt update
sudo apt upgrade
sudo do-release-upgrade -d
提示会开新的 sshd,需要允许端口 iptables -I INPUT -p tcp --dport 1022 -j ACCEPT
, 不需要做这个操作因为没有用防火墙限制端口。
然后就是同意更改软件源,从 xenial
到 bionic
,yes;同意下载软件,yes 。
期间出现配置文件更新提示的时候,先按 D 查看更改,再视情况选择 Y 或者 N,一般我都是选择 Y:
-
/etc/bash.bashrc
Y
-
/etc/systemd/system.conf:
Y
-
/etc/sysctl.conf:
Y
,少了这几行,之后手动加回去:kernel.sysrq = 1 net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1
-
/etc/ntp.conf:
Y
,原先使用的腾讯云自己的 ntp 服务器,可以升级后手动改回去,也可以不改。-# servers -server ntpupdate.tencentyun.com iburst +pool 0.ubuntu.pool.ntp.org iburst +pool 1.ubuntu.pool.ntp.org iburst +pool 2.ubuntu.pool.ntp.org iburst +pool 3.ubuntu.pool.ntp.org iburst # Use Ubuntu's ntp server as a fallback. -# pool ntp.ubuntu.com +pool ntp.ubuntu.com
-
/etc/ssh/sshd_config:
install the package maintainer's version
,如果改了端口或者其他设置,可以升级后再改一次,注意若选择了包默认的配置文件,之前手动修改的配置将被覆盖,登录不了的话记得用原始的 22 端口。 -
/etc/logrotate.d/rsyslog
Y
升级完成后按照提示重启。
清理
sudo apt autoremove
sudo apt autoclean
uname -a
确认新的内核,cat /etc/issue
查看当前 ubuntu 版本,完善上面的配置后,sudo reboot
重启。
问题修复
DNS 异常
升级后上不了网了,出现 Temporary failure in name resolution
的问题,是 DNS 解析坏掉了。sudo vi /etc/resolv.conf
,里面只有一条 nameserver 127.0.0.53
,然而 /etc/resolvconf/resolv.conf.d/base
里面有俩条记录,手动把这俩条记录加到 /etc/resolv.conf
就正常了。/etc/resolv.conf
是自动生成的,对它的改动每次开机会被覆盖,所以不能治本。理论上来说会把 /etc/resolvconf/resolv.conf.d/base
包含进来,不知道出了什么问题没有成功。最后我新建了 /etc/resolvconf/resolv.conf.d/tail
文件,里面有俩条 DNS 服务器信息:
nameserver 183.60.83.19
nameserver 183.60.82.98
手动执行 sudo resolvconf -u
进行更新,这次/etc/resolv.conf
里面就多了俩条记录并且重启后还会有,运行 sudo systemd-resolve --status
查看:
一切正常了。
Redis 启动不了
安装 redis-server 时发现启动不了:
systemd[1]: Failed to start Advanced key-value store.
dpkg: error processing package redis-server (--configure):
查看 '/var/log/redis/redis-server.log' 发现 Creating Server TCP listening socket ::1:6379: bind: Cannot assign requested address
错误,应该是没有 ipv6 支持造成的。
解决办法很简单,修改/etc/redis/redis.conf
,将 bind 127.0.0.1 ::1
里的 ::1
去掉,再次执行安装命令 sudo apt install redis-server
即可。