首页 > 代码库 > CloudStack 4.4学习总结之cloudstack-management安装

CloudStack 4.4学习总结之cloudstack-management安装

CloudStack 4.4学习总结之cloudstack-management安装


 

1cloudstack-management安装步骤(CloudStack 3.04.4软件包

 

    CloudStack的3.0版本和4.4版本的命令和目录有很大的区别。

 

    下面的命令,标注部分为3.0和4.4的区别,其他的不变。

 

①、以 root 身份登录并设置主机名:

主机名:    【cloud-server.perofu.com】

    ip:        【172.22.2.76】

 

hostname cloud-server.perofu.com

vi /etc/sysconfig/network

    HOSTNAME=cloud-server.perofu.com                                            

vi /etc/hosts

    127.0.0.1       cloud-server.perofu.com

    172.22.2.76         cloud-server.perofu.com

    172.22.2.87     cloud-agent-1.perofu.com

    172.22.2.100    cloud-agent-2.perofu.com

 

 

②、设置SELinux并同步时间:

vi /etc/sysconfig/selinux

    SELINUX=disabled                                                            

setenforce 0

yum install ntpdate -y

echo ‘#ntpd‘ >>   /var/spool/cron/root

echo "10 5 * * *   /usr/sbin/ntpdate ntp.api.bz &> /dev/null" >>   /var/spool/cron/root

echo ‘‘ >>   /var/spool/cron/root

service ntpd stop

chkconfig ntpd off

/usr/sbin/ntpdate   ntp.api.bz &> /dev/null

 

③、安装MySQL

 

    这里将mysql单独拿出来安装,用的是光盘的yum源,可以节省资源,当然大家可以使用Cloudstack的安装脚本进行安装,一样的效果。

 

yum install openssl-devel   mysql-server mysql-devel -y

cp -a   /usr/share/doc/mysql-server-5.1.66/my-medium.cnf /etc/my.cnf

vi /etc/my.cnf

    [mysqld]

    innodb_rollback_on_timeout=1

    innodb_lock_wait_timeout=600  

    max_connections=350  

    log-bin=mysql-bin  

    binlog-format=ROW

/etc/init.d/mysqld start

chkconfig mysqld on

/usr/bin/mysql_secure_installation  #配置mysql安全,可直接全选Y                 

 

④、安装cloudstack-management

 

V4.4

vi   /etc/yum.repos.d/cloudstack.repo 

[cloudstack]                                                                    

name=cloudstack

baseurl=http://cloudstack.apt-get.eu/rhel/4.4/

enabled=1

gpgcheck=0

yum -y install   cloudstack-management httpd

 

V3.0

tar -axf   CloudStack-oss-3.0.2-1-rhel6.2.tar.gz -C /usr/local/src/

cd   /usr/local/src/CloudStack-oss-3.0.2-1-rhel6.2/

./install.sh

   

 

“M”------>    安装 Management Server 软件。

“D”------>    安装 MySQL。

     

 

⑤、初始化CloudStack的数据库:

 

V4.4

cloudstack-setup-databases cloud:dbpassword@localhost --deploy-as=root:password

 

[root@cloud-server   ~]# cloudstack-setup-databases cloud:123456@localhost --deploy-as=root:123456

 

 

V3.0

cloud-setup-databases   cloud:dbpassword@localhost   --deploy-as=root:password

 

    注:即表示以 root 用户身份来生成数据库,该数据库属于新建的 cloud 用户(密码 dbpassword 可以留空)。

 

[root@cloud-server   ~]# cloud-setup-databases cloud:123456@localhost --deploy-as=root:123456

Mysql   user name:cloud                                                             [ OK ]

Mysql   user password:123456                                                        [ OK ]

Mysql   server ip:localhost                                                         [ OK ]

Mysql   server port:3306                                                            [ OK ]

Mysql   root user name:root                                                         [ OK ]

Mysql   root user password:123456                                                   [ OK ]

Checking   Cloud database files ...                                                 [ OK ]

Checking   local machine hostname ...                                               [ OK ]

Checking   SELinux setup ...                                                        WARNING: We detected that your SELinux is not configured in   permissive. to make sure cloudstack won‘t block by SELinux after system   reboot, we strongly suggest you setting it in permissive in   /etc/selinux/config, then reboot the machine.

[   OK ]

Detected   local IP address as 172.22.2.76, will use as cluster management server node   IP[ OK ]

Preparing   /etc/cloud/management/db.properties                                   [ OK ]

Applying   /usr/share/cloud/setup/create-database.sql                             [ OK ]

Applying   /usr/share/cloud/setup/create-schema.sql                               [ OK ]

Applying   /usr/share/cloud/setup/create-database-premium.sql                     [ OK ]

Applying   /usr/share/cloud/setup/create-schema-premium.sql                       [ OK ]

Applying   /usr/share/cloud/setup/server-setup.sql                                [ OK ]

Applying   /usr/share/cloud/setup/templates.sql                                   [ OK ]

Applying   /usr/share/cloud/setup/create-index-fk.sql                             [ OK ]

Processing   encryption ...                                                         [ OK ]

Finalizing   setup ...                                                              [ OK ]

 

CloudStack   has successfully initialized database, you can check your database   configuration in /etc/cloud/management/db.properties

 

    /etc/cloud/management/db.properties存放CloudStack数据库的相关信息。

 

⑥、初始化cloudstack-management并启动:

 

    对操作系统 iptables、sudoers 的设置(CloudStack 本身有安全性方面的要求,不是无限暴露给网络,同时又需要一些管理权限来运行自身服务,因此要做这两项的设置)。

 

V4.4

 

/etc/init.d/httpd start

chkconfig httpd on                                                              

cloudstack-setup-management

/etc/init.d/cloudstack-management   start

chkconfig cloudstack-management   on

 

V3.0

cloud-setup-management                                                           

/etc/init.d/cloud-management   start

chkconfig cloud-management   on

 

 

[root@cloud-server   ~]# cloud-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!

 

manager的日志文件:/var/log/cloud/management/management-server.log

 

⑦、配置NFS

 

前面讲过,CloudStack 需要两类存储(primary storage 和 secondary storage)来支持它的 cluster 和 host,本节中由 NFS 来提供这两个存储,因此前述步骤中要启动 NFS 服务。同时为了方便起见,NFS Server 也由 cloud-server.perofu.com 充当。

 

yum install nfs-utils -y

mkdir -p   /data/{primary,secondary}  #创建两个目录,分别作为一级和二级存储

chmod 777 /data/*

vi /etc/exports

    /data/primary   *(rw,fsid=1,async,no_root_squash,no_subtree_check)

    /data/secondary *(rw,fsid=2,async,no_root_squash,no_subtree_check)

exportfs -a     #导出/data 目录

cp /etc/sysconfig/nfs   /etc/sysconfig/nfs.bak

> /etc/sysconfig/nfs

vi /etc/sysconfig/nfs       #用于iptables


   LOCKD_TCPPORT=32803

    LOCKD_UDPPORT=32769

    MOUNTD_PORT=892

    RQUOTAD_PORT=875

    STATD_PORT=662

    STATD_OUTGOING_PORT=2020

vi /etc/sysconfig/iptables  #加入到所有INPUT之前,也可以关闭iptables

    -A INPUT -m state --state NEW -p udp   --dport 111 -j ACCEPT

    -A INPUT -m state --state NEW -p tcp   --dport 111 -j ACCEPT 

    -A INPUT -m state --state NEW -p tcp   --dport 2049 -j ACCEPT 

    -A INPUT -m state --state NEW -p tcp   --dport 32803 -j ACCEPT  

    -A INPUT -m state --state NEW -p udp   --dport 32769 -j ACCEPT 

    -A INPUT -m state --state NEW -p tcp   --dport 892 -j ACCEPT 

    -A INPUT -m state --state NEW -p udp   --dport 892 -j ACCEPT 

    -A INPUT -m state --state NEW -p tcp   --dport 875 -j ACCEPT 

    -A INPUT -m state --state NEW -p udp   --dport 875 -j ACCEPT 

    -A INPUT -m state --state NEW -p tcp   --dport 662 -j ACCEPT 

    -A INPUT -m state --state NEW -p udp   --dport 662 -j ACCEPT

service iptables restart

service iptables save

vi /etc/idmapd.conf     #管理服务器(cloud-server.perofu.com)和 hypervisor都要

    Domain = perofu.com

service rpcbind restart

service nfs restart

mkdir /tmp/primarymount

mount -t nfs 172.22.2.76:/data/primary   /tmp/primarymount #测试能否挂载,iptables

umount /tmp/primarymount/

service rpcbind restart

service nfs restart

chkconfig nfs on

chkconfig rpcbind on

 

[root@cloud-server   ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup-lv_root

                       19G  1.7G     16G  10% /

tmpfs                 116M     0    116M   0% /dev/shm

/dev/sda1             485M   32M    428M   7% /boot

/dev/sr0              4.1G  4.1G       0 100% /mnt

172.22.2.76:/data/primary 19G  1.7G     16G  10% /tmp/primarymount

 

 

⑧、导入虚拟机模板:

系统虚拟机模板按要求要存放在辅助存储上的,我们可以先手动挂载nfs辅助存储, 然后把290M KVM虚拟化模板先下载到辅助存储目录下,然后在导入, 导入系统虚拟机模板步是必须要配置的内容。本例采用KVM虚拟化,下载导入KVM虚拟机模板。

 

         1)、在management上挂载辅助存储

         2)、下载kvm模板,并上传到辅助存储;

         3)、导入。

 

         systemvm64template-4.4.0-6-kvm.qcow2.bz2模板文件有点大,最好是通过别的下载工具进行下载,如百度网盘的离线下载,再上传使用。

 

         在management上操作。

V4.4

/usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt   -m /tmp/secondarymount -f systemvm64template-4.4.0-6-kvm.qcow2.bz2 -h kvm -F

 

V3.0

mkdir /tmp/secondarymount

mount -t nfs 172.22.2.76:/data/secondary   /tmp/secondarymount

cd /tmp/secondarymount

wget http://cloudstack.apt-get.eu/systemvm/4.4/systemvm64template-4.4.0-6-kvm.qcow2.bz2

/usr/lib64/cloud/agent/scripts/storage/secondary/cloud-install-sys-tmplt   -m /tmp/secondarymount -f systemvm64template-4.4.0-6-kvm.qcow2.bz2 -h kvm -F

 

    系统虚拟机默认用户名密码:root/6m1ll10n

 

[root@cloud-server   ~]# mkdir /tmp/secondarymount

[root@cloud-server   ~]# mount -t nfs 172.22.2.76:/data/secondary /tmp/secondarymount

[root@cloud-server   ~]# cd /tmp/secondarymount

[root@cloud-server   secondarymount]# rz

rz   waiting to receive.

Starting   zmodem transfer.  Press Ctrl+C to   cancel.

  100%    296844 KB 6184 KB/s 00:00:48         0 Errorss2...

 

[root@cloud-server   secondarymount]# pwd

/tmp/secondarymount

[root@cloud-server   secondarymount]#

[root@cloud-server   secondarymount]# ll

total   296848

-rw-r--r--.   1 root root 303968528 Sep 29 03:17 systemvm64template-4.4.0-6-kvm.qcow2.bz2

[root@cloud-server   secondarymount]#   /usr/lib64/cloud/agent/scripts/storage/secondary/cloud-install-sys-tmplt -m   /tmp/secondarymount -f systemvm64template-4.4.0-6-kvm.qcow2.bz2 -h kvm -F

Uncompressing   to   /usr/lib64/cloud/agent/scripts/storage/secondary/6e1d6d0d-8768-48b9-87af-44a182427c8c.qcow2.tmp   (type bz2)...could take a long time

Moving   to /tmp/secondarymount/template/tmpl/1/3///6e1d6d0d-8768-48b9-87af-44a182427c8c.qcow2...could   take a while

Successfully   installed system VM template systemvm64template-4.4.0-6-kvm.qcow2.bz2 to   /tmp/secondarymount/template/tmpl/1/3/

[root@cloud-server   secondarymount]#

 

 

⑨、访问web

 

http://172.22.2.76:8080/client/

默认用户名和密码为admin, password

 

V4.4

 145149_6KdL_727880.png


V3.0

 145321_6YCs_727880.png

 

 

⑩、CloudStack如何重装:

1)、停掉CloudStack服务:

 

service   cloudstack-management stop                                            

 

 

2)、删除数据库:

 

mysql>drop   database cloud;                                                     

mysql>drop   database cloud_usage;

mysql>drop   database cloudbridge;

mysql>\q


3)、初始化CloudStack数据库:


    详见初始化CloudStack数据库部分。

 

4)、重新导入系统虚机:

    详见导入虚拟机模板部分。

 

5)、启动cloudstack服务:

 

service   cloudstack-management start                                            

 

这时,你再登陆就会发现一个全新的CloudStack啦。


     到此,CloudStack Management就安装完成了,下节进入CloudStack Agent与KVM的安装

本文出自 “无咎” 博客,请务必保留此出处http://perofu.blog.51cto.com/6061242/1569222

CloudStack 4.4学习总结之cloudstack-management安装