yum error: Failed to initialize NSS library on Centos 7

https://blog.jatiman.com/2018/06/yum-error-failed-to-initialize-nss.html#:~:text=yum%20error%3A%20Failed%20to%20initialize%20NSS%20library%20on,4.%20Step%20Four%20...%205%205.%20Step%20Five

 

Today I get error when accessing yum. This may be caused by the ssh connection closed when doing update. Here the error when I typed  yum :

error: Failed to initialize NSS library
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   cannot import name ts

Please install a package which provides this module, or
verify that the module is installed correctly.

It's possible that the above module doesn't match the
current version of Python, which is:
2.7.5 (default, Aug  4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]

If you cannot solve this problem yourself, please go to
the yum faq at:
  http://yum.baseurl.org/wiki/Faq

The issue will happen only on systems that are updating nss-softokn-freebl alone without updating nss and/or nspr.
Here my last line yum.log and also my Centos Version.

[root@db2 ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[root@db2 ~]# date
Sat Jun 30 17:46:05 WIB 2018
[root@db2 ~]# tail /var/log/yum.log
Jun 26 16:01:47 Updated: cronie-anacron-1.4.11-19.el7.x86_64
Jun 26 16:01:48 Updated: cronie-1.4.11-19.el7.x86_64
Jun 26 16:47:33 Installed: ntpdate-4.2.6p5-28.el7.centos.x86_64
Jun 30 12:35:35 Updated: libgcc-4.8.5-28.el7_5.1.x86_64
Jun 30 12:35:39 Updated: 1:grub2-common-2.02-0.65.el7.centos.2.noarch
Jun 30 12:35:43 Updated: 1:grub2-pc-modules-2.02-0.65.el7.centos.2.noarch
Jun 30 12:35:45 Updated: firewalld-filesystem-0.4.4.4-14.el7.noarch
Jun 30 12:35:51 Updated: tzdata-2018e-3.el7.noarch
Jun 30 12:35:57 Updated: ncurses-base-5.9-14.20130511.el7_4.noarch
Jun 30 12:36:01 Updated: nss-softokn-freebl-3.36.0-5.el7_5.x86_64
[root@db2 ~]#

I've search in google and found tutorial here . After I followed the instruction, there's nothing happened.

Before you follow this tutorial, I'm not responsible if there's any broken system/package when you following this tutorial.

1. Step One
Search nss-util package (search in any centos online repository) that come with nss-softokn-freebl that has been installed by yum (see yum.log). Example, in my case, nss-softokn-freebl-3.36.0-5.el7_5.x86_64 come with nss-3.36.0-5.el7_5.x86_64.rpm and nss-util-3.36.0-1.el7_5.x86_64.rpm

2. Step Two
After that, convert the nss-util rpm package to cpio with command :
rpm2cpio nss-util-3.36.0-1.el7_5.x86_64.rpm | cpio -idmv
3. Step Three
Then, copy the library (.so file) by typing :
yes | cp ./usr/lib64/libnssutil3.so /lib64/libnssutil3.so
Make sure that you did not forget the "." after the cp -R command

Now try to use yum and rpm again like usual. If the issue still persist, do the following step :

4. Step Four
Convert the nss rpm package to cpio with command :
rpm2cpio nspr-4.19.0-1.el7_5.x86_64.rpm | cpio -idmv
5. Step Five
After that, copy the .so file to /usr/lib64 by typing this command
yes | cp -R ./usr/lib64/* /usr/lib64/
Make sure that you did not forget the "." after the cp -R command


Now try to use rpm and yum again like usual. If you find any other solution or still getting this probelm, please comment below.
posted @ 2023-03-14 10:44  香菜哥哥  阅读(957)  评论(0编辑  收藏  举报