cloudstack必须安装在ubuntu server版本上吗
发布网友
发布时间:2022-04-25 06:03
我来回答
共1个回答
热心网友
时间:2022-05-03 08:18
方法一:在线安装(Server版)
一.安装CloudStackManagement
1.配置国内的网易镜像源
$ sudo sed -i s/us.archive.ubuntu.com/mirrors.163.com/g/etc/apt/sources.list
$ sudo sed -i s/security.ubuntu.com/mirrors.163.com/g /etc/apt/sources.list
2.配置CloudStack官方源
$ sudo vim /etc/apt/sources.list.d/cloudstack.list
deb http://cloudstack.apt-get.eu/ubuntu precise 4.0
3.配置CloudStack官方源证书
$ wget -O - http://cloudstack.apt-get.eu/release.asc|sudo apt-key add -
4.更新系统的安装源
$ sudo apt-get update
5.安装时间服务器
$ sudo apt-get install openntpd
6.安装CloudStack Management Server(5分钟左右)
$ sudo apt-get install cloud-client
7.将用户cloud加入到sudo用户组
CloudStack默认以cloud用户启动,但默认会通过sudo以root身份管理相关文件与目录
$ sudo adser cloud sudo
8.初始化root用户密码,如cloudstack
CloudStack默认需要root权限远程SSH连接到Agent
$ sudo -i
9. 使用权限
为了解决一个bug,即CloudStack默认以cloud用户启动,但却读取的是启动服务的用户的home目录用来存放一些临时文件,从而导致权限问题
$ chmod 777 /root
$ exit
10.安装配置MySQL数据库
$ sudo apt-get install mysql-server
注:在安装过程中会要求输入密码,请在弹出的界面中输入密码,如:111111一定要记住该密码
11.修改MySQL配置文件参数
$ sudo vim /etc/mysql/my.cnf
在[mysqld]模块中加入以下参数
innodb_rollback_on_timeout=1
innodb_lock_wait_timeout=600
max_connections=350
log-bin=mysql-bin
binlog-format = 'ROW'
12.重启MySQL
$ sudo service mysql restart
13.初始化数据库cloud
$ sudocloud-setup-databases cloud:111111@localhost --deploy-as=root:111111 -e file -mcloudstack -k cloudstack
注:其中的111111是mysql的密码,要根据您的实际情况修改。
14.配置NFS共享
CloudStack 需要一个地方来存放Primar和SecondaryStorage,官方推荐使用NFS共享。
安装NFS
$ sudo apt-get install nfs-common nfs-kernel-server
15.创建目录
$ sudo mkdir -p /export/primary
$ sudo mkdir -p /export/secondary
16.编辑NFS配置文件
$ sudo vim /etc/exports
/export *(rw,async,no_root_squash,no_subtree_check)
17.刷新配置
$ sudo exportfs -a
18.挂载NFS共享
$ sudo mkdir /mnt/primary
$ sudo mount -t nfs 192.168.1.223:/export/primary /mnt/primary
$ sudo mkdir /mnt/secondary
$ sudo mount -t nfs 192.168.1.223:/export/secondary /mnt/secondary
注意:192.168.1.223是本机IP,不同的电脑不一样,否则回报错:mount.nfs: Network is unreachable
用户可以通过ifconfig命令查看IP地址
19.测试NFS共享
$ df -h
Filesystem Size Used Avail Use% Mounted on
...
192.168.1.64:/export/primary 29G 7.7G 21G 28% /mnt/primary
192.168.1.64:/export/secondary 29G 7.7G 21G 28% /mnt/secondary
20.编辑fstab
$ sudo vim /etc/fstab
增加以下内容
192.168.1.223:/export/primary /mnt/primary nfs rw,tcp,intr 0 1
192.168.1.223:/export/secondary /mnt/secondary nfs rw,tcp,intr 0 1
注意:上述的IP地址是本机的IP地址,不用电脑肯定不一样,所以要按实际情况修改。
21.准备System VM Template
我们选择KVM作为虚拟化引擎
$ sudo /usr/lib/cloud/common/scripts/storage/secondary/cloud-install-sys-tmplt-m /mnt/secondary \
-u http://download.cloud.com/templates/acton/acton-systemvm-02062012.qcow2.bz2-h kvm -F
整个过程大概需要花费半个小时(视网速而定)
22.禁用系统默认的tomcat服务
$ sudo /etc/init.d/tomcat6 stop
$ sudo update-rc.d -f tomcat6remove
23.启动cloud-management
$ cd ~
$ sudo /etc/init.d/cloud-management restart
$ sudo cloud-setup-management
登陆用户界面
http://youIP:8080/client/
默认账号密码
admin/password
二.安装CloudStackAgent
(准备:与安装cloudstack-management的前5步相同)
1.安装配置Agent
$sudo apt-get install cloud-agent
2.安装配置libvirt
$ sudo vim /etc/libvirt/libvirtd.conf
修改以下配置
listen_tls = 0
listen_tcp = 1
tcp_port = "16059"
auth_tcp = "none"
mdns_adv = 0
3.查看配置
$ cat /etc/libvirt/libvirtd.conf | grep-v '#' | grep -v "^$"
内容如下
view sourceprint?
1.
listen_tls = 0
view sourceprint?
1.
listen_tcp = 1
view sourceprint?
1.
tcp_port = "16509"
view sourceprint?
1.
mdns_adv = 0
view sourceprint?
1.
unix_sock_group = "libvirtd"
view sourceprint?
1.
unix_sock_rw_perms = "0770"
view sourceprint?
1.
auth_unix_ro = "none"
view sourceprint?
1.
auth_unix_rw = "none"
view sourceprint?
1.
auth_tcp = "none"
view sourceprint?
1.
<strong>4.修改配置</strong>
$sudo vim /etc/init/libvirt-bin.conf
修改以下参数
view sourceprint?
1.
env libvirtd_opts="-d -l"
#sudo vim /etc/libvirt/qemu.conf
修改以下参数
view sourceprint?
1.
vnc_listen = "0.0.0.0"
重启服务
$ sudo service libvirt-bin restart
5.3 配置安全策略
$ sudo dpkg --list "apparmor"
$sudo ln -s /etc/apparmor.d/usr.sbin.libvirtd /etc/apparmor.d/disable/
$ sudo ln -s /etc/apparmor.d/usr.lib.libvirt.virt-aa-helper/etc/apparmor.d/disable/
$ sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.libvirtd
$ sudo apparmor_parser -R /etc/apparmor.d/usr.lib.libvirt.virt-aa-helper
5.4 配置网桥
需要注意的是,官方文档给出的配置参数会导致网络不可用。
正确的配置是将物理网卡设置为manual,然后在虚拟网卡上设置IP并桥接到物理网卡上。
$ sudo vim /etc/network/interfaces
view sourceprint?
1.
# This file describes the network interfaces available on your system
view sourceprint?
1.
# and how to activate them. For more information, see interfaces(5).
view sourceprint?
1.
view sourceprint?
1.
# The loopback network interface
view sourceprint?
1.
auto lo
view sourceprint?
1.
iface lo inet loopback
view sourceprint?
1.
view sourceprint?
1.
# The primary network interface
view sourceprint?
1.
auto eth0
view sourceprint?
1.
iface eth0 inet manual
view sourceprint?
1.
view sourceprint?
1.
# Public network
view sourceprint?
1.
auto cloudbr0
view sourceprint?
1.
iface cloudbr0 inet static
view sourceprint?
1.
address 192.168.1.202
view sourceprint?
1.
netmask 255.255.255.0
view sourceprint?
1.
gateway 192.168.1.1
view sourceprint?
1.
bridge_ports eth0
view sourceprint?
1.
bridge_fd 5
view sourceprint?
1.
bridge_stp off
view sourceprint?
1.
bridge_maxwait 1
view sourceprint?
1.
# Private network
view sourceprint?
1.
auto cloudbr1
view sourceprint?
1.
iface cloudbr1 inet manual
view sourceprint?
1.
bridge_ports eth0
view sourceprint?
1.
bridge_fd 5
view sourceprint?
1.
bridge_stp off
view sourceprint?
1.
bridge_maxwait 1
view sourceprint?
1.
$sudo /etc/init.d/networking restart
$ sudo /etc/init.d/networking start
5.5 配置防火墙
$ sudo ufw allow proto tcp from any toany port 22
$ sudo ufw allow proto tcp from any to any port 80
$ sudo ufw allow proto tcp from any to any port 1798
$ sudo ufw allow proto tcp from any to any port 16509
$ sudo ufw allow proto tcp from any to any port 5900:6100
$ sudo ufw allow proto tcp from any to any port 49152:49216
方法二:离线安装(ubuntu即可)
(一).下载不安装(192.168.1.201)
通过命令sudo apt-get-d install XXXXX
下载不安装,会将文件下载到/var/cache/apt/archives
以下步骤是在ubuntu server12.04上制作CloudStack的离线安装包
1.配置国内的网易镜像源
$ sudo sed -is/us.archive.ubuntu.com/mirrors.163.com/g /etc/apt/sources.list
$ sudo sed -i s/security.ubuntu.com/mirrors.163.com/g /etc/apt/sources.list
2.配置CloudStack官方源
$ sudo vim /etc/apt/sources.list.d/cloudstack.list
deb http://cloudstack.apt-get.eu/ubuntu precise 4.0
3.配置CloudStack官方源证书
$ wget -O - http://cloudstack.apt-get.eu/release.asc|sudo apt-key add -
4.更新系统的安装源
$ sudo apt-get update
5.下载时间服务器
$ sudo apt-get -d install openntpd
6.下载CloudStack (5分钟左右)
$ sudo apt-get -d install cloud-client
$sudo apt-get -d install cloud-agent
7.下载配置MySQL数据库
$ sudo apt-get -d install mysql-server
$ sudo apt-get -d install nfs-common nfs-kernel-server
以上步骤执行完之后,/var/cache/apt/archives目录下就是所需要的deb文件
8.打包System VMTemplate
(二).在另外一台ubuntu上制作离线包(192.168.1.73)
1.根目录下新建一个文件夹
$ sudo mkdir offlineCloudStackPackage
2.在之前电脑上,执行如下命名,将下载的deb包拷贝到上述新建的文件夹下
$ sudo scp -r /var/cache/apt/archives root@192.168.1.73:/offlineCloudStackPackage
3.修改文件夹的权限,可读可写可执行
$ sudo chmod 777 -R/offlineCloudStackPackage/
4.建立deb包的依赖关系
$ sudo dpkg-scanpackages/offlineCloudStackPackage/ /dev/null |gzip >/offlineCloudStackPackage/Packages.gz
5.将生成的Packages.gz包复制到和deb同目录下
$sudo cp/offlineCloudStackPackage/Packages.gz /offlineCloudStackPackage/archives/Packages.gz
6.打包成压缩包,以备后用
$ tar cvzf offlineCloudStackPackage.tar.gzofflineCloudStackPackage/
保存offlineCloudStackPackage.tar.gz文件到U盘或服务器
(三).安装(离线的Ubuntu服务器)
1.插入U盘,将offlineCloudStackPackage.tar.gz复制到根目录下,解压
$ sudo tar -xvf offlineCloudStackPackage.tar.gz
2.add sources in systemsource.list
$ sudo vi /etc/apt/sources.list
$ deb file:///offlineCloudStackPackagearchives/
然后将所有的其他deb全部注销掉(#)
3. update your system source
$ sudo apt-get update
然后执行在线安装的第(5)~(20)和(22)~(23)步
在启动CloudStack之前,最好先将虚拟机模板拷贝到二级存储/mnt/secondary下