首先得说明一点,此篇文章只适合于公司没有空余的服务器给你搭建环境,而你自己又想自己试试搭建cs环境,本人使用的笔记本是i7+16g内存,如果你的电脑低于8g的内存,那就洗洗睡吧,不用看下面的文章了。
一 workstation设置
1.1编辑->虚拟网络编辑器
记住net起始ip是192.168.40.0,网关是192.168.40.2,子网掩码是255.255.255.0
1.2安装centos6.5,默认安装即可,我自己management机器使用了20g的硬盘,kvm机器使用了100g的硬盘
1.3安装好系统之后,分别进入两个虚拟机,将ip修改
Managent 虚拟机
DEVICE="eth0"
BOOTPROTO="static"
ONBOOT="yes"
TYPE="Ethernet"
IPADDR=192.168.40.3
NETMASK=255.255.255.0
GATEWAY=192.168.40.2
Kvm虚拟机
DEVICE="eth0"
BOOTPROTO="static"
ONBOOT="yes"
TYPE="Ethernet"
IPADDR=192.168.40.4
NETMASK=255.255.255.0
GATEWAY=192.168.40.2
二 管理节点虚拟机配置
1.1 上传cs安装包至management虚机上,解压
1.2 配置yum源
1.2.1 备份yum源
mv /etc/yum.repos.d/* /root/
1.2.2 编辑yum源 文件
vi /etc/yum.repos.d/media.repo
输入以下内容
[media]
name=media
baseurl=file:///media
gpgcheck=0
enabled=1
1.2.3 挂载centos光盘
在management虚机中执行一下命令,进行挂载
[root@localhost yum.repos.d]# mount /dev/cdrom /media/
mount: you must specify the filesystem type
[root@localhost yum.repos.d]# mount /dev/cdrom /media/
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@localhost yum.repos.d]# yum clean all
Loaded plugins: fastestmirror, refresh-packagekit, security
Cleaning repos: media
Cleaning up Everything
1.2.4 解压cs安装包
tar -xvf CloudStack-non-oss-4.0.0-1.tar.bz2
1.2.5 安装管理节点
[root@localhost ~]# cd CloudStack-non-oss-4.0.0-1
[root@localhost CloudStack-non-oss-4.0.0-1]# ./install.sh
Setting up the temporary repository...
Cleaning Yum cache...
Loaded plugins: fastestmirror, refresh-packagekit, security
Cleaning repos: cloud-temp media
0 metadata files removed
Welcome to the Apache CloudStack (Incubating) Installer. What would you like to do?
M) Install the Management Server
A) Install the Agent
B) Install BareMetal Agent
S) Install the Usage Monitor
D) Install the database server
Q) Quit
> m
Tip:如果这里出现问题,请核对上面的yum源是否配置好,和系统版本是否正确。
1.2.6修改hosts
Vi /etc/hosts
在末尾加上下面这句话,192.168.40.3是management机器ip地址
192.168.40.3 srvr1.cloud.priv
重启机器
然后输入 hostname --fqdn
如果出现 srvr1.cloud.priv说明这步操作成功,否则自己百多或者检查这个步骤把
1.2.7修改selinux
vi /etc/selinux/config
修改内容中的SELINUX
SELINUX=permissive
重启机器
1.2.8 执行下面命令
# chkconfig rpcbind on
# chkconfig nfs on
# service rpcbind start
#service nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
1.2.9 安装数据库
[root@localhost ~]# cd CloudStack-non-oss-4.0.0-1
[root@localhost CloudStack-non-oss-4.0.0-1]# ./install.sh
Setting up the temporary repository...
Cleaning Yum cache...
Loaded plugins: fastestmirror, refresh-packagekit, security
Cleaning repos: cloud-temp media
2 metadata files removed
Welcome to the Apache CloudStack (Incubating) Installer. What would you like to do?
M) Install the Management Server
A) Install the Agent
B) Install BareMetal Agent
S) Install the Usage Monitor
D) Install the database server
Q) Quit
> d
1.2.10 初始化数据库
[root@srvr1 ~]# cloudstack-setup-databases cloud:@localhost --deploy-as=root
1.2.11 启动管理节点
[root@srvr1 ~]# cloudstack-setup-management
Starting to configure CloudStack Management Server:
Configure sudoers ... [OK]
Configure Firewall ... [OK]
Configure CloudStack Management Server ...[OK]
CloudStack Management Server setup is Done!
1.2.12关闭防火墙
[root@srvr1 ~]# /etc/init.d/iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
[root@srvr1 ~]# chkconfig iptables on
1.2.13 在windows机器上访问http://192.168.40.3:8080/client/
1.2.14 创建二级存储
mkdir -p /Secondary01
vi /etc/exports
添加一下内容
/Secondary01 *(rw,async,no_root_squash)
重启服务
[root@srvr1 ~]# /etc/init.d/rpcbind restart
Stopping rpcbind: [ OK ]
Starting rpcbind: [ OK ]
[root@srvr1 ~]# /etc/init.d/nfs restart
Shutting down NFS daemon: [ OK ]
Shutting down NFS mountd: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down RPC idmapd: [ OK ]
Starting NFS services: exportfs: Failed to stat /Secondary01: No such file or directory
[ OK ]
Starting NFS quotas: [ OK ]
Starting NFS mountd: [ OK ]
Starting NFS daemon: [ OK ]
Starting RPC idmapd: [ OK ]
检测一下挂载
[root@srvr1 ~]# showmount -e 192.168.40.3
Export list for 192.168.40.3:
/Secondary01 *
1.2.15准备文件服务器
[root@srvr1 Secondary01]# yum install httpd
重启服务
[root@srvr1 Secondary01]# /etc/init.d/httpd restart
在window机器上访问http://192.168.40.3/
出现上面的页面则说明文件服务器启动成功
1.2.16部署系统虚拟机模版
将系统虚拟机模版systemvm64template-2014-06-23-master-kvm.qcow2上传至 management虚拟机中的/var/www/html
[root@srvr1 Secondary01]# mount 192.168.40.3:/Secondary01 /mnt/
部署虚拟机模版
/usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt -m /mnt/ -u http://192.168.40.3/systemvm64template-2014-06-23-master-kvm.qcow2.bz2 -h kvm -F
等待成功之后执行下面命令进行卸载/mnt卷
umount /mnt/
三 kvm主机设置
1.1在workstation中,选择kvm机器,设置中按照下图,勾选虚拟化inter vt
1.2.配置yum源,这里就不多叙述了,和management机器上的一致
1.3修改hosts文件
Vi /etc/hosts
在末尾加上下面这句话,192.168.40.3是management机器ip地址
192.168.40.4 node1.cloud.node1
重启机器
然后输入 hostname --fqdn
如果出现 srvr1.cloud.priv说明这步操作成功,否则自己百多或者检查这个步骤把
1.4关闭selinux
vi /etc/selinux/config
修改内容中的SELINUX
SELINUX=permissive
重启机器
1.5 删除预先安装好的kvm包
yum erase qemu-kvm
1.6安装createrepo包
yum install createrepo
由于自己打包的cs包安装kvm代理的时候,centos6.5中会缺少人rpm包,所以要执行下面步骤
# mkdir -p /root/kvmrepo
将所需的rpm包和cs安装包上传值kvm虚机中
Rpm包上传至目录/root/kvmrepo
Cs安装包上传至/root/
# createrepo /root/kvmrepo/
[root@localhost yum.repos.d]# vi media.repo
[media]
name=media
baseurl=file:///media
enabled=1
gpgcheck=0
[kvmrepo]
name=kvmrepo
baseurl=file:///root/kvmrepo
enabled=1
gpgcheck=0
# yum clean all
# yum install jakarta-commons-daemon-jsvc
1.7解压cs安装包,安装代理
[root@localhost kvmrepo]# cd /root/
[root@localhost ~]# ls
anaconda-ks.cfg CloudStack-non-oss-4.0.0-1.tar.bz2 Desktop Documents Downloads install.log install.log.syslog kvmrepo Music Pictures Public Templates Videos
[root@localhost ~]# tar -xvf CloudStack-non-oss-4.0.0-1.tar.bz2
[root@localhost ~]# cd CloudStack-non-oss-4.0.0-1
[root@localhost CloudStack-non-oss-4.0.0-1]# ./install.sh
Setting up the temporary repository...
Cleaning Yum cache...
Loaded plugins: fastestmirror, refresh-packagekit, security
Cleaning repos: cloud-temp kvmrepo media
2 metadata files removed
Welcome to the Apache CloudStack (Incubating) Installer. What would you like to do?
M) Install the Management Server
A) Install the Agent
B) Install BareMetal Agent
S) Install the Usage Monitor
D) Install the database server
Q) Quit
> a
1.8配置nfs
[root@localhost CloudStack-non-oss-4.0.0-1]# chkconfig rpcbind on
[root@localhost CloudStack-non-oss-4.0.0-1]# chkconfig nfs on
[root@localhost CloudStack-non-oss-4.0.0-1]# service rpcbind start
Starting rpcbind: [ OK ]
[root@localhost CloudStack-non-oss-4.0.0-1]# service nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS mountd: [ OK ]
Starting NFS daemon: [ OK ]
Starting RPC idmapd: [ OK ]
1.9安装qemu-kvm
yum install qemu-kvm
yum install libvirt
如果出现错误,请将yum源中的kvmrepo部分删除,然后yum clean all执行
1.10 修改配置文件
vi /etc/libvirt/qemu.conf
取消vnc_listen = "0.0.0.0"中的注释#
1.11修改配置文件/etc/libvirt/libvirtd.conf
listen_tls = 0
listen_tcp = 1
tcp_port = "16059"
auth_tcp = "none"
mdns_adv = 0
1.12修改配置文件/etc/sysconfig/libvirtd 取消下面的注释
#LIBVIRTD_ARGS="--listen"
1.13重启libvirt服务
# /etc/init.d/libvirtd restart
1.14测试一下安装情况
# lsmod | grep kvm
kvm_intel 55496 0
kvm 337772 1 kvm_intel
三 建zone
1.1启动管理节点
在management管理节点机器上执行
# /etc/init.d/cloudstack-management start
1.2 在windows机器上创建zone,访问http://192.168.40.3:8080/client/
帐号和密码 admin/password
1.3选择基础架构--区域--查看全部--添加区域
1.4选择基本,点击下一步,出现下图
1.5 按照下面两幅图输入信息
1.6 点击下一步,出现下图
1.7 点击下一步,出现下图,然后按照下图输入信息
1.8点击下一步,出现下图,输入途中信息
1.9点击下一步,出现下图,输入下图中的信息
1.10点击下一步,出现下图,输入下图中的信息
1.11点击下一步,出现下图,输入下图中的信息
1.11点击下一步,出现下图,点击启动,然后大家就祈祷把,一般都是出问题,那就慢慢调试吧。
希望大家能一次成功,我也不是一次就成功了,慢慢调试,另附上日志存在的位置
management: /var/log/cloudstack/management/management-server.ser
附上上文中所用到的cs安装包和安装kvm所需要的rpm包
http://pan.baidu.com/s/1sjn0WkH
4xd9