[iyunv@agent2 ~]# mkfs.ext4 /dev/sdb
mke2fs 1.41.12 (17-May-2010)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
3276800 inodes, 13107200 blocks
655360 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
400 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[iyunv@agent2 ~]#
[iyunv@master1 ~]# mysql -uroot -p123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.1.73-log Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cloud |
| cloud_usage |
| mysql |
| test |
+--------------------+
5 rows in set (0.01 sec)
mysql> drop database cloud;
Query OK, 274 rows affected (1.34 sec)
mysql> drop database cloud_usage;
Query OK, 25 rows affected (0.09 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.00 sec)
mysql>
停止management服务
[iyunv@master1 ~]# /etc/init.d/cloudstack-management stop
Stopping cloudstack-management: [FAILED]
[iyunv@master1 ~]# /etc/init.d/cloudstack-management stop
Stopping cloudstack-management: [ OK ]
[iyunv@master1 ~]# /etc/init.d/cloudstack-management status
cloudstack-management is stopped
[iyunv@master1 ~]#
[iyunv@agent1 ~]# glusterfs -V
glusterfs 3.7.20 built on Jan 30 2017 15:39:27
Repository revision: git://git.gluster.com/glusterfs.git
Copyright (c) 2006-2013 Red Hat, Inc. <http://www.redhat.com/>
GlusterFS comes with ABSOLUTELY NO WARRANTY.
It is licensed to you under your choice of the GNU Lesser
General Public License, version 3 or any later version (LGPLv3
or later), or the GNU General Public License, version 2 (GPLv2),
in all cases as published by the Free Software Foundation.
[iyunv@agent1 ~]#
启动glusterd并设置开机启动(两个agent上操作)
[iyunv@agent1 ~]# /etc/init.d/glusterd start
Starting glusterd: [ OK ]
[iyunv@agent1 ~]# chkconfig glusterd on
[iyunv@agent1 ~]#
两台agent停止iptables
[iyunv@agent1 ~]# /etc/init.d/iptables stop
iptables: Setting chains to policy ACCEPT: nat mangle filte[ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
[iyunv@agent1 ~]# chkconfig iptables off
[iyunv@agent1 ~]#
gluster加入节点,并检查状态,在一台agent上操作即可
[iyunv@agent1 ~]# gluster peer probe agent2
peer probe: failed: Probe returned with Transport endpoint is not connected
[iyunv@agent1 ~]# gluster peer probe agent2
peer probe: success.
[iyunv@agent1 ~]# gluster peer status
Number of Peers: 1
Hostname: agent2
Uuid: 2778cb7a-32ef-4a3f-a34c-b97f5937bb49
State: Peer in Cluster (Connected)
[iyunv@agent1 ~]#
创建复制卷
开始操作
gv2是自定义的
[iyunv@agent1 ~]# gluster volume create gv2 replica 2 agent1:/export/primary agent2:/export/primary force
volume create: gv2: success: please start the volume to access data
[iyunv@agent1 ~]#
Volume Name: gv2
Type: Replicate
Volume ID: 3a23ab68-73da-4f1b-bc5c-3310ffa9e8b7
Status: Started
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: agent1:/export/primary
Brick2: agent2:/export/primary
Options Reconfigured:
performance.readdir-ahead: on
[iyunv@agent1 ~]#
gluster的东西至此完毕,继续之前的内容
CloudStack配置和用户界面操作
继续在master上如下初始化数据库的操作,导入数据
[iyunv@master1 ~]# cloudstack-setup-databases cloud:123456@localhost --deploy-as=root:123456
Mysql user name:cloud [ OK ]
Mysql user password:****** [ OK ]
Mysql server ip:localhost [ OK ]
Mysql server port:3306 [ OK ]
Mysql root user name:root [ OK ]
Mysql root user password:****** [ OK ]
Checking Cloud database files ... [ OK ]
Checking local machine hostname ... [ OK ]
Checking SELinux setup ... [ OK ]
Detected local IP address as 192.168.145.151, will use as cluster management server node IP[ OK ]
Preparing /etc/cloudstack/management/db.properties [ OK ]
Applying /usr/share/cloudstack-management/setup/create-database.sql [ OK ]
Applying /usr/share/cloudstack-management/setup/create-schema.sql [ OK ]
Applying /usr/share/cloudstack-management/setup/create-database-premium.sql [ OK ]
Applying /usr/share/cloudstack-management/setup/create-schema-premium.sql [ OK ]
Applying /usr/share/cloudstack-management/setup/server-setup.sql [ OK ]
Applying /usr/share/cloudstack-management/setup/templates.sql [ OK ]
Processing encryption ... [ OK ]
Finalizing setup ... [ OK ]
CloudStack has successfully initialized database, you can check your database configuration in /etc/cloudstack/management/db.properties
[iyunv@master1 ~]#
[iyunv@master1 tools]# /usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt \
> -m /export/secondary \
> -f /tools/systemvm64template-4.6.0-kvm.qcow2.bz2 \
> -h kvm -F
Uncompressing to /usr/share/cloudstack-common/scripts/storage/secondary/9824edc4-61db-4ad8-a08a-61f051b9ebfe.qcow2.tmp (type bz2)...could take a long time
Moving to /export/secondary/template/tmpl/1/3///9824edc4-61db-4ad8-a08a-61f051b9ebfe.qcow2...could take a while
Successfully installed system VM template /tools/systemvm64template-4.6.0-kvm.qcow2.bz2 to /export/secondary/template/tmpl/1/3/
[iyunv@master1 ~]#
[iyunv@agent1 ~]# cd /etc/sysconfig/network-scripts/
[iyunv@agent1 network-scripts]# ls ifcfg-cloudbr0
ifcfg-cloudbr0
[iyunv@agent1 network-scripts]# rm -f ifcfg-cloudbr0
[iyunv@agent1 network-scripts]# /etc/init.d/network restart
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: [ OK ]
[iyunv@agent1 network-scripts]#
[iyunv@master1 ~]# /etc/init.d/cloudstack-management restart
Stopping cloudstack-management: [FAILED]
Starting cloudstack-management: [ OK ]
[iyunv@master1 ~]# /etc/init.d/cloudstack-management restart
Stopping cloudstack-management: [ OK ]
Starting cloudstack-management: [ OK ]
[iyunv@master1 ~]#
重启过程中,日志有些报错,参照下。不用管
[iyunv@master1 ~]# tail -f /var/log/cloudstack/management/catalina.out
INFO [o.a.c.s.l.CloudStackExtendedLifeCycle] (Thread-85:null) (logid:) stopping bean VolumeDataStoreDaoImpl
INFO [o.a.c.s.l.CloudStackExtendedLifeCycle] (Thread-85:null) (logid:) stopping bean UsageDaoImpl
INFO [o.a.c.s.l.CloudStackExtendedLifeCycle] (Thread-85:null) (logid:) stopping bean ManagementServerNode
INFO [o.a.c.s.l.CloudStackExtendedLifeCycle] (Thread-85:null) (logid:) stopping bean ConfigurationServerImpl
INFO [o.a.c.s.l.CloudStackExtendedLifeCycle] (Thread-85:null) (logid:) stopping bean DatabaseIntegrityChecker
INFO [o.a.c.s.l.CloudStackExtendedLifeCycle] (Thread-85:null) (logid:) stopping bean ClusterManagerImpl
INFO [c.c.c.ClusterManagerImpl] (Thread-85:null) (logid:) Stopping Cluster manager, msid : 52236852888
log4j:WARN No appenders could be found for logger (com.cloud.cluster.ClusterManagerImpl).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "SnapshotPollTask" java.lang.NullPointerException
at org.slf4j.impl.Log4jLoggerAdapter.info(Log4jLoggerAdapter.java:304)
at org.apache.cloudstack.managed.context.ManagedContextRunnable.getContext(ManagedContextRunnable.java:66)
at org.apache.cloudstack.managed.context.ManagedContextRunnable.run(ManagedContextRunnable.java:46)
at org.apache.cloudstack.managed.context.ManagedContextTimerTask.run(ManagedContextTimerTask.java:27)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
Feb 12, 2017 8:50:21 PM org.apache.catalina.core.AprLifecycleListener init
Feb 12, 2017 8:50:22 PM org.apache.catalina.session.StandardManager doLoad
SEVERE: IOException while loading persisted sessions: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: net.sf.cglib.proxy.NoOp$1
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: net.sf.cglib.proxy.NoOp$1
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1354)
[iyunv@master1 ~]#
[iyunv@agent1 ~]# virsh list
Id Name State
----------------------------------------------------
1 v-2-VM running
[iyunv@agent1 ~]#
[iyunv@agent2 ~]# virsh list
Id Name State
----------------------------------------------------
1 s-1-VM running
[iyunv@agent2 ~]#
它的ip是192.168.145.180
agent1上目前是没有该虚拟机的
我们把它从agent2迁移到agent1上
[iyunv@agent1 ~]# virsh list
Id Name State
----------------------------------------------------
1 v-2-VM running
[iyunv@agent1 ~]#
先ping着,那边做迁移,看看会不会丢包
提示迁移完毕
有少量丢包
64 bytes from 192.168.145.180: icmp_seq=132 ttl=64 time=2.97 ms
64 bytes from 192.168.145.180: icmp_seq=133 ttl=64 time=0.830 ms
64 bytes from 192.168.145.180: icmp_seq=134 ttl=64 time=0.640 ms
64 bytes from 192.168.145.180: icmp_seq=135 ttl=64 time=0.850 ms
64 bytes from 192.168.145.180: icmp_seq=136 ttl=64 time=1.43 ms
^C
--- 192.168.145.180 ping statistics ---
136 packets transmitted, 132 received, 2% packet loss, time 135432ms
rtt min/avg/max/mdev = 0.447/1.331/8.792/1.268 ms
[iyunv@master1 ~]#
已经迁移完毕了
[iyunv@agent1 ~]# virsh list
Id Name State
----------------------------------------------------
1 v-2-VM running
3 s-1-VM running
[iyunv@agent1 ~]#
迁移原理,在新的host上创建虚拟机,只不过是挂起的,拷贝硬盘数据和内存数据过去
迁移完毕,起来。
网络一定要快,不丢包
这是kvm自带的功能,只是用界面把底层命令封装了 自定义虚拟机配置方案
你可以添加自定义的kvm配置套餐
先看看自己虚host的cpuinfo
看到2200mhz
[iyunv@agent1 ~]# cat /proc/cpuinfo | head -10
processor: 0
vendor_id: GenuineIntel
cpu family: 6
model: 42
model name: Intel(R) Core(TM) i7-2670QM CPU @ 2.20GHz
stepping: 7
microcode: 26
cpu MHz: 2192.909
cache size: 6144 KB
physical id: 0
[iyunv@agent1 ~]#