centos8自带DNF插件,无需安装
dnf --version
dnf repolist
dnf repolist all
dnf list
dnf list installed
dnf search 软件名
dnf install vim
dnf remove vim
dnf update systemd
dnf update 或 # dnf upgrade
dnf autoremove
Traceback (most recent call last):
File "/usr/bin/dnf", line 57, in <module>
from dnf.cli import main
File "/usr/lib/python2.7/site-packages/dnf/__init__.py", line 30, in <module>
import dnf.base
File "/usr/lib/python2.7/site-packages/dnf/base.py", line 29, in <module>
import libdnf.transaction
File "/usr/lib64/python2.7/site-packages/libdnf/__init__.py", line 3, in <module>
from . import conf
File "/usr/lib64/python2.7/site-packages/libdnf/conf.py", line 17, in <module>
_conf = swig_import_helper()
File "/usr/lib64/python2.7/site-packages/libdnf/conf.py", line 16, in swig_import_helper
return importlib.import_module('_conf')
File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named _conf
其实最主要的错误就是最后一条:ImportError: No module named _conf
先升级python:
yum update python*
再安装以下软件:
yum install dnf-data dnf-plugins-core libdnf-devel libdnf python2-dnf-plugin-migrate dnf-automatic -y
重新运行dnf。
~ $ dnf --version
4.0.9
Traceback (most recent call last):
File "/usr/bin/dnf", line 58, in <module>
main.user_main(sys.argv[1:], exit_code=True)
File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 179, in user_main
errcode = main(args)
File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 64, in main
return _main(base, args, cli_class, option_parser_class)
File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 95, in _main
cli.configure(list(map(ucd, args)), option_parser())
File "/usr/lib/python2.7/site-packages/dnf/cli/cli.py", line 868, in configure
self.base.output)
File "/usr/lib/python2.7/site-packages/dnf/cli/cli.py", line 137, in print_versions
sm_ui_time(pkg.installtime)))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 4: ordinal not in range(128)
这是由于python2中的编码bug,需要在python目录/lib/python2.7/site-packages/
(系统pyhton目录:/usr/lib/python2.7/site-packages/
)中新建一个文件:sitecustomize.py
,其中包含下列代码
import sys
sys.setdefaultencoding('utf-8')
验证:
dnf --version
dnf install wget
centos7先去官网找npm,配置yum,配置命令
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum update
dnf下载或yum下载
dnf install mysql-server
yum install mysql-server
dnf install redis
dnf install nginx