更新时间:2022-05-12 GMT+08:00
分享

配置oVirt编译环境

配置网络环境

本文档安装部署oVirt采用源码编译安装部署,编译过程中需要访问CentOS官方提供的repo源和maven中心仓,所以编译安装机器需要能够访问互联网。

通过curl命令验证网络:

1
curl --connect-timeout 5 www.huawei.com

如果不能正常curl成功,需要配置网络和网络代理。

配置curl

  1. 创建curl配置文件。

    1
    touch ~/.curlrc
    

  2. 在文件中添加如下内容:

    1
    2
    echo "# 允许不使用证书到SSL站点" >> ~/.curlrc
    echo "insecure" >> ~/.curlrc
    

配置wget

  1. 创建wget配置文件。

    1
    touch ~/.wgetrc
    

  2. 在文件中添加如下内容:

    1
    2
    echo "# 不检查服务端证书" >> ~/.wgetrc
    echo "check_certificate = off" >> ~/.wgetrc
    

配置git

  1. 创建git配置文件。

    1
    touch ~/.gitconfig
    

  2. 然后在文件中添加如下内容:

    1
    2
    echo "[http]" >> ~/.gitconfig
    echo "sslVerify = false" >> ~/.gitconfig
    

配置DNS

“/etc/resolve.conf”文件中添加如下内容:

1
2
nameserver <DNS服务器的IP地址>
search <定义域名的搜索列表>

需要根据实际情况配置DNS server和域名的搜索列表。

安装Maven

  1. 安装Maven。

    1
    yum install maven -y
    

  2. 配置maven代理,在“/etc/maven/settings.xml”文件中添加如下配置信息。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    <proxies>
    <proxy>
    <id>optional</id>
    <active>true</active>
    <protocol>http</protocol>
    <host>$proxyHost</host>
    <port>$proxyPort</port>
    <username>$account</username>
    <password>$password</password>
    <nonProxyHosts>localhost</nonProxyHosts>
    </proxy>
    </proxies>
    

  • 部分模块采用mvn源码编译安装的方式,需要通过代理访问Maven中心仓,此处提前配置。其中$proxyHost、$proxyPort、$account、$password配置信息根据实际情况替换。
  • 注意$password密码当中有特殊字符可直接使用,不需要转义。
  • 如果使用的代理为cntlm类不需要账号密码类代理,仅需要配置$proxyHost和$proxyPort。为防止报Not Authorized by proxy错误,需要删除Maven配置文件 “/etc/maven/settings.xml”中的如下两行:
    1
    2
    <username>$account</username>
    <password>$password</password>
    

安装基本工具

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
yum install rpm-build* -y
yum install git -y
yum install autoconf automake libtool -y
yum install python3-devel -y
yum install createrepo_c.aarch64 -y
yum install libdnf -y
yum install libmodulemd.aarch64 -y
yum install python3-pip-wheel.noarch -y
yum install make cmake -y
yum install gcc-c++ -y
yum update nss -y
yum install yum-utils -y

编译安装QEMU

