下面操作需全部在root账号里执行,先尝试yum命令是否可用,如果可用,直接跳到步骤5。
1. 先尝试yum是否可用;报错一般是yum所依赖的python版本和当前系统的python版本不匹配导致的
yum
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
No module named yum
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.8 (default, Nov 24 2015, 15:31:38)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
查找当前系统的python版本和python路径,删除现有的/usr/bin/python,然后建立软链到新python路径,再执行yum命令,仍然无解,还报错No module named yum,接下来得重装yum和python了
2. 重装yum和python, 参考http://smilepad.blog.51cto.com/6094369/1333478
1)删除现有Python
[root@test~]# rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps ##强制删除已安装程序及其关联
[root@test~]# whereis python |xargs rm -frv ##删除所有残余文件 ##xargs,允许你对输出执行其他某些命令
[root@test~]# whereis python ##验证删除,返回无结果
2)删除现有的yum
[root@test~]# rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
[root@test~]# whereis yum |xargs rm -frv
3)centos 4.3系统下载了下面几个yum包和python包
centos-yumconf-4-4.5.noarch.rpm
libxml2-python-2.6.16-6.x86_64.rpm
python-2.3.4-14.1.x86_64.rpm
python-elementtree-1.2.6-4.x86_64.rpm
python-sqlite-1.1.6-1.x86_64.rpm
python-urlgrabber-2.9.6-2.noarch.rpm
rpm-python-4.3.3-13_nonptl.x86_64.rpm
yum-2.4.2-2.centos4.noarch.rpm
4)rpm命令安装
rpm -Uvh --replacepkgs python*.rpm
rpm -ivh libxml2-python-2.6.16-6.x86_64.rpm
rpm -ivh centos-yumconf-4-4.5.noarch.rpm
rpm -Uvh --replacepkgs rpm-python*.rpm yum*.rpm
3. 检查是否安装好了yum和python,检查yum软件源配置里是否新增了文件,如下面的CentOS-Base.repo,如果有新增,把它删了
[root@test ]# ll /etc/yum.repos.d/
total 12
-rw-r--r-- 1 root root 2364 Feb 17 2006 CentOS-Base.repo
-rw-r--r-- 1 root root 237 Oct 13 2014 epel_4.repo
-rw-r--r-- 1 root root 156 Jul 8 2014 yum4.repo
4. 再确认yum是否安装好,如果出现coredump问题,可参考http://crazylinux.blog.51cto.com/259244/1050751这个解决
解决办法:
# rpm -q zlib zlib-devel
# cp /usr/lib/libz.so.1.2.3 /usr/local/lib/
# cd /usr/local/lib
# ln -sf libz.so.1.2.3 libz.so
# ln -sf libz.so.1.2.3 libz.so.1
# yum clean all
5. 如果yum安装无问题了,执行 (一般机器上已有samba-common,如果没有的话,也安装一下)
yum install samba
yum install samba-client
yum install samba-swat
全部按y安装
安装ok,rpm -qa|grep samba
[root@test]# rpm -qa|grep samba
samba-3.0.10-1.4E.6
samba-common-3.0.10-1.4E.6
samba-common-3.0.10-1.4E.6
samba-client-3.0.10-1.4E.6
samba-swat-3.0.10-1.4E.6
6. 修改smb.conf
vi /etc/samba/smb.conf
在文件最后添加
[share]
path = /home/work
available = yes
browseable = yes
public = yes
writable = yes
[work]
comment = uc
path=/home/work
create mask = 0664
directory mask = 0775
writable = yes
valid users = work
browseable = yes
7. 需要添加用户,smbpasswd -a work ,两次输入密码【该用户必须是linux现有账号】
8. 启动samba /etc/init.d/smb restart
[root@test samba]# /etc/init.d/smb restart
Shutting down SMB services: [FAILED]
Shutting down NMB services: [FAILED]
Starting SMB services: [ OK ]
Starting NMB services: [ OK ]
正常启动了!!!!!
9. 打开Finder CMD+K smb://10.10.10.10就可以正常使用了
选择work登录,可能不需要输入账号及密码,如果需要输入账号和密码,可能是没smbpasswd添加用户
网友评论