Cloudstack安装部署.docx
《Cloudstack安装部署.docx》由会员分享,可在线阅读,更多相关《Cloudstack安装部署.docx(14页珍藏版)》请在冰豆网上搜索。
![Cloudstack安装部署.docx](https://file1.bdocx.com/fileroot1/2023-7/6/380b6db5-91ff-47f7-bde8-5190d2e68d01/380b6db5-91ff-47f7-bde8-5190d2e68d011.gif)
Cloudstack安装部署
1.概况
IaaS层统一管理监控平台包括OpenStack,CloudStack等,对于使用大量主机和存储的应用提供了管理平台。
CloudStack是一个开源的具有高可用性及扩展性的云计算平台。
支持管理大部分主流的hypervisors,如KVM,XenServer,VMware,OracleVM,Xen等
1.CloudStack管理网络,存储,主机,支持管理KVM,Xen,VMWare虚拟机。
2.CloudStack是Apache顶级项目,完成与OpenStack类似功能。
3.KVM(kernel-basedVirtualMachine)是基于内核的虚拟机,是基于硬件的完全虚拟化。
2.安装KVM及相关软件
1.1.安装kvm虚拟机
1、KVM需要有CPU的支持(Intelvmx或AMDsvm),在安装KVM之前检查一下CPU是否提供了虚拟技术的支持:
[root@myKVM~]#egrep'^flags.*(vmx|svm)'/proc/cpuinfo
有显示,有显示则说明处理器具有VT功能
2、在主板BIOS中开启CPU的VirtualTechnolege(VT,虚化技术)
3、安装kvm及其需要的软件包
[root@myKVM~]#yuminstallkvmkmod-kvmqemukvm-qemu-imgvirt-viewervirt-managerlibvirtlibvirt-pythonpython-virtinst
或
[root@myKVM~]#yumgroupinstallKVM
4、检查kvm模块是否安装,使用以下命令显示两个模块则表示安装完成
[root@myKVM~]#lsmod|grepkvm
1.2.启动virt-manager管理界面
1、客户端
VNC到服务器端,因为需要用服务器的图形界面
2、服务器端
启动libvirtd服务,并保证下次自动启动
[root@myKVM~]#servicelibvirtdstart
Startinglibvirtddaemon:
[确定]
[root@myKVM~]#chkconfiglibvirtdon
1.3.远程创建和管理KVM虚拟机
1.打开Application=>SystemTools=>VirtualMachineManager就可以装虚拟机了,功能跟VMware类似
3.安装cloudstack环境
构建安装包
#yumgroupinstall"DevelopmentTools"
#yuminstalljava-1.6.0-openjdk-devel.x86_64genisoimagemysqlmysql-serverws-commons-utilMySQL-pythontomcat6createrepo
Next,you'llneedtoinstallbuild-timedependenciesforCloudStackwithMaven.We'reusingMaven3,soyou'llwanttograbaMaven3tarballanduncompressitinyourhomedirectory(orwhateverlocationyouprefer):
$tarzxvfapache-maven-3.0.4-bin.tar.gz
$exportPATH=/usr/local/apache-maven-3.0.4//bin:
$PATH
MavenalsoneedstoknowwhereJavais,andexpectstheJAVA_HOMEenvironmentvariabletobeset:
$exportJAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/
VerifythatMavenisinstalledcorrectly:
$mvn--version
GeneratingRPMS
Nowthatwehavetheprerequisitesandsource,youwillcdtothepackaging/centos63/directory.
GeneratingRPMsisdoneusingthepackage.shscript:
$./package.sh
Thatwillrunforabitandthenplacethefinishedpackagesindist/rpmbuild/RPMS/x86_64/.
YoushouldseesixRPMsinthatdirectory:
ñcloudstack-agent-4.1.0.el6.x86_64.rpm
ñcloudstack-awsapi-4.1.0.el6.x86_64.rpm
ñcloudstack-cli-4.1.0.el6.x86_64.rpm
ñcloudstack-common-4.1.0.el6.x86_64.rpm
ñcloudstack-management-4.1.0.el6.x86_64.rpm
ñcloudstack-usage-4.1.0.el6.x86_64.rpm
Configuringyoursystemstouseyournewyumrepository
NowthatyouryumrepositoryispopulatedwithRPMsandmetadataweneedtoconfigurethemachinesthatneedtoinstall$PRODUCT;.Createafilenamed/etc/yum.repos.d/cloudstack.repowiththisinformation:
[cloudstack]
name=cloudstack
baseurl=bbb:
//cloudstack.apt-get.eu/rhel/4.1/
enabled=1
gpgcheck=0
Checkforafullyqualifiedhostname.
hostname--fqdn
ñMakesurethatthemachinecanreachtheInternet.
pingaaacloudstack.org
TurnonNTPfortimesynchronization.
yuminstallntp
安装mysql
InstallMySQLfromthepackagerepositoryofyourdistribution:
yuminstallmysql-server
ñOpentheMySQLconfigurationfile.Theconfigurationfileis/etc/mybbbfor/etc/mysql/mybbbf,dependingonyourOS.
innodb_rollback_on_timeout=1
innodb_lock_wait_timeout=600
max_connections=350
log-bin=mysql-bin
binlog-format='ROW'
StartorrestartMySQLtoputthenewconfigurationintoeffect.
servicemysqldstart
OnUbuntu,restartMySQL.
servicemysqldrestart
设置mysql密码
mysql_secure_installation
设置远程链接
#mysql-uroot-p
mysql>grantallprivilegeson*.*to'root'@'%'withgrantoption;
mysql>flushprivileges;
ConfigureSELinux(RHELandCentOS):
1.CheckwhetherSELinuxisinstalledonyourmachine.Ifnot,youcanskipthissection.
InRHELorCentOS,SELinuxisinstalledandenabledbydefault.Youcanverifythiswith:
$rpm-qa|grepselinux
2.SettheSELINUXvariablein/etc/selinux/configto"permissive".Thisensuresthatthepermissivesettingwillbemaintainedafterasystemreboot.
InRHELorCentOS:
vi/etc/selinux/config
Changethefollowingline
SELINUX=enforcing
tothis:
SELINUX=permissive
3.SetSELinuxtopermissivestartingimmediately,withoutrequiringasystemreboot.
$setenforcepermissive
3.1.安装cloud-client
安装cloudstack客户端
yuminstallcloud-client
Setupthedatabase.Thefollowingcommandcreatesthe"cloud"useronthedatabase.
cloudstack-setup-databasescloud:
passw0rd@lnxcs01--deploy-as=root:
passw0rd-efile-mpassw0rd-kpassw0rd
IfyouarerunningtheKVMhypervisoronthesamemachinewiththeManagementServer,edit/etc/sudoersandaddthefollowingline:
Defaults:
cloud!
requiretty
Nowthatthedatabaseissetup,youcanfinishconfiguringtheOSfortheManagementServer.Thiscommandwillsetupiptables,sudoers,andstarttheManagementServer.
#cloudstack-setup-management
[root@lnxcs01~]#servicecloudstack-managementstart
/etc/init.d/cloud-managementrestart
如果不能启动,请查看错误日志
访问位置:
bbb:
//lnxcs01:
8080/client
Username:
admin
Password:
password.
3.2.安装NFS
安装NFSUtils
yuminstallnfs-utils
创建存储目录
#mkdir-p/export/primary
#mkdir-p/export/secondary
编辑NFS配置文件
$sudovi/etc/exports
/export*(rw,async,no_root_squash,no_subtree_check)
刷新配置
$sudoexportfs-a
#vi/etc/sysconfig/nfs
Uncommentthefollowinglines:
LOCKD_TCPPORT=32803
LOCKD_UDPPORT=32769
MOUNTD_PORT=892
RQUOTAD_PORT=875
STATD_PORT=662
STATD_OUTGOING_PORT=2020
Editthe/etc/sysconfig/iptablesfile.
#vi/etc/sysconfig/iptables
AddthefollowinglinesatthebeginningoftheINPUTchainwhereisthenetworkthatyou'llbeusing:
-AINPUT-s10.192.17.47-mstate--stateNEW-pudp--dport111-jACCEPT
-AINPUT-s10.192.17.47-mstate--stateNEW-ptcp--dport111-jACCEPT
-AINPUT-s10.192.17.47-mstate--stateNEW-ptcp--dport2049-jACCEPT
-AINPUT-s10.192.17.47-mstate--stateNEW-ptcp--dport32803-jACCEPT
-AINPUT-s10.192.17.47-mstate--stateNEW-pudp--dport32769-jACCEPT
-AINPUT-s10.192.17.47-mstate--stateNEW-ptcp--dport892-jACCEPT
-AINPUT-s10.192.17.47-mstate--stateNEW-pudp--dport892-jACCEPT
-AINPUT-s10.192.17.47-mstate--stateNEW-ptcp--dport875-jACCEPT
-AINPUT-s10.192.17.47-mstate--stateNEW-pudp--dport875-jACCEPT
-AINPUT-s10.192.17.47-mstate--stateNEW-ptcp--dport662-jACCEPT
-AINPUT-s10.192.17.47-mstate--stateNEW-pudp--dport662-jACCEPT
ñRunthefollowingcommands:
#serviceiptablesrestart
#serviceiptablessave
IfNFSv4communicationisusedbetweenclientandserver,addyourdomainto/etc/idmapd.confonboththehypervisorhostandManagementServer.
#vi/etc/idmapd.conf
Removethecharacter#fromthebeginningoftheDomainlineinidmapd.confandreplacethevalueinthefilewithyourowndomain.Intheexamplebelow,thedomainiscompanyaaa.
Domain=lnxcs01aaa
#servicerpcbindstart
#servicenfsstart
#chkconfignfson
#chkconfigrpcbindon
#reboot
挂载测试NFS共享
#mkdir/mnt/primary
#mount-tnfs10.192.17.47:
/export/primary/mnt/primary
#mkdir/mnt/secondary
#mount-tnfs10.192.17.47:
/export/secondary/mnt/secondary
umount/mnt/primary
umount/mnt/secondary
$df-h
1FilesystemSizeUsedAvailUse%Mountedon
2...
310.192.17.47:
/export/primary434G7.8G404G2%/mnt/primary
410.192.17.47:
/export/secondary434G7.8G404G2%/mnt/secondary
#vi/etc/fstab
增加以下内容
10.192.17.47:
/export/primary/mnt/primarynfsrw,tcp,intr01
10.192.17.47:
/export/secondary/mnt/secondarynfsrw,tcp,intr01
3.3.准备VM模板
/usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt-m/mnt/secondary-ubbb:
//download.cloudaaa/templates/acton/acton-systemvm-02062012.qcow2.bz2-hkvm-spassw0rd-F
nstall-sys-tmplt-m/mnt/secondary-ubbb:
//download.cloudaaa/templates/acton/acton-systemvm-02062012.qcow2.bz2-hkvm-spassw0rd-F
--2013-06-2613:
15:
20--bbb:
//download.cloudaaa/templates/acton/acton-systemvm-02062012.qcow2.bz2
Resolvingdownload.cloudaaa...176.32.99.39
Connectingtodownload.cloudaaa|176.32.99.39|:
80...connected.
bbbrequestsent,awaitingresponse...200OK
Length:
286036668(273M)[binary/octet-stream]
Savingto:
“/usr/share/cloudstack-common/scripts/storage/secondary/d115b31e-b564-4590-8800-cf4d638bdf2a.qcow2”
100%[======================================>]286,036,668250K/sin26m29s
2013-06-2613:
42:
04(176KB/s)-“/usr/share/cloudstack-common/scripts/storage/secondary/d115b31e-b564-4590-8800-cf4d638bdf2a.qcow2”saved[286036668/286036668]
Uncompressingto/usr/share/cloudstack-common/scripts/storage/secondary/d115b31e-b564-4590-8800-cf4d638bdf2a.qcow2.tmp(typebz2)...couldtakealongtime
Movingto/mnt/secondary/template/tmpl/1/3///d115b31e-b564-4590-8800-cf4d638bdf2a.qcow2...couldtakeawhile
SuccessfullyinstalledsystemVMtemplateto/mnt/secondary/template/tmpl/1/3
4.配置cloudstack环境
4.1.配置基础环境
通过bbb:
//lnxcs01:
8080/client/配置infrasructure中的zone,pod,cluster
4.2.安装cloud-agent
在同一台机器上安装cloud-client和client-agent(KVM主机和cloud管理在一台机器上)
#yuminstallcloud-agent
通过命令将host添加到cloudstackmanagement中。
如果出现unabletoaddtohost错误,查看一下网络,新增加一个文件
vi/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0#网卡的名称
#TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BRIDGE=virbr0
vi/etc/sysconfig/network-scripts/ifcfg-virbr0
DEVICE=virbr0#网桥的名称,这是CloudStack默认的网桥名称
TYPE=Bridge#设备类型为网桥
ONBOOT=yes
BOOTPROTO=static#使用静态IP,注意在ifcfg-p4p1中不写ip,网桥的配置文件中才写
IPADDR=192.168.122.1#IP位置,根据自己的网络情况配置
BROADCAST=192.168.122.255#广播位置,根据自己的网络情况配置
NETMASK=255.255.255.0#子网掩码,根据自己的网络情况配置
GATEWAY=10.192.17.254#网关位置,根据自己的网络情况配置
DNS1=10.192.1.1#DNS服务器位置,根据自己的网络情况配置
况配置
确保配置文件正确后,关闭NetworkManager服务
>#serviceNetworkManagerstop
你可以看到右上角网络的图标消失了,之后重启网络服务
>#servicenetworkreload
>#serviceNetworkManagerstart
#cloudstack-setup-agent
cloud-setup-agent然后根据要求写MSip,zoneid,podid,clu