oVirt 4.x版本依赖高版本的QEMU和libvirt,由于QEMU目前最新版本4.2.0在ARM服务器上存在迁移缺陷,所以需要打上patch并重新编译安装。

  1. 安装依赖包。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    yum install http://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm -y
    sed -i "s/enabled=0/enabled=1/g" /etc/yum.repos.d/CentOS-PowerTools.repo
    wget https://vault.centos.org/8.1.1911/AppStream/aarch64/os/Packages/perl-Test-Harness-3.42-1.el8.noarch.rpm
    rpm -ivh perl-Test-Harness-3.42-1.el8.noarch.rpm
    yum install bluez-libs-devel brlapi-devel check-devel device-mapper-multipath-devel libaio-devel libfdt-devel -y
    yum install libgcrypt-devel libpng-devel libseccomp-devel libusbx-devel lzo-devel pciutils-devel  pixman-devel -y
    yum install python3-sphinx rdma-core-devel snappy-devel texinfo libxkbcommon-devel spice-protocol -y
    yum install spice-server-devel virglrenderer-devel   cyrus-sasl-devel gnutls-devel libattr-devel -y
    yum install libcap-ng-devel libcurl-devel libiscsi-devel librados-devel librbd-devel libssh-devel -y
    yum install libuuid-devel ncurses-devel numactl-devel python3-devel systemd-devel -y
    yum install systemtap-sdt-devel edk2-aarch64 -y
    

  2. 下载patch。

    1
    2
    3
    4
    5
    mkdir -p /opt/ovirt/
    cd /opt/ovirt/
    git clone https://gitee.com/src-openeuler/qemu.git
    cd qemu
    git checkout -b openEuler-20.03-LTS origin/openEuler-20.03-LTS
    

  3. 下载安装QEMU-KVM RPM包。

    1
    2
    3
    cd /opt/ovirt/
    wget https://cbs.centos.org/kojifiles/packages/qemu-kvm/4.2.0/19.el8/src/qemu-kvm-4.2.0-19.el8.src.rpm
    rpm -ivh qemu-kvm-4.2.0-19.el8.src.rpm
    

  4. 修改“qemu-kvm.spec”文件。

    1
    2
    3
    cd /root/rpmbuild/SPECS/
    sed -i 's/have_spice   0/have_spice   1/g' qemu-kvm.spec
    sed -i 's/Patch0019/#Patch0019/g' qemu-kvm.spec
    

    在qemu-kvm.spec文件中添加如下判断:

  5. 打patch。

    1
    2
    rpmbuild -bp qemu-kvm.spec
    cd /root/rpmbuild/BUILD/qemu-4.2.0/
    

    以下patch命令由于qemu版本不同可能会导致命令失败,根据失败提示的rej文件手动打入patch即可。

    1
    2
    3
    4
    cat /opt/ovirt/qemu/cpu-add-Kunpeng-920-cpu-support.patch | /usr/bin/patch -p1 --fuzz=0 --no-backup-if-mismatch
    cat /opt/ovirt/qemu/cpu-parse-feature-to-avoid-failure.patch | /usr/bin/patch -p1 --fuzz=0 --no-backup-if-mismatch
    cat /opt/ovirt/qemu/cpu-add-Cortex-A72-processor-kvm-target-support.patch | /usr/bin/patch -p1 --fuzz=0 --no-backup-if-mismatch
    cat /opt/ovirt/qemu/async-use-explicit-memory-barriers.patch | /usr/bin/patch -p1 --fuzz=0 --no-backup-if-mismatch
    

  6. 编译安装QEMU。

    1
    2
    3
    4
    cd /root/rpmbuild/SPECS
    rpmbuild -bb --noprep --nocheck qemu-kvm.spec
    cd /root/rpmbuild/RPMS/aarch64
    yum localinstall qemu* -y
    

    若环境上本身存在qemu相关包,可能会提示冲突,可使用rpm -e卸载冲突包后再安装

编译安装libvirt

  1. 安装依赖。

    1
    yum install audit-libs-devel cyrus-sasl-devel dbus-devel device-mapper-devel glusterfs-api-devel glusterfs-devel gnutls-devel libacl-devel libattr-devel libblkid-devel libcap-ng-devel libiscsi-devel libnl3-devel libpcap-devel libpciaccess-devel librados-devel librbd-devel libselinux-devel libssh-devel libssh2-devel libtasn1-devel libtirpc-devel ncurses-devel netcf-devel numactl-devel parted-devel python3-docutils readline-devel rpcgen sanlock-devel systemd-devel systemtap-sdt-devel wireshark-devel xfsprogs-devel  augeas dnsmasq libxml2-devel numad radvd scrub yajl-devel gnutls-utils iproute-tc lzop systemd-container glusterfs glusterfs-cli sanlock -y
    

  2. 下载编译libvirt。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    cd /opt/ovirt/
    git clone https://gitee.com/src-openeuler/libvirt.git
    cd libvirt
    git checkout -b openEuler-20.03-LTS origin/openEuler-20.03-LTS
    cp * /root/rpmbuild/SOURCES/
    rm -rf /root/rpmbuild/RPMS/aarch64/libvirt*
    cd /root/rpmbuild/SOURCES/
    sed -i 's/Requires: qemu//g' libvirt.spec
    sed -i 's/make %{?_smp_mflags} V=1/make -j 4 V=1/g' libvirt.spec
    rpmbuild -bb libvirt.spec
    

  3. 安装libvirt。

    1
    2
    3
    4
    cd /root/rpmbuild/RPMS/aarch64
    rpm -e python3-libvirt libvirt-libs pcp-pmda-libvirt pcp-testsuite
    rpm -ivh libvirt-*rpm
    yum install python3-libvirt libvirt-libs pcp-pmda-libvirt pcp-testsuite -y
    

  4. 启动。

    1
    systemctl start libvirtd
    

安装repo2mudule工具

  1. 切换到指定安装目录。

    1
    2
    3
    mkdir -p /opt/ovirt/
    cd /opt/ovirt/
    rm -rf modulemd-tools
    

  2. 下载并安装repo2module工具包。

    1
    2
    3
    4
    5
    git clone https://github.com/rpm-software-management/modulemd-tools.git
    cd modulemd-tools/repo2module
    git reset --hard f7a64149b33564f4aea0641dd240dcce34857032
    cp -r /usr/lib/python3.6 /usr/local/lib/
    python3 setup.py install
    

