您的当前位置:首页正文

修改mysql配置文件vim commend not found 和安装vim -Temporary failure resolving 'deb.debian.org和'docker联网问题解决

2024-11-23 来源:个人技术集锦

这样要从开始mysql-binlog 说起了。
问题描述:
1 起因:修改docker容器mysql配置文件开启binlog实现canal微服务监听数据库的改变。发现指定/etc/mysql/my.cnf不能vim修改编辑,只能查看。
2 因为是在docker容器内,他就像个虚拟机,跟外界没有关联,要安装vim包才可以进行操作。如下命令
apt-get update
apt-get install vim
3 执行完报错如下:

root@7ccd5ffbc1e1:/etc/mysql# apt-get install vim
Reading package lists… Done
Building dependency tree
Reading state information… Done
Package vim is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package ‘vim’ has no installation candidate

4 apt-get update 报错失败是因为没有配置dns的原因

cd /etc/docker
touch daemon.json
添加
{
“dns”: [“8.8.8.8”, “114.114.114.114”]
}

重启服务
systemctl restart docker
重新执行2更新安装即可成功,如下:

root@7ccd5ffbc1e1:/etc/mysql# apt-get update
Hit:1 http://repo.mysql.com/apt/debian buster InRelease
Get:2 http://deb.debian.org/debian buster InRelease [122 kB]
Get:3 http://deb.debian.org/debian buster-updates InRelease [49.3 kB]
Hit:4 http://security.debian.org/debian-security buster/updates InRelease
Get:5 http://deb.debian.org/debian buster/main amd64 Packages [7907 kB]
Get:6 http://deb.debian.org/debian buster-updates/main amd64 Packages [7380 B]
Fetched 3480 kB in 18s (198 kB/s)
Reading package lists… Done
root@7ccd5ffbc1e1:/etc/mysql# apt-get install vim
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
vim-common vim-runtime xxd
Suggested packages:
ctags vim-doc vim-scripts
The following NEW packages will be installed:
vim vim-common vim-runtime xxd
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 7390 kB of archives.

显示全文