CloudStack 4.4学习总结之cloudstack-agent安装
2、节点安装(cloudstack-agent、KVM):注:每个Hypervisor上,都要保证【/mnt】目录为空,否则,可能会出现InsufficientServerCapacityException (服务器资源不足)的报错。
cloud-agent-2.perofu.com和cloud-agent-1.perofu.com的安装步骤一样,即,所有cloudstack-agent节点的安装步骤均一样。
下面以cloud-agent-1.perofu.com进行演示。
①、以 root 身份登录并设置主机名:
【cloud-agent-1.perofu.com】
hostname cloud-agent-1.perofu.com
vi /etc/sysconfig/network
HOSTNAME=cloud-agent-1.perofu.com
vi /etc/hosts
127.0.0.1 cloud-agent-1.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、关闭iptables并同步时间:
vi /etc/sysconfig/selinux
SELINUX=disabled
setenforce 0
service iptables stop
chkconfig iptables off
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
③、安装Management agent:
V4.4
vi /etc/yum.repos.d/cloudstack.repo
name=cloudstack
baseurl=http://cloudstack.apt-get.eu/rhel/4.4/
enabled=1
gpgcheck=0
yum -y install cloudstack-agent
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
A
“A”------> 安装 CloudStack Agent 软件, CloudStack客户端。
④、安装KVM虚拟化环境:
1)、查看CPU是否支持虚拟化:
grep -E -o 'vmx|svm' /proc/cpuinfo
VMX:它是Intel处理器虚拟机技术标志;
SVM:它是AMD处理器虚拟机技术的标志。
注:linux发行版本必须在64bit环境中才能使用KVM。
# grep -E -o 'vmx|svm' /proc/cpuinfo
vmx
2)、安装kvm:
yum源使用的是Centos 6.4的光盘镜像。
yum -y install kvm python-virtinst libvirt tunctl bridge-utils virt-manager qemu-kvm-tools virt-viewer virt-v2v libguestfs-tools
3)、修改vnc的监听端口:
vnc默认的监听127.0.0.1。
因为,在创建虚拟机时,需要连接vnc,去手动安装新系统。
cp /etc/libvirt/qemu.conf /etc/libvirt/qemu.conf.bak
vi /etc/libvirt/qemu.conf
vnc_listen=0.0.0.0
4)、配置Libvirt:
vi /etc/libvirt/libvirtd.conf
listen_tls = 0
listen_tcp = 1
tcp_port = "16509"
auth_tcp = "none"
mdns_adv = 0
vi /etc/sysconfig/libvirtd
LIBVIRTD_ARGS="--listen"
service libvirtd restart
chkconfig libvirtd on
5)、检查KVM是否加载成功:
如果没有输出信息,则表示没有加载成功。
lsmod | grep kvm
# lsmod | grep kvm
kvm_intel 534840
kvm 3165061 kvm_intel
6)、检查KVM是否成功安装:
-all关闭的也会显示。
virsh list --all
# virsh list --all
Id Name State
----------------------------------------------------
7)、配置网卡:
虚拟机的网卡名称是:cloudbr0,不要自作聪明,用了br0,报了一个下午的错。
yum install -y tunctl
cat << EOF > /etc/sysconfig/network-scripts/ifcfg-cloudbr0
DEVICE=cloudbr0
TYPE=Bridge
BOOTPROTO=static
IPV6INIT=no
ONBOOT=yes
IPADDR=172.22.2.87
NETMASK=255.255.0.0
GATEWAY=172.22.1.3
DNS1=8.8.8.8
DELAY=0
EOF
cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/bak_ifcfg-eth0
cat << EOF > /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
BRIDGE=cloudbr0
IPV6INIT=no
EOF
/etc/init.d/network restart
#查看桥接网络
brctl show
# ifconfig
cloudbr0 Link encap:EthernetHWaddr 00:0C:29:40:7F:1D
inet addr:172.22.2.87Bcast:172.22.255.255Mask:255.255.0.0
inet6 addr: fe80::20c:29ff:fe40:7f1d/64 Scope:Link
UP BROADCAST RUNNING MULTICASTMTU:1500 Metric:1
RX packets:226 errors:0 dropped:0 overruns:0 frame:0
TX packets:28 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:18457 (18.0 KiB)TX bytes:3116 (3.0 KiB)
eth0 Link encap:EthernetHWaddr 00:0C:29:40:7F:1D
inet6 addr: fe80::20c:29ff:fe40:7f1d/64 Scope:Link
UP BROADCAST RUNNING MULTICASTMTU:1500 Metric:1
RX packets:175448 errors:0 dropped:0 overruns:0 frame:0
TX packets:94709 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:191337793 (182.4 MiB)TX bytes:7210912 (6.8 MiB)
⑤、配置cloudstack-agent:
这里也可以省略,只是在初始化的时候需要手动输入cloudstack-management的ip。
V4.4
vi /etc/cloudstack/agent/agent.properties
# cloudstack管理服务器地址
host= 172.22.2.76
V3.0
vi /etc/cloud/agent/agent.properties
# cloudstack管理服务器地址
host= 172.22.2.76
⑥、配置nfs域名:
vi /etc/idmapd.conf
Domain = perofu.com
⑦、初始化cloudstack-agent:
一路回车,即可。
V4.4
cloudstack-setup-agent
V3.0
cloud-setup-agent
# cloud-setup-agent
Welcome to Cloud Agent Setup:
Please input the Management Server Name/IP:
Please input the Zone Id:
Please input the Pod Id:
Please input the Cluster Id:[]
Please choose which network used to create VM:
Starting to configure your system:
Configure SElinux ...
Configure Network ...
Configure Libvirt ...
Configure Firewall ...
Configure cloudAgent ...
Cloud Agent setup is Done!
Libvirt报错:
# cloud-setup-agent
Welcome to Cloud Agent Setup:
Please input the Management Server Name/IP:
Please input the Zone Id:
Please input the Pod Id:
Please input the Cluster Id:[]
Please choose which network used to create VM:
Starting to configure your system:
Configure SElinux ...
Configure Network ...
Configure Libvirt ...
Traceback (most recent call last):
File "/usr/bin/cloud-setup-agent", line 112, in <module>
syscfg.config()
File "/usr/lib/python2.6/site-packages/cloudutils/syscfg.py", line 76, in config
raise CloudInternalException()
TypeError: __init__() takes exactly 2 arguments (1 given)
解决:
Libvirt启动失败,端口没看到。
# /etc/init.d/libvirtd restart
Stopping libvirtd daemon:
Starting libvirtd daemon: libcgroup initialization failed: Cgroup is not mounted
yum list libcgroup -y
vi /etc/cgconfig.conf
group virt {
cpu {
cpu.shares = 9216;
}
}
/etc/init.d/cgconfig restart
/etc/init.d/libvirtd restart
chkconfig cgconfig on
⑧、启动cloud-agent:
这里,不需要手动启动cloud-agent,当在manager上创建主机时,manager会自动启动cloud-agent的。
/etc/init.d/cloud-agent start
启动失败啊.
2014-09-29 05:54:34,892 INFO (main:null) id is
2014-09-29 05:54:35,044{GMT} INFO (main:) VirtualRoutingResource _scriptDir to use: scripts/network/domr/kvm
2014-09-29 05:54:35,044 INFO (main:null) VirtualRoutingResource _scriptDir to use: scripts/network/domr/kvm
2014-09-29 05:54:35,050{GMT} INFO (main:) ipassoc.sh found in /usr/lib64/cloud/agent/./scripts/network/domr/ipassoc.sh
2014-09-29 05:54:35,050 INFO (main:null) ipassoc.sh found in /usr/lib64/cloud/agent/./scripts/network/domr/ipassoc.sh
2014-09-29 05:54:35,649{GMT} INFO (main:) agent.properties found at /etc/cloud/agent/agent.properties
2014-09-29 05:54:35,649 INFO (main:null) agent.properties found at /etc/cloud/agent/agent.properties
2014-09-29 05:54:35,657{GMT} INFO (main:) Agent [id = new : type = LibvirtComputingResource : zone = default : pod = default : workers = 5 : host = 172.22.2.76 : port = 8250
2014-09-29 05:54:35,657 INFO (main:null) Agent [id = new : type = LibvirtComputingResource : zone = default : pod = default : workers = 5 : host = 172.22.2.76 : port = 8250
2014-09-29 05:54:35,665{GMT} INFO (Agent-Selector:) Connecting to 172.22.2.76:8250
2014-09-29 05:54:35,665 INFO (Agent-Selector:null) Connecting to 172.22.2.76:8250
2014-09-29 05:54:36,096{GMT} INFO (Agent-Selector:) SSL: Handshake done
2014-09-29 05:54:36,096 INFO (Agent-Selector:null) SSL: Handshake done
2014-09-29 05:54:36,312{GMT} INFO (Agent-Handler-1:) Default Builder inited.
2014-09-29 05:54:36,312 INFO (Agent-Handler-1:null) Default Builder inited.
2014-09-29 05:54:36,588{GMT} ERROR (Agent-Handler-2:) Not allowed to connect to the server: java.lang.IllegalArgumentException: Host 172.22.2.87 sent incorrect data center: default
2014-09-29 05:54:36,588 ERROR (Agent-Handler-2:null) Not allowed to connect to the server: java.lang.IllegalArgumentException: Host 172.22.2.87 sent incorrect data center: default
2014-09-29 05:54:36,591{GMT} INFO (AgentShutdownThread:) Stopping the agent: Reason = sig.kill
2014-09-29 05:54:36,591 INFO (AgentShutdownThread:null) Stopping the agent: Reason = sig.kill
⑨、卸载并清空/mnt目录:
一定要保证/mnt目录没有被使用,且目录为空,否则CloudStack无法对其挂载Primary Storage,新建实例,可能会失败,除非你有多个agent,/mnt已有的数据,请提前保存好。
umount /mnt
rm -rf /mnt/*
⑩、等待加入cloudstack:
到此cloudstack-agent就配置完成了,现在的cloudstack-agent可以在创建区域时加入,也可以在创建完区域后,手动加入,后面均有介绍。
页:
[1]