cloudstack +xenserver 安裝部署

abin1703發表於2016-01-07


cloudstack 4.4 +xenserver 安裝部署






一、所有節點配置






1、關閉防火牆


vi /etc/sysconfig/iptables


# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
COMMIT




service iptables stop
chkconfig iptales off


2、關閉selinux


vi /etc/selinux/config


SELINUX=disabled


重啟伺服器
reboot -h 0




3、修改主機名稱
vi /etc/sysconfig/network


NETWORKING=yes
HOSTNAME=nfs.abc.com


4、修改hosts檔案


vi /etc/hosts


192.168.111.20 manger.abc.com
192.168.111.21 nfs..abc.com
192.168.111.22 xenserver01.abc.com




5、配置ntp服務


yum install -y ntp


vi /etc/ntp.conf


server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10


service ntpd start
chkconfig ntpd on


6、修改/etc/idmapd.conf其中的Domain,使得叢集中的所有機器的Domain相同
# vi /etc/idmapd.conf
Domain = crdar.priv






二、nfs伺服器的配置


1、檢視是否已經安裝相關軟體




# rpm -qa |grep nfs
nfs-utils-1.2.3-39.el6.i686


# rpm -qa |grep rpcbind
rpcbind-0.2.0-11.el6.i686




yum install -y nfs rpcbind




2、修改/etc/sysconfig/nfs
# vi /etc/sysconfig/nfs 


... 
  
LOCKD_TCPPORT=32803 
  
LOCKD_UDPPORT=32769 
  
MOUNTD_PORT=892 
  
RQUOTAD_PORT=875 
  
STATD_PORT=662 
  
STATD_OUTGOING_PORT=2020 






3、啟動服務並設為開機啟動



service nfs start
service rpcbind start
chkconfig rpcbind on
chkconfig nfs on


確認nfs服務是否啟動成功
# rpcinfo -p








4、配置掛在的磁碟




如:


# mkdir /primary
# mkdir /secondary


賦予2目錄寫許可權
# chmod 777 /primary
# chmod 777 /secondary


5、編輯配置/etc/exports
# vi /etc/exports
/primary *(rw,async,no_root_squash,no_subtree_check)
/secondary *(rw,async,no_root_squash,no_subtree_check)


注:可以吧一級儲存放在管理節點,需要配置nfs檔案,並且配置/etc/exports,新增/primary *(rw,async,no_root_squash,no_subtree_check)




重新全部掛載內容
# exportfs -a




8、重啟服務

service nfs restart
service rpcbind restart


# vi /etc/idmapd.conf
Domain = cedar.priv








三、xenserver






透過 ssh 登入到 xenserver 主機


1、調整DOM0記憶體值


//備份配置檔案
# cp /boot/extlinux.conf /boot/extlinux.conf.bak20150113


修改dom0_mem值為2940M或者更大(最大不超過4G)
# sed  -i '10s/dom0_mem=752M/dom0_mem=2940M/g' /boot/extlinux.conf


修改完成之後,重啟系統
# reboot




修改檔案許可權為722
# chmod 722 /etc/xensource-inventory




2、如果該 主機所在的 CloudStack  的 zone 使用 的是基本網路,則需要禁用OpenVswitch(OVS) 


# xe-switch-network-backend bridge


出現 You *MUST* now reboot your system 表示完成


重新啟動後OK




四、管理節點




cloudstack軟體庫
系統模板


0、安裝yum-fastestmirror外掛,自動選擇最快的yum源
# yum -y install yum-fastestmirror


0-1、升級系統
# yum update




1、修改主機名稱
修改/etc/hosts和/etc/sysconfig/network檔案
# vi /etc/hosts
192.168.111.20 manger.cedar.priv manger
192.168.111.21 nfs.cedar.priv nfs
192.168.111.22 xenserver01.cedar.priv xenserver01


# vi /etc/sysconfig/network
HOSTNAME=manger.cedar.priv


檢查方法: 
# hostname
# hostname --fqdn




2、SElinux 僅顯示警告資訊,不阻止
# vi /etc/selinux/config
#SELINUX=enforcing  //註釋掉
SELINUX=permissive  //加入此行


檢查方法:
# sestatus




3、安裝ntp伺服器
首先檢視時間及時區
# date -R; date +%z
Fri, 19 Oct 2012 23:34:27 +0800  
+0800  
主要就是後面的+0800,東八區


設定日期
# date -s 20121019
設定時間
# date -s 23:40:00
設定時區
# cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime




安裝ntp
# yum install ntp -y
修改/etc/ntp.conf檔案,加入下面3行


restrict 192.168.111.0 mask 255.255.255.0 nomodify notrap //允許內網其他機器同步時間


server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10


配置ntp服務自啟動
# chkconfig ntpd on
檢視啟動配置情況
# chkconfig --list ntpd


新增ntp的123埠到防火牆



iptables  -I INPUT -p udp -m udp --dport 123 -j ACCEPT


# service iptables save; service iptables restart




ntpq -p 檢視網路中的NTP伺服器,同時顯示客戶端和每個伺服器的關係


