CentOS7搭建dev-stack环境

一,工具信息

获取工具
    从VirtualBox的官网下载当前最新的5.1版本。
    下载地址:https://www.virtualbox.org/wiki/Downloads
    下载完毕就可以直接在计算机上安装。

安装虚拟机:

CentOS7.3

配置信息:64G硬盘,4CPU,4G内存,两个网卡(NAT、桥接各一个)

系统安装好之后,修改网卡的显示名称为ethx:

1. 编辑ifcfg-eth0, 将文件中的ensx改为ethx。文件名和里面内容

2. vim /etc/default/grub   
    修改GRUB_CMDLINE_LINUX 行内容,在后面加上 net.ifnames=0 biosdevname=0,如下:   
    GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet net.ifnames=0 biosdevname=0"

3. 重新生成grub.cfg文件
   # grub2-mkconfig -o /boot/grub2/grub.cfg

4. reboot 重启后生效

5. 保证/etc/ssh/sshd_config中的PermitRootLogin参数为yes,这样能保证ssh访问,后续使用方便。

6. 保证关掉selinux。


二,安装工具

1. 确保网络畅通

ping www.baidu.com

2. 安装git

yum -y install git
3. 安装pip
yum -y install epel-release
yum -y install pip


4. 配置pip
在/root目录下,查看是否有.pip目录,若没有,创建该目录。
执行命令mkdir .pip,进入该目录,创建对应配置文件pip.conf。
在配置文件中填入以下内容(这里是我最后实际用的,如果你看到过之前那个,也是可以的):
[global]
timeout = 6000
index-url = http://pypi.douban.com/simple/
[install]
trusted-host = pypi.douban.com

 
5. 下载devstack,进入/home目录,执行以下命令,下载DevStack,并指定openstack版本:

如果要下载最新代码,使用:

git clone http://git.trystack.cn/openstack-dev/devstack.git -b master

如果要指定分支,使用:

git clone http://git.trystack.cn/openstack-dev/devstack.git -b stable/newton

6. 由于当前DevStack脚本已不支持直接使用root用户,所以我们要创建stack用户。
    执行命令cd /home/devstack/tools,进入脚本目录。
    执行命令./create-stack-user.sh,创建stack用户。

7. 执行命令passwd stack,给stack用户设置密码。具体操作步骤同root用户。

执行命令chown -R stack:stack /home/devstack,将对应目录及其下的文件更换用户组。
执行命令chmod 777 /dev/pts/0,以便后续su切换到别的用户,也可执行screen命令。

8. 执行命令su stack,切换至stack用户。
执行cd ~,进入到stack用户名下的目录,默认是/opt/stack。
像对root用户那样,添加pip的配置文件。参考当前面步骤。
在/opt/stack目录下新增.pip目录,里面配置pip.conf。


9. 修改local.conf
从/home/devstack/samples子目录中中拷贝一份local.conf文件到/home/devstack目录然后编辑。参见local.conf配置。

10.最后执行stack脚本(home/devstack下)。安装过程中,只遇到了下载的image名称后面带双引号。
修改function脚本,将image_fname写死:cirros-0.3.4-x86_64-disk.img 问题解决。


11. 成功日志。
This is your host IP address: 192.168.0.162
This is your host IPv6 address: ::1
Horizon is now available at http://192.168.0.162/dashboard
Keystone is serving at http://192.168.0.162/identity/
The default users are: admin and demo
The password: password


local.conf配置文件内容:

# Sample ``local.conf`` for user-configurable variables in ``stack.sh``

# NOTE: Copy this file to the root DevStack directory for it to work properly.

# ``local.conf`` is a user-maintained settings file that is sourced from ``stackrc``.
# This gives it the ability to override any variables set in ``stackrc``.
# Also, most of the settings in ``stack.sh`` are written to only be set if no
# value has already been set; this lets ``local.conf`` effectively override the
# default values.