安装python createrepo_c module

  1. 安装依赖包。

    1
    2
    3
    sed -i 's/enabled=0/enabled=1/g' /etc/yum.repos.d/CentOS-PowerTools.repo
    yum install bzip2-devel doxygen drpm-devel file-devel glib2-devel libcurl-devel libxml2-devel openssl-devel python3-nose python3-sphinx rpm-devel sqlite-devel xz-devel zlib-devel -y
    yum install createrepo_c-libs.aarch64 createrepo_c-devel.aarch64 python3-createrepo_c.aarch64 createrepo_c.aarch64 -y
    

  2. 下载createrepo_c源码包,并解压至“/opt/ovirt”目录。

    1
    2
    3
    cd /opt/ovirt/
    wget https://files.pythonhosted.org/packages/c9/ed/77d4f3661fb8f23a73765aa0dbff074ecb566a00e0d5a32a5d248e62952b/createrepo_c-0.16.0.tar.gz
    tar -xvf createrepo_c-0.16.0.tar.gz
    

  3. 将createrepo_c-0.16.0.tar.gz拷贝到“/root/rpmbuild/SOURCES/”目录。

    1
    2
    3
    rm -rf /root/rpmbuild/RPMS/aarch64/*
    mkdir -p /root/rpmbuild/SOURCES/
    cp createrepo_c-0.16.0.tar.gz /root/rpmbuild/SOURCES/
    

  4. 编译生成并安装RPM包。

    1
    2
    3
    4
    cd createrepo_c-0.16.0/
    rpmbuild -bb createrepo_c.spec  --nocheck
    cd /root/rpmbuild/RPMS/aarch64/
    yum install *rpm -y
    

安装oVirt源

  1. “/etc/yum.conf”文件中添加“sslverify=false”。

  2. 安装oVirt源。

    1
    yum install http://resources.ovirt.org/pub/yum-repo/ovirt-release44.rpm
    

  3. 修改“ovirt-4.4.repo”文件,将文件中“https”更改为“http”。

    1
    sed -i "s/https/http/" /etc/yum.repos.d/ovirt-4.4.repo
    

安装CentOS-OpsTools源

1
yum install centos-release-opstools.noarch

添加CentOS 8/8.1 oVirt ARM源

  1. 创建ovirt-4.4-arm-hw.repo文件,并配置oVirt ARM源。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    touch /etc/yum.repos.d/ovirt-4.4-arm-hw.repo
    echo "
    [CentOS-8.1-Ovirt]
    name=centos-8.1-ovirt
    baseurl=http://mirrors.huaweicloud.com/centos-vault/8.1.1911/virt/aarch64/ovirt-44/
    enabled=1
    gpgcheck=0
    priority=1
    
    [CentOS-8-Ovirt]
    name=centos-8-ovirt
    baseurl=http://mirrors.huaweicloud.com/centos/8-stream/virt/aarch64/ovirt-44/
    enabled=1
    gpgcheck=0
    priority=2" >> /etc/yum.repos.d/ovirt-4.4-arm-hw.repo
    

  2. 更新yum。

    1
    2
    yum clean all
    yum makecache
    

编译安装ovirt-engine-sdk4

  1. 下载安装python-ovirt-engine-sdk4-4.4.4-1.el8.src.rpm包。

    1
    2
    3
    cd /opt/ovirt
    wget https://resources.ovirt.org/pub/ovirt-4.4/rpm/el8/SRPMS/python-ovirt-engine-sdk4-4.4.4-1.el8.src.rpm
    rpmbuild --rebuild --clean python-ovirt-engine-sdk4-4.4.4-1.el8.src.rpm
    

  2. 创建ovirt-host-repo和ovirt-engine-repo文件夹。

    1
    2
    mkdir -p /opt/ovirt/ovirt-host-repo/
    mkdir -p /opt/ovirt/ovirt-engine-repo/
    

  3. “/root/rpmbuild/RPMS/aarch64/”下*ovirt-engine-sdk相关rpm包分别拷贝至“ovirt-host-repo”“ovirt-engine-repo”目录下。

    1
    2
    cp /root/rpmbuild/RPMS/aarch64/*ovirt-engine-sdk*rpm /opt/ovirt/ovirt-host-repo/
    cp /root/rpmbuild/RPMS/aarch64/*ovirt-engine-sdk*rpm /opt/ovirt/ovirt-engine-repo/
    

  4. 创建ovirt-engine-repo yum源。

    1
    2
    3
    cd /opt/ovirt/ovirt-engine-repo/
    rm -rf repodata
    createrepo_c .
    

  5. 创建ovirt-host-repo yum源。

    1
    2
    3
    cd /opt/ovirt/ovirt-host-repo/
    rm -rf repodata
    createrepo_c .
    

  6. 新建ovirt-engine-4.4-local.repo文件,并添加本地源配置。

    1
    2
    3
    4
    5
    6
    7
    8
    touch /etc/yum.repos.d/ovirt-engine-4.4-local.repo
    cat > /etc/yum.repos.d/ovirt-engine-4.4-local.repo <<EOS
    [ovirt-engine-local]
    name=ovirt engine local
    baseurl=file:///opt/ovirt/ovirt-engine-repo/
    enabled=1
    gpgcheck=0
    EOS
    

  7. 更新yum。

    1
    2
    yum clean all
    yum makecache
    

分享:

    相关文档

    相关产品

close