首页 > 系统相关 >安装Centos7初始化操作系统

安装Centos7初始化操作系统

时间:2023-03-16 20:35:38浏览次数:45  
标签:初始化 00 操作系统 firewalld Centos7 lft ff root localhost

设置静态网络

1、设置静态网络,一是用来不让地址飘忽不定,二来是为了访问外网。

命令如下:

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33

修改内容:

TYPE="Ethernet"
BOOTPROTO="static"    # 设置为静态网络static。
DEFROUTE="yes"
PEERDNS="yes"
PEERROUTES="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
UUID="66f9933b-54eb-4156-81f4-8cb3f344124b"
DEVICE="ens33"
ONBOOT="yes"
IPADDR="192.168.43.2"    # 配置跟宿主机联网的同网段IP地址
NETMASK="255.255.255.0"      # 配置子网掩码
GATEWAY="192.168.43.1"      # 配置宿主机的网关
DNS1="8.8.8.8"      # 配置DNS解析服务器

 2、重启网络服务。

[root@localhost ~]# systemctl restart network

 3、查看IP地址是否已经更改。

[root@localhost ~]# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:b2:e5:54 brd ff:ff:ff:ff:ff:ff
    inet 192.168.43.2/24 brd 192.168.43.255 scope global ens33    # 可以查看这里IP地址已经更改
       valid_lft forever preferred_lft forever
    inet6 2409:890c:39b0:630:1427:b41a:753c:ef8d/64 scope global noprefixroute dynamic 
       valid_lft 3472sec preferred_lft 3472sec
    inet6 fe80::e458:494f:e11c:bbe8/64 scope link 
       valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000
    link/ether 52:54:00:cd:f3:96 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000
    link/ether 52:54:00:cd:f3:96 brd ff:ff:ff:ff:ff:ff

 4、验证网络是否联通。

[root@localhost ~]# ping www.baidu.com
PING www.a.shifen.com (39.156.66.18) 56(84) bytes of data.
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=1 ttl=50 time=51.6 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=2 ttl=50 time=69.3 ms
64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=3 ttl=50 time=57.5 ms

 关闭防火墙

1、关闭防火墙,防止以后服务会被防火墙挡掉。

[root@localhost ~]# iptables -F
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
[root@localhost ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

Mar 16 02:52:21 localhost.localdomain systemd[1]: Starting firewalld - dynami....
Mar 16 02:52:27 localhost.localdomain systemd[1]: Started firewalld - dynamic....
Mar 16 03:45:13 localhost.localdomain systemd[1]: Stopping firewalld - dynami....
Mar 16 03:45:18 localhost.localdomain systemd[1]: Stopped firewalld - dynamic....
Hint: Some lines were ellipsized, use -l to show in full.

 关闭selinux

1、临时关闭selinux。

[root@localhost ~]# getenforce
Enforcing
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce
Permissive

 2、永久关闭selinux。

执行命令:

[root@localhost ~]# vim /etc/selinux/config       # 这两种配置文件效果一样,任选其一。
[root@localhost ~]# vim /etc/sysconfig/selinux 

 修改内容:

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
# SELINUX=enforcing      # 注释第一行即可
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
# SELINUXTYPE=targeted      # 注释这一行即可

 修改主机名

修改命令如下:

[root@localhost ~]# hostnamectl set-hostname K8s-master
[root@localhost ~]# bash
[root@k8s-master ~]# 

 配置主机和IP地址映射关系

1、修改配置文件。

执行命令:

[root@k8s-master ~]# vim /etc/hosts

 添加内容:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
K8s-master 192.168.43.2      # 前面是主机名,后面是对应IP
K8s-node01 192.168.43.3
K8s-node02 192.168.43.4

 2、重载配置文件。

[root@k8s-master ~]# systemctl daemon-reload 

 配置网络yum源

阿里云Centos7镜像下载地址:Centos7地址

1、安装wget工具。

[root@k8s-master ~]# yum -y install wget

 2、备份本地源。

[root@k8s-master ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

 3、下载阿里云镜像源。

[root@k8s-master ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

 4、生成缓存。

[root@k8s-master ~]# yum makecache

5、安装epel扩展源(可以搜到更多的包)。

[root@k8s-master ~]# yum install -y epel-release

标签:初始化,00,操作系统,firewalld,Centos7,lft,ff,root,localhost
From: https://www.cnblogs.com/Bookcict/p/17224025.html

相关文章

  • centos7 安装 postgresql-9.2
    1.添加yum配置yuminstall-yhttp://download.postgresql.org/pub/repos/yum/9.2/redhat/rhel-7-x86_64/pgdg-centos92-9.2-3.noarch.rpm2.安装服务yumins......
  • Centos7配置本地及网络yum源
    开源镜像站:阿里云开源镜像站:https://mirrors.aliyun.com/网易开源镜像站:https://mirrors.163.com/中科大开源镜像站:https://mirrors.ustc.edu.cn/清华开源镜像站:http......
  • CentOS7永久挂载硬盘
    mkdir/mnt/cdrom//创建挂载硬盘目录mount-orw/dev/vdb1/mnt/cdrom//挂载硬盘设备/dev/vdb1rw是可读可写,ro是只读上面步骤重启会失效,解决办......
  • Docker安装及初始化
    1Docker安装方法1.1(推荐)根据官方指引:InstallDockerEngine安装;方法1.2(不推荐)使用iEDA仓库中的build脚本安装,如下:#内部仓库,等待开源2初始化Docker设置方......
  • centos7拷贝挂载硬盘一些命令检查硬盘序列号
    Centos新增硬盘以后,系统不能自动进行识别。1.由于不知道新增硬盘挂载的位置,可以先查看现有硬盘挂载的适配器。ls-l/sys/block/sdalrwxrwxrwx.1rootroot0Jun1511......
  • centos7 安装docker 错误解决
    yum-config-manager--add-repohttp://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repoyum-yinstalldocker-ce安装报错:错误:软件包:2:container-selinux-2......
  • 单核无操作系统如何实现任务并行运行demo之ardiuno读取MPU6050进行oled显示和控制ws28
    实物演示​​视频请转向哔站​​1.起源一直想做一个多种模式显示的灯阵控制小玩意作为床头灯,这样每次一个人在乌漆嘛黑的卧室刷手机时能够给自己带来一丝暖意!!!此外在......
  • Vscode golang初始化配置
    1、下载安装GO插件2、写代码时vscode提示你需要安装go插件,点击installall进行安装如果安装失败,原因是有道墙,解决方法是,配置国内源如下:goenv-wGO111MODULE=ongoe......
  • centos7.6安装GCC9.3.0
    CentOS7.6下安装gcc9.3.0本文主要介绍怎么在CentOS7.6环境下安装GCC9.3.0,适用于部分源码包需要高版本的gcc进行编译的场景,需要准备的环境有:CentOS7.6gcc-9.3.0.......
  • 5.9 GDT与IDT的初始化(harib02i)
    5.9GDT与IDT的初始化(harib02i)CPU用8字节来表示一个段的1.段的大小2.段的起始地址3.段的管理属性(禁止写入,禁止执行,系统专用)信息,但8字节(64位)远大于段寄存器(16位),故用段寄存......