# This is a collection of some of the settings we have found to be useful
# in our DevStack development environments. Additional settings are described
# in http://docs.openstack.org/developer/devstack/configuration.html#local-conf
# These should be considered as samples and are unsupported DevStack code.

# The ``localrc`` section replaces the old ``localrc`` configuration file.
# Note that if ``localrc`` is present it will be used in favor of this section.
[[local|localrc]]
GIT_BASE=http://git.trystack.cn
NOVNC_REPO=http://git.trystack.cn/kanaka/noVNC.git
SPICE_REPO=http://git.trystack.cn/git/spice/spice-html5.git

RECLONE=no

# Minimal Contents
# ----------------

# While ``stack.sh`` is happy to run without ``localrc``, devlife is better when
# there are a few minimal variables set:

# If the ``*_PASSWORD`` variables are not set here you will be prompted to enter
# values for them by ``stack.sh``and they will be added to ``local.conf``.

DATABASE_PASSWORD=password
ADMIN_PASSWORD=password
SERVICE_PASSWORD=password
SERVICE_TOKEN=password
RABBIT_PASSWORD=password

DOWNLOAD_DEFAULT_IMAGES=False
IMAGE_URLS=“http://images.trystack.cn/cirros/cirros-0.3.4-x86_64-disk.img”

# ``HOST_IP`` and ``HOST_IPV6`` should be set manually for best results if
# the NIC configuration of the host is unusual, i.e. ``eth1`` has the default
# route but ``eth0`` is the public interface.  They are auto-detected in
# ``stack.sh`` but often is indeterminate on later runs due to the IP moving
# from an Ethernet interface to a bridge on the host. Setting it here also
# makes it available for ``openrc`` to include when setting ``OS_AUTH_URL``.
# Neither is set by default.
HOST_IP=192.168.0.150
#HOST_IPV6=2001:db8::7


# Logging
# -------

# By default ``stack.sh`` output only goes to the terminal where it runs.  It can
# be configured to additionally log to a file by setting ``LOGFILE`` to the full
# path of the destination log file.  A timestamp will be appended to the given name.
LOGFILE=$DEST/logs/stack.sh.log

# Old log files are automatically removed after 7 days to keep things neat.  Change
# the number of days by setting ``LOGDAYS``.
LOGDAYS=2

# Nova logs will be colorized if ``SYSLOG`` is not set; turn this off by setting
# ``LOG_COLOR`` false.
#LOG_COLOR=False


# Using milestone-proposed branches
# ---------------------------------

# Uncomment these to grab the milestone-proposed branches from the
# repos:
#CINDER_BRANCH=milestone-proposed
#GLANCE_BRANCH=milestone-proposed
#HORIZON_BRANCH=milestone-proposed
#KEYSTONE_BRANCH=milestone-proposed
#KEYSTONECLIENT_BRANCH=milestone-proposed
#NOVA_BRANCH=milestone-proposed
#NOVACLIENT_BRANCH=milestone-proposed
#NEUTRON_BRANCH=milestone-proposed
#SWIFT_BRANCH=milestone-proposed

HORIZON_BRANCH=master
KEYSTONE_BRANCH=master
NOVA_BRANCH=master
NEUTRON_BRANCH=master
GLANCE_BRANCH=master
CINDER_BRANCH=master

# Using git versions of clients
# -----------------------------
# By default clients are installed from pip.  See LIBS_FROM_GIT in
# stackrc for details on getting clients from specific branches or
# revisions.  e.g.
# LIBS_FROM_GIT="python-ironicclient"
# IRONICCLIENT_BRANCH=refs/changes/44/2.../1

#keystone

KEYSTONE_TOKEN_FORMAT=UUID

#Heat

HEAT_BRANCH=master
enable_service h-eng h-api h-api-cfn h-api-cw

# Swift
# -----

###SWIFT_BRANCH=master
###ENABLED_SERVICES+=,s-proxy,s-object,s-Container,s-account

