安装centos stream 8的笔记

Posted bmwhero

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安装centos stream 8的笔记相关的知识,希望对你有一定的参考价值。

第一次安装centos stream 8,安装和之前没什么区别,但是配置有些东西变了,做个笔记

一、安装

下载centos stream 8的iso文件:

https://mirrors.tuna.tsinghua.edu.cn/centos/8-stream/isos/x86_64/

安装过程与之前的centos类似,我这里进行的是在vmware workstation 16.1中安装。

文件系统配置建议/boot 512MB占sda1,LVM管理 / 和 swap,创建sda2作为物理卷,vg00作为卷组,swap给2GB,/ 给20GB;

时区选择中国上海;

关闭没有任何用的KDump;

软件可以使用最小化software的方式安装,安装之后 / 下约1.9GB,一般不需要GUI;

网络和主机名可以先不配置,安装好了以后再配。

二、配置

1 处理1分30秒等待的bug

启动时,systemd-journal-flush服务卡住,提示
centos8 a start job is running for flush journal......
等待1分30秒后通过
该问题是因为systemd-journal-flush.service这个服务,在启动时因为/var/log下没有journal目录,启动失败导致的
首次进入OS,手工在/var/log下,创建该目录
mkdir /var/log/journal
重启OS验证该问题解决。
详见:
https://forums.centos.org/viewtopic.php?f=54&t=80095

2 启用ens32网卡

cd /etc/sysconfig/network-scripts
cp ifcfg-ens32 /tmp/ifcfg-ens32
sed -i \'s/ONBOOT=no/ONBOOT=yes/\' ifcfg-ens32
nmcli c reload
nmcli c down ens32
nmcli c up ens32

注意centos8开始强制使用NetworkManager服务管理网络,老牌的network不让用了,且nmcli命令代替了之前的ifup和ifdown。

网卡启用后可以使用终端命令行执行后续配置,不用再在控制台中弄了。

3 配置主要的yum源

默认的yum源用的是官方的,特别慢,可以将repo文件全部备份,换成全套阿里yum源。

CentOS-Base.repo

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
 
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
#failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
        http://mirrors.aliyuncs.com/centos/$releasever/BaseOS/$basearch/os/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
#failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/os/
        http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/os/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/os/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
#failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/os/
        http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/os/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
 
[PowerTools]
name=CentOS-$releasever - PowerTools - mirrors.aliyun.com
#failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/PowerTools/$basearch/os/
        http://mirrors.aliyuncs.com/centos/$releasever/PowerTools/$basearch/os/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/PowerTools/$basearch/os/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official


[AppStream]
name=CentOS-$releasever - AppStream - mirrors.aliyun.com
#failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
        http://mirrors.aliyuncs.com/centos/$releasever/AppStream/$basearch/os/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/AppStream/$basearch/os/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official

docker-ce.repo

#docker-ce.repo
#docker repo from aliyun
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-stable-debuginfo]
name=Docker CE Stable - Debuginfo $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/debug-$basearch/stable
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-stable-source]
name=Docker CE Stable - Sources
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/source/stable
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-test]
name=Docker CE Test - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-test-debuginfo]
name=Docker CE Test - Debuginfo $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/debug-$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-test-source]
name=Docker CE Test - Sources
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/source/test
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-nightly]
name=Docker CE Nightly - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-nightly-debuginfo]
name=Docker CE Nightly - Debuginfo $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/debug-$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-nightly-source]
name=Docker CE Nightly - Sources
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/source/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

kubernetes.repo

#kubernetes.repo
#kubernetes el7 from aliyun
[kubernetes]
name=Kubernetes el7
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg

4 yum install一些常用包

yum clean all
yum makecache
yum install chrony iproute net-tools telnet vim samba-client sysstat nmap-ncat tree psmisc lsof iputils

5 防火墙、selinux关闭并打卡时间同步

systemctl stop firewalld
systemctl disable firewalld
sed -i \'s/enforcing/disabled/\' /etc/selinux/config
systemctl start chronyd
systemctl enable chronyd

6 网卡标准配置

DHCP的网卡:

TYPE=Ethernet
DEVICE=ens32
NAME=ens32
ONBOOT=yes
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
BOOTPROTO=DHCP

注意centos8开始强制使用NetworkManager管理网络,NAME参数必须有。DHCP也是做标准虚拟机镜像推荐使用的设置。

固定IP的网卡:

TYPE=Ethernet
DEVICE=ens32
NAME=ens32
ONBOOT=yes
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
BOOTPROTO=none
IPADDR=192.168.124.11
NETMASK=255.255.255.0
GATEWAY=192.168.124.1

7 克隆新系统

将该centos stream 8,克隆为一个新的操作系统,需要做的工作:

1.修改hostname
hostnamectl --static set-hostname newhostname
2.网卡文件/etc/sysconfig/network-scripts/ifcfg-ens32中改为
BOOTPROTO=none
并增加指定的IP地址、子网掩码和网关
IPADDR=192.168.124.11
NETMASK=255.255.255.0
GATEWAY=192.168.124.1
3./etc/resolv.conf中增加DNS
nameserver 114.114.114.114
nameserver 8.8.8.8
4.通过nmcli重新加载网卡
nmcli c reload
nmcli c down ens32
nmcli c up ens32
5.验证
可以ping通网关和www.baidu.com

(全文完)

Kafka:ZK+Kafka+Spark Streaming集群环境搭建VMW安装四台CentOS,并实现本机与它们能交互,虚拟机内部实现可以上网。

Centos7出现异常:Failed to start LSB: Bring up/down networking.

按照《Kafka:ZK+Kafka+Spark Streaming集群环境搭建(一)VMW安装四台CentOS,并实现本机与它们能交互,虚拟机内部实现可以上网。》配置好虚拟机,正在使用中,让它强制断电后,启动起来发现ip无法访问,而且重启网络失败:

执行:systemctl restart network.service
出现异常:Failed to start LSB: Bring up/down networking.

执行ifconfig,发现配置好的ens33也不见了:

[spark@master ~]$ ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 4  bytes 336 (336.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4  bytes 336 (336.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

解决方案:

systemctl stop NetworkManager
systemctl disable NetworkManager
Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.

重新启动网络:

systemctl start network.service

重新ifconfig查看是否ens33启用

[root@master spark]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.120  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::20c:29ff:fe71:ac74  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:71:ac:74  txqueuelen 1000  (Ethernet)
        RX packets 235  bytes 28303 (27.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 137  bytes 22067 (21.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 4  bytes 336 (336.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4  bytes 336 (336.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@master spark]# 

到此ens33起作用了,此时测试网络也可以通了。

 

以上是关于安装centos stream 8的笔记的主要内容,如果未能解决你的问题,请参考以下文章

centos-stream8 制作YUM镜像仓库

centos-stream8 制作YUM镜像仓库

centos-stream8 制作YUM镜像仓库

如何从CentOS Linux 8迁移到CentOS Stream 8

centos7下redis-2.8.13安装笔记

centOS 8 操作系统下载与安装