控制端安装
-
安装前准备
//安装相关依赖 yum -y install wget net-tools bridge-utils nfs-utils lrzsz gcc gcc-c++ make cmake libxml2-devel openssl-devel curl curl-devel unzip sudo ntp libaio-devel vim ncurses-devel autoconf automake zlib-devel python-devel epel-release //桥接网络 vi /etc/sysconfig/network-scripts/ifcfg-br0 DEVICE=br0 NAME=br0 TYPE=Bridge IPADDR=172.31.236.223 PREFIX=24 GATEWAY=172.31.236.1 DNS1=114.114.114.114 ONBOOT=yes BOOTPROTO=static NM_CONTROLLED=no vi /etc/sysconfig/network-scripts/ifcfg-em1 DEVICE=em1 BOOTPROTO=none NM_CONTROLLED=no ONBOOT=yes TYPE=Ethernet BRIDGE=br0 //关闭防火墙 关闭SELinux sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config setenforce 0 systemctl stop firewalld && systemctl disable firewalld //更新hosts cat << "EOT" > /etc/hosts 172.31.236.221 opennebula00 172.31.236.222 opennebula01 172.31.236.223 opennebula02 172.31.236.224 opennebula03 172.31.236.225 opennebula04 172.31.236.226 opennebula05 172.31.236.227 opennebula06 172.31.236.228 opennebula07 172.31.236.229 opennebula08 172.31.236.230 opennebula09 172.31.236.231 opennebula10 172.31.236.232 opennebula11 172.31.236.233 opennebula12 172.31.236.234 opennebula13 172.31.236.235 opennebula14 172.31.236.236 opennebula15 172.31.236.237 opennebula16 172.31.236.238 opennebula17 172.31.236.239 opennebula18 172.31.236.240 opennebula19 172.31.236.241 opennebula20 172.31.236.242 opennebula21 172.31.236.243 opennebula22 172.31.236.244 opennebula23 172.31.236.245 opennebula24 172.31.236.246 opennebula25 172.31.236.247 opennebula26 172.31.236.248 opennebula27 172.31.236.249 opennebula28 172.31.236.250 opennebula29 EOT //添加Opennebula仓库 cat << "EOT" > /etc/yum.repos.d/opennebula.repo [opennebula] name=OpenNebula Community Edition baseurl=https://downloads.opennebula.io/repo/5.12/CentOS/7/$basearch enabled=1 gpgkey=https://downloads.opennebula.io/repo/repo.key gpgcheck=1 repo_gpgcheck=1 EOT
//更新缓存
yum makecache fast -y
//设置时区
timedatectl set-timezone ‘Asia/Shanghai’
//同步时间
ntpdate cn.pool.ntp.org
安装Opennebula
yum install opennebula-server opennebula-sunstone opennebula-ruby opennebula-gate opennebula-flow -y
systemctl start opennebula && systemctl start opennebula-sunstone
systemctl enable opennebula && systemctl enable opennebula-sunstone
安装节点
- 准备工作参考控制端
- 安装节点包
yum install opennebula-node-kvm -y
systemctl restart libvirtd && systemctl enable libvirtd
配置免密登录
//修改oneadmin密码
passwd oneadmin
//切换到oneadmin用户下
su - oneadmin
// 创建known_hosts
ssh-keyscan <frontend> <node1> <node2> <node3> ... >> /var/lib/one/.ssh/known_hosts
//分发身份验证
ssh-copy-id -i /var/lib/one/.ssh/id_rsa.pub <node1>
scp -p /var/lib/one/.ssh/known_hosts <node1>:/var/lib/one/.ssh/
//验证连接
在控制端切换到 oneadmin 用户,ssh 任意节点,不需要密码即成功
默认的账号密码在 /var/lib/one/.one/one_auth
修改默认密码:
echo “oneadmin:mypasswd” > ~/.one/one_auth
创建集群-创建主机(主机名一定是物理机的主机名称)-创建虚拟网络(给集群分配IP)-APPS下载镜像模板-模板,虚拟机里修改对应的内存及CPU,总线及缓存修改成Virtio/WriteBack
- 验证安装
oneuser show
镜像制作
// 生成母盘镜像
qemu-img create -f qcow2 COS7.qcow2 200G
// 安装操作系统
/usr/libexec/qemu-kvm -m 32768 -boot d -cdrom CentOS-7-x86_64-DVD-1804.iso -drive file=COS7.qcow2 -nographic -vnc :0
// 添加tap0到桥接网络
brctl addif br0 tap0
brctl addif br0 eth0
// 编写tap0开机启动脚本
#!/bin/bash
if [ -n $1 ]; then
ip link set $1 up
brctl addif ${switch} $1
exit 0
else
echo "no interface!"
exit 1
fi
// 启动制作好的镜像
/usr/libexec/qemu-kvm -m 32768 -smp 2 -drive file=COS7.qcow2,if=virtio,index=1 -net nic -net tap,script=/tmp/qemu-ifup.sh -nographic -vnc :0
## 母盘镜像优化操作
// 关闭防火墙
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config && setenforce 0 && systemctl stop firewalld && systemctl disable firewalld
// 卸载现有的Docker
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
// 安装相关依赖
yum -y install wget net-tools nfs-utils lrzsz gcc gcc-c++ make cmake libxml2-devel openssl-devel curl curl-devel unzip sudo ntp libaio-devel vim ncurses-devel autoconf automake zlib-devel python-devel epel-release openssh-server
// 安装最新Docker和docker-compose
curl -sSL https://get.daocloud.io/docker | sh && yum install docker-compose -y && systemctl start docker && systemctl enable docker
// 配置Quicktron专用镜像