# Swift is now used as the back-end for the S3-like object store. Setting the
# hash value is required and you will be prompted for it if Swift is enabled
# so just set it to something already:
###SWIFT_HASH=66a3d6b56c1f479c8b4e70ab5c2000f5

# For development purposes the default of 3 replicas is usually not required.
# Set this to 1 to save some resources:
###SWIFT_REPLICAS=1

# The data for Swift is stored by default in (``$DEST/data/swift``),
# or (``$DATA_DIR/swift``) if ``DATA_DIR`` has been set, and can be
# moved by setting ``SWIFT_DATA_DIR``. The directory will be created
# if it does not exist.
###SWIFT_DATA_DIR=$DEST/data

#Enabling Neutron (network) Service

disable_service n-net
enable_service q-svc
enable_service q-agt
enable_service q-dhcp
enable_service q-l3
enable_service q-meta
enable_service q-metering
enable_service neutron




问题记录
1. 虚拟机重启后,如何启动openstack的相关服务?

 screen -c stack-screenrc

2. 日志路径:根据local.conf找到logs目录(find / -name stack.sh.log)。所有日志都在那里

3. 安装ironic时提示ovs错误,需要手动启动ovs服务

systemctl start openvswitch

systemctl enable openvswitch

4. 安装好的虚拟机重启后lv丢失的问题:
[root@localhost ~]# losetup --list
NAME       SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE
/dev/loop0         0      0         0  0 /opt/stack/data/stack-volumes-default-backing-file
/dev/loop1         0      0         0  0 /opt/stack/data/stack-volumes-lvmdriver-1-backing-file
[root@localhost ~]# losetup /dev/loop0 /opt/stack/data/stack-volumes-default-backing-file
[root@localhost ~]# losetup /dev/loop1 /opt/stack/data/stack-volumes-lvmdriver-1-backing-file

5.ironic的dev搭建时,遇到这样一个问题:gitclone或者yum安装时,都没有等待,直接向下,导致后续报错。
因为locla.conf中有个OFFLINE设置为TRUE了。改成下面形式。
#OFFLINE=True
RECLONE=True

6.ironic的dev搭建时,需要注意的地方:
tempest需要手动git下来;
需要手动安装qemu;
遇到过一次unstack时,没有彻底清理。导致再次stack的时候,网桥br-node-0还存在,报错网桥br-node-0不能创建。