# ntpq -p


注意reach指要大於17以上才有更新同步。




4、配置cloudstack軟體庫
# vi /etc/yum.repos.d/cloudstack.repo
[cloudstack]
name=cloudstack
baseurl=
enabled=1
gpgcheck=0


或者配置cloudstack軟體庫為區域網源
# vi /etc/yum.repos.d/cloudstack.repo
[cloudstack]
name=cloudstack
baseurl=http://192.168.111.251/cloudstack4.4.2/
enabled=1
gpgcheck=0




5、安裝mysql
# yum -y install mysql-server
修改/etc/my.cnf檔案
在[mysqld]下面新增下列引數
# vi /etc/my.cnf
innodb_rollback_on_timeout=1
innodb_lock_wait_timeout=600
max_connections=350
log-bin=mysql-bin
binlog-format = 'ROW'


啟動mysql並設定開機自啟動

service mysqld start
chkconfig mysqld on


新增mysql的3306埠到防火牆
# iptables  -I INPUT -p tcp -m tcp --dport 3306 -j ACCEPT
# service iptables save; service iptables restart


或者直接關閉防火牆
# service iptables stop
# chkconfig iptables off
檢視防火牆關閉狀態
# service iptables status


設定mysql密碼
# mysqladmin -u root password 123456


開啟mysql遠端連線
在mysql控制檯中輸入如下命令
# grant all privileges on *.* to 'root'@'%' identified by '123456';
# flush privileges;
# exit




6、安裝cloudstack
# yum -y install cloudstack-management




下載vhd-util
# wget
# mv vhd-util /usr/share/cloudstack-common/scripts/vm/hypervisor/xenserver




/etc/idmapd.conf其中的Domain,使得叢集中的所有機器的Domain相同
# vi /etc/idmapd.conf
Domain = cedar.priv




安裝完成後重啟伺服器




使用 cloudstack-setup-databases 初始化 ClouStack 資料庫
# cloudstack-setup-databases cloud:123456@localhost --deploy-as=root:123456 -e file -m 123456 -k 123456
直至出現“CloudStack has successfully initialized database, you can check your database configuration in /etc/cloud/management/db.properties”表明雲平臺資料庫初始化成功。
安裝啟動管理伺服器


# cloudstack-setup-management




掛載NFS目錄
查詢伺服器NFS目錄
# showmount -e 192.168.111.21


在/下建立目錄
# mkdir /secondary


掛載secondary目錄
# mount -t nfs 192.168.111.21:/secondary /secondary


檢視是否掛載成功
# df -h




在cloudstack管理節點中匯入KVM、xenserver系統模板檔案
# /usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt -m /secondary -u http://192.168.111.251/systemvm/systemvm64template-4.4.1-7-xen.vhd.bz2 -h xenserver -F


/usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt -m /secondary -u systemvm64template-4.4.1-7-kvm.qcow2.bz2 -h kvm -F
/usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt -m /secondary -f systemvm64template-4.4.1-7-xen.vhd.bz2 -h xenserver -F


解除安裝掛載的NFS
# umount /secondary


刪除目錄
# rm -rf /secondary


重啟cloudstack服務
# service cloudstack-management restart


重啟服務後,重啟伺服器。




開啟瀏覽器,訪問控制節點 http://192.168.111.20:8080/client/ 就會看到登入介面,預設使用者名稱和密碼是 admin/password,登入後修改密碼、做一些配置後就可以開始用了


在全域性設定中將
secstorage.allowed.internal.sites
將其值設定為二級儲存的 IP 地址或者二級儲存所在的網段,將其設定為其所在的網段:10.84.80.0/24


修改銷燬的虛擬機器的存在時間為30s
點選“全域性設定“,在查詢處查詢“expunge”,分別修改”expunge .delay“和”expunge.interval”由原來的”86400“為”30“


//下面可以不使用
修改system.vm.use.local.storage,使得false為true,這個表示,允許使用xenserver本地的儲存作為虛擬機器的硬碟,因為在一臺主機安裝完xenserver後,發現其“巨大”的磁碟空間可使用量為0,全部被xenserver隱藏了,為了不浪費空間,我們允許使用本地硬碟,這樣也能減輕虛擬機器硬碟使用nfs所產生的網路負載。






五、製作http ISO映象站點


1、安裝Apache
yum install httpd


2、修改配置檔案


vi /etc/httpd/conf/httpd.conf 


取消如下行註釋並修改如下內容 
ServerName IP:80


注:IP只得是本地IP地址


3、重啟httpd服務
service httpd start
service httpd on 


4、上傳  ISO 檔案到/var/www/html


5、修改/etc/mime.types檔案


vi /etc/mime.types


# MIME type                                     Extensions
none/none                                       iso


6、重啟httpd服務


service httpd restart




7、訪問
例如:



注:CentOS-6.5-x86_64-bin-DVD1.iso是上傳/var/www/html目錄下的映象






















































































































來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30345407/viewspace-1973386/,如需轉載,請註明出處,否則將追究法律責任。