美文网首页
centos安装配置

centos安装配置

作者: sknfie | 来源:发表于2020-12-08 18:30 被阅读0次

    概述

    CentOS 安装后,需要对网络,dns等进行配置。

    配置网络

    ONBOOT是指明在系统启动时是否激活网卡,只有在激活状态的网卡才能去连接网络,进行网络通讯

    cd /etc/sysconfig/network-scripts
    
    vi ifcfg-enp0s3  //ONBOOT改成yes
    
    TYPE=Ethernet
    PROXY_METHOD=none
    BROWSER_ONLY=no
    BOOTPROTO=dhcp
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=no
    IPV6INIT=yes
    IPV6_AUTOCONF=yes
    IPV6_DEFROUTE=yes
    IPV6_FAILURE_FATAL=no
    IPV6_ADDR_GEN_MODE=stable-privacy
    NAME=enp0s3
    UUID=38f7d015-94e8-4387-b440-4347a4218129
    DEVICE=enp0s3
    ONBOOT=yes
    

    重启网络

    service network restart
    

    配置DNS

    检查NetworkManager状态

    systemctl status NetworkManager.service
    â—� NetworkManager.service - Network Manager
       Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled)
       Active: **active (running)** since Tue 2020-12-08 16:38:44 CST; 56min ago
         Docs: man:NetworkManager(8)
     Main PID: 618 (NetworkManager)
       CGroup: /system.slice/NetworkManager.service
              |——618 /usr/sbin/NetworkManager --no-daemon
              |——657 /sbin/dhclient -d -q -sf /usr/libexec/nm-dhcp-helper -pf /var/run/dhclient-enp0s3.pid -lf /var/lib/NetworkManager/dhclient-38f7d015-94e8-...
    
    Dec 08 16:38:50 localhost.localdomain NetworkManager[618]: <info>  [1607416730.9761] device (enp0s3): Activation: successful, device activated.
    Dec 08 16:38:50 localhost.localdomain NetworkManager[618]: <info>  [1607416730.9765] manager: startup complete
    Dec 08 16:38:50 localhost.localdomain NetworkManager[618]: <info>  [1607416730.9768] manager: NetworkManager state is now CONNECTED_GLOBAL
    Dec 08 16:38:54 localhost.localdomain dhclient[663]: XMT: Info-Request on enp0s3, interval 7990ms.
    Dec 08 16:39:02 localhost.localdomain dhclient[663]: XMT: Info-Request on enp0s3, interval 16420ms.
    Dec 08 16:39:18 localhost.localdomain dhclient[663]: XMT: Info-Request on enp0s3, interval 33000ms.
    Dec 08 16:39:32 localhost.localdomain NetworkManager[618]: <warn>  [1607416772.6475] dhcp6 (enp0s3): request timed out
    Dec 08 16:39:32 localhost.localdomain NetworkManager[618]: <info>  [1607416772.6475] dhcp6 (enp0s3): state changed unknown -> timeout
    Dec 08 16:39:32 localhost.localdomain NetworkManager[618]: <info>  [1607416772.6486] dhcp6 (enp0s3): canceled DHCP transaction, DHCP client pid 663
    Dec 08 16:39:32 localhost.localdomain NetworkManager[618]: <info>  [1607416772.6486] dhcp6 (enp0s3): state changed timeout -> done
    

    检查NetworkManager网络管理接口

    [root@localhost network-scripts]# nmcli dev status
    DEVICE  TYPE      STATE      CONNECTION 
    enp0s3  ethernet  connected  enp0s3     
    lo      loopback  unmanaged  --         
    

    检查NetworkManager网络连接

    [root@localhost network-scripts]# nmcli connection show
    NAME    UUID                                  TYPE      DEVICE 
    enp0s3  38f7d015-94e8-4387-b440-4347a4218129  ethernet  enp0s3 
    

    设置dns

    nmcli con mod enp0s3 ipv4.dns "114.114.114.114 8.8.8.8"
    

    dns生效

    nmcli con up enp0s3 
    

    查看resolv.conf文件

    [root@localhost network-scripts]# vi /etc/resolv.conf 
    # Generated by NetworkManager
    nameserver 172.20.10.1
    nameserver 114.114.114.114
    nameserver 8.8.8.8
    

    配置 hosts

    172.20.10.3 www.myhost.com
    

    关闭防火墙

    一些软件如集群之间需要打开固定的端口,防止连接不上,先关闭防火墙

    [root@localhost network-scripts]# systemctl stop firewalld.service
    [root@localhost network-scripts]# systemctl disable firewalld.service
    

    配置 yum 工具

    yum clean all
    # 生成缓存,安装的时候从缓存中查询相关数据,提高安装速度
    yum makecache
    
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: mirrors.tuna.tsinghua.edu.cn
     * extras: mirrors.tuna.tsinghua.edu.cn
     * updates: mirrors.tuna.tsinghua.edu.cn
    base                                                                                                                                  | 3.6 kB  00:00:00     
    extras                                                                                                                                | 2.9 kB  00:00:00     
    updates                                                                                                                               | 2.9 kB  00:00:00     
    (1/6): extras/7/x86_64/filelists_db                                                                                                   | 224 kB  00:00:00     
    (2/6): base/7/x86_64/filelists_db                                                                                                     | 7.2 MB  00:00:02     
    (3/6): extras/7/x86_64/other_db                                                                                                       | 134 kB  00:00:15     
    (4/6): updates/7/x86_64/other_db                                                                                                      | 226 kB  00:00:15     
    (5/6): updates/7/x86_64/filelists_db                                                                                                  | 2.1 MB  00:00:16     
    (6/6): base/7/x86_64/other_db                                                                                                         | 2.6 MB  00:00:16     
    Metadata Cache Created
    

    安装jdk1.8

    [root@localhost yum.repos.d]# yum list|grep jdk
    java-1.8.0-openjdk.i686                     1:1.8.0.272.b10-1.el7_9    updates  
    java-1.8.0-openjdk.x86_64                   1:1.8.0.272.b10-1.el7_9    updates  
    
    [root@localhost yum.repos.d]# yum install -y java-1.8.0-openjdk.x86_64
    

    相关文章

      网友评论

          本文标题:centos安装配置

          本文链接:https://www.haomeiwen.com/subject/gtkqgktx.html