<think>我们正在解决一个具体问题:在VMware上基于CentOS7搭建Linux0.11环境。Linux0.11是一个非常古老的内核版本,因此我们需要一个兼容的编译环境。通常,我们会选择较旧的Linux发行版(如RedHat9.0)来编译,但用户要求使用CentOS7CentOS7相对较新,因此我们需要做一些调整。参考引用[2]中提到,在VMware中安装RedHat9.0并制作Docker镜像,但用户希望用CentOS7。我们可以尝试在CentOS7上构建一个类似RedHat9.0的编译环境。步骤概述:1.准备VMware虚拟机,安装CentOS7。2.安装必要的开发工具和库。3.获取Linux0.11源码。4.修改Makefile或源码以适应CentOS7环境(因为gcc版本过高,可能需要降级或调整编译选项)。5.编译Linux0.11内核。详细步骤:1.**创建VMware虚拟机并安装CentOS7**-下载CentOS7镜像(例如从阿里云镜像站:https://mirrors.aliyun.com/centos/7/isos/x86_64/)-在VMware中创建新的虚拟机,选择CentOS7镜像,完成安装。建议最小化安装,然后安装开发工具。2.**安装基础开发环境**-安装必要的软件包:```bashsudoyumgroupinstall"DevelopmentTools"sudoyuminstallncurses-develbisonflexelfutils-libelf-devel```-由于Linux0.11需要较老的编译器,我们可能需要安装较旧版本的gcc。但CentOS7默认的gcc版本是4.8.5,已经比Linux0.11所需的版本(如gcc2.x)高很多。因此,我们需要调整编译选项或使用兼容模式。3.**获取Linux0.11源码**-可以从官方或镜像站点下载,例如:```bashwgethttps://mirrors.edge.kernel.org/pub/linux/kernel/Historic/linux-0.11.tar.gztarzxvflinux-0.11.tar.gzcdlinux-0.11```4.**调整编译环境**-由于gcc版本过高,直接编译会报错。我们可以尝试修改Makefile来降低警告和错误级别,或者使用特定的编译选项。-常见的做法是修改Makefile中的CFLAGS,添加`-fno-stack-protector-m32-fno-builtin`等选项,以规避高版本gcc的安全特性。-另外,可能需要修改源码中的一些头文件引用和函数声明。5.**编译**-在源码目录下执行:```bashmake```-如果遇到错误,根据错误信息进行修改。常见的错误包括:-缺少头文件:可以创建对应的符号链接或从其他位置复制。-函数未声明:在源码中添加函数声明。-类型不匹配:修改源码中的类型。6.**运行**-编译成功后,会生成一个名为`Image`的内核映像文件。-我们可以使用Bochs或QEMU来运行这个内核。在CentOS7安装QEMU:```bashsudoyuminstallqemu```-然后使用QEMU运行:```bashqemu-system-i386-kernelarch/i386/boot/Image```由于在较新的系统上编译旧内核存在挑战,如果遇到难以解决的问题,也可以考虑在CentOS7虚拟机中再创建一个Docker容器,容器内使用较旧的环境(如引用[2]中提到的RedHat9.0的Docker镜像)进行编译。另一种方法是使用现成的编译环境,例如从网上下载已经配置好的Docker镜像(如引用[2]中提到的`yy20190811/rh9:1.00`),然后在CentOS7上运行Docker容器进行编译。因此,我们提供两种方案:方案一:直接在CentOS7上编译(可能需要较多调整)方案二:在CentOS7安装Docker,然后使用旧版编译环境的Docker镜像这里我们先给出方案一的步骤,如果方案一遇到困难再考虑方案二。由于时间有限,我们无法预测所有错误,但以下是一个常见的调整示例:在编译Linux0.11时,可能会遇到`asm/segment.h`文件找不到的问题。这是因为高版本内核的头文件结构发生了变化。我们可以尝试:```bashmkdirasmln-s/usr/include/asm-genericasm```另一个常见错误是`gcc:error:unrecognizedcommandlineoption‘-fno-stack-protector’`,这是因为旧版gcc没有这个选项,但在CentOS7的gcc4.8.5中是有这个选项的,所以这个错误可能不会出现。如果出现,可以去掉这个选项。考虑到上述步骤的复杂性,对于初学者,推荐使用Docker方案(方案二)可能更简单。**方案二:使用Docker编译**1.在CentOS7安装Docker:```bashsudoyuminstall-yyum-utilssudoyum-config-manager--add-repohttps://download.docker.com/linux/centos/docker-ce.reposudoyuminstalldocker-cedocker-ce-clicontainerd.iosudosystemctlstartdockersudosystemctlenabledocker```2.拉取旧版编译环境的Docker镜像(如引用[2]中提到的):```bashdockerpullyy20190811/rh9:1.00```3.运行容器并挂载源码目录:```bashdockerrun-it-v/path/to/linux-0.11:/linux-0.11yy20190811/rh9:1.00/bin/bash```然后进入容器内的`/linux-0.11`目录进行编译。4.在容器内编译:```bashcd/linux-0.11make```这样,编译生成的内核映像文件会留在宿主机的`/path/to/linux-0.11`目录中。总结:用户可以根据自己的情况选择方案。如果希望直接在CentOS7上编译,需要做好面对编译错误的准备并进行调整;如果希望快速搭建编译环境,推荐使用Docker方案。注意:在VMware虚拟机中运行CentOS7时,请确保网络连接正常,以便下载软件包和Docker镜像。最后,关于防火墙配置(参考引用[3]),在实验环境中可以关闭防火墙,但在生产环境中需谨慎:```bashsudosystemctlstopfirewalldsudosystemctldisablefirewalld```但请注意,关闭防火墙会降低系统安全性,仅在实验环境使用。希望这些步骤能帮助用户成功搭建Linux0.11环境。</think>### 如何在 VMware 上基于 CentOS 7 搭建 Linux 0.11 环境 #### 步骤 1:准备基础环境 1. **安装 VMware 和 CentOS 7** - 下载 CentOS 7 镜像(推荐阿里云镜像站): ```bash https://mirrors.aliyun.com/centos/7/isos/x86_64/ ``` - 在 VMware 中创建新虚拟机: - 选择 "典型安装" → 加载 CentOS 7 ISO - 磁盘分配 ≥ 20GB,内存 ≥ 2GB - 网络模式选择 NAT 或桥接 2. **初始系统配置** ```bash # 关闭防火墙(实验环境) sudo systemctl stop firewalld sudo systemctl disable firewalld # 禁用 SELinux sudo sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config sudo setenforce 0 # 更新系统 sudo yum update -y ``` #### 步骤 2:安装编译依赖 ```bash # 安装开发工具链 sudo yum groupinstall "Development Tools" -y # 安装必要依赖 sudo yum install -y ncurses-devel bison flex elfutils-libelf-devel glibc-devel.i686 gcc-c++ # 验证 GCC 版本(需 ≥ 4.8) gcc --version ``` #### 步骤 3:获取 Linux 0.11 源码 ```bash # 下载源码包 wget https://mirrors.edge.kernel.org/pub/linux/kernel/Historic/linux-0.11.tar.gz # 解压并进入目录 tar zxvf linux-0.11.tar.gz cd linux-0.11 ``` #### 步骤 4:修复兼容性问题 由于 CentOS 7 的 GCC 较新,需修改源码: 1. **编辑 `Makefile`** ```makefile # 在 CFLAGS 中添加兼容参数 CFLAGS = -m32 -fno-stack-protector -fno-builtin -fno-PIC ``` 2. **修改头文件** ```bash # 创建兼容头文件链接 sudo ln -s /usr/include/asm-generic /usr/include/asm ``` #### 步骤 5:编译内核 ```bash # 清理旧编译文件 make clean # 开始编译 make ``` - 编译成功后生成 `Image` 文件(位于 `arch/i386/boot/`) #### 步骤 6:安装模拟器运行 ```bash # 安装 QEMU 模拟器 sudo yum install -y qemu-system-i386 # 启动 Linux 0.11 qemu-system-i386 -kernel arch/i386/boot/Image -append "root=/dev/sda" ``` #### 验证结果 - 成功启动后显示经典提示符: ```bash Welcome to Linux 0.11 / $ ``` - 可执行基本命令:`ls`, `cat /etc/issue` 等 --- ### 常见问题解决 1. **编译错误:`asm/segment.h` 缺失** ```bash # 手动创建头文件链接 mkdir -p include/asm ln -s /usr/include/asm-generic include/asm/segment.h ``` 2. **QEMU 启动黑屏** ```bash # 添加 console 参数 qemu-system-i386 -kernel Image -append "console=ttyS0 root=/dev/sda" ``` 3. **32 位支持缺失** ```bash # 安装多库支持 sudo yum install -y glibc-devel.i686 libgcc.i686 ``` --- ### 相关问题 1. 如何在 Linux 0.11 环境中添加自定义内核模块? 2. 有哪些工具可以调试 Linux 0.11 内核代码? 3. 如何将编译好的 Linux 0.11 内核部署到物理机? > 提示:建议在虚拟机中定期创建快照,避免环境损坏[^3]。CentOS 7 的软件包管理比古老系统更便捷,但需注意 32/64 位兼容性问题[^2]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值