今天使用centos,用来学习hadoop,但是在安装yum时简直卡的不行,下载速度只有几百b,连连百度都用不了。
所以在网上搜了几种方法来弄一下,反正几种方法都试过,最后速度确实有所提高,但是就是不知道哪种方法最重要。
三种方法:
一,调vmware
二,设置dns
- vi /etc/resolv.conf
打开文件,在最前面添加:nameserver 127.0.0.1
其他内容保持不变。。
[root@localhost ~]# vim /etc/resolv.conf
[root@localhost ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 127.0.0.1
nameserver 192.168.0.6
nameserver 192.168.0.5
[root@localhost ~]#
[root@localhost ~]# chattr +i /etc/resolv.conf #加锁,解决网络重启之后,会后自动修改的情况
[root@localhost ~]# time curl -s http://www.baidu.com > /dev/null
real 0m3.546s
user 0m0.007s
sys 0m0.011s
2,安装dnsmasq服务
[root@localhost ~]# yum install -y dnsmasq
yum install -y dnsmasq
vi /etc/dnsmasq.conf
listen-address=127.0.0.1 #解除以下一行的注释(并加上ip地址):
resolv-file=/etc/resolv.conf #【ps:此处个人未设置,就OK了】
[root@localhost ~]# service dnsmasq restart
Redirecting to /bin/systemctl restart dnsmasq.service
[root@localhost ~]# time curl -s http://www.baidu.com > /dev/null
real 0m0.042s
user 0m0.006s
sys 0m0.011s
通过前后操作对比,发现以毫秒级返回。。
三,关闭ipv6
vi /etc/modprobe.d/dist.conf
在文件的结尾添加
alias net-pf-10 off
alias ipv6 off
最后保存文件,重启centos