1. 配置静态IP

  1. # 1.修改的网卡配置
  2. su - root
  3. cd /etc/sysconfig/network-scripts
  4. vim ifcfg-ens33
  5. ## 替换的配置内容
  6. TYPE=Ethernet
  7. PROXY_METHOD=none
  8. BROWSER_ONLY=no
  9. BOOTPROTO=static # 配置成静态网卡
  10. DEFROUTE=yes
  11. IPV4_FAILURE_FATAL=yes
  12. IPV6INIT=no
  13. IPV6_AUTOCONF=yes
  14. IPV6_DEFROUTE=yes
  15. IPV6_FAILURE_FATAL=no
  16. IPV6_ADDR_GEN_MODE=stable-privacy
  17. NAME=ens33 # 设置网卡的名称
  18. UUID=81d93f93-820f-48ef-a84c-d86baaaff978
  19. DEVICE=ens33
  20. ONBOOT=yes # 设置成开机启动
  21. IPADDR=192.168.160.51 # 设置的静态IP
  22. PREFIX=24 # 子网掩码的长度
  23. GATEWAY=192.168.160.2 # 设置的网关
  24. DNS1=223.5.5.5 # DNS的域名解析
  25. ## 重启网卡的操作
  26. /etc/init.d/network restart
  27. or
  28. service network restart

2. 修改过阿里的源

  1. # 替换国内源
  2. su - root
  3. yum install -y wget
  4. # 备份原来的源
  5. mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
  6. ## 下载源
  7. wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  8. 【或者】
  9. curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  10. # 更新源
  11. yum clean all # 清除缓存
  12. yum makecache # 生成缓存
  1. # 备份repo文件
  2. mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
  3. ## 可以修改CentOS-Base.repo的文件内容如下:
  4. # CentOS-Base.repo
  5. #
  6. # The mirror system uses the connecting IP address of the client and the
  7. # update status of each mirror to pick mirrors that are updated to and
  8. # geographically close to the client. You should use this for CentOS updates
  9. # unless you are manually picking other mirrors.
  10. #
  11. # If the mirrorlist= does not work for you, as a fall back you can try the
  12. # remarked out baseurl= line instead.
  13. #
  14. #
  15. [base]
  16. name=CentOS-$releasever - Base - mirrors.aliyun.com
  17. failovermethod=priority
  18. baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
  19. http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
  20. http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
  21. gpgcheck=1
  22. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  23. #released updates
  24. [updates]
  25. name=CentOS-$releasever - Updates - mirrors.aliyun.com
  26. failovermethod=priority
  27. baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
  28. http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
  29. http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
  30. gpgcheck=1
  31. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  32. #additional packages that may be useful
  33. [extras]
  34. name=CentOS-$releasever - Extras - mirrors.aliyun.com
  35. failovermethod=priority
  36. baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
  37. http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
  38. http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
  39. gpgcheck=1
  40. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  41. #additional packages that extend functionality of existing packages
  42. [centosplus]
  43. name=CentOS-$releasever - Plus - mirrors.aliyun.com
  44. failovermethod=priority
  45. baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
  46. http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
  47. http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
  48. gpgcheck=1
  49. enabled=0
  50. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  51. #contrib - packages by Centos Users
  52. [contrib]
  53. name=CentOS-$releasever - Contrib - mirrors.aliyun.com
  54. failovermethod=priority
  55. baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
  56. ## 更新yum源:
  57. yum update
  58. # 查看yum仓库中,共有多少包
  59. yum repolist