测试环境,下面二者之一CentOS-6.5-x86_64-minimal.isoCentOS-7-x86_64-Minimal-1511.iso第一步系统检测与优化,即初始化工作,常规型的rpm -qa|wc -lip addrping qq.comcat /var/log/boot.log以下是c65的关闭ipv6与防火墙CentOS-6.5-x86_64-minimal.isosed -i '$a\alias net-pf-10 off \nalias ipv6 off' /etc/modprobe.d/dist.confgrep 'ipv6' /etc/modprobe.d/dist.confchkconfig --level 2345 ip6tables offchkconfig --level 2345 iptables offchkconfig --list|grep iptablesservice iptables stopservice ip6tables stop最小化安装是没有防火墙服务的CentOS-7-x86_64-Minimal-1511.iso[root@localhost ~]# cat /etc/redhat-releaseCentOS Linux release 7.2.1511 (Core)[root@localhost grub2]# vi /etc/default/grub将GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet"改为GRUB_CMDLINE_LINUX="ipv6.disable=1 rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet"即加上ipv6.disable=1,再重新生成grub.cfg,再重启系统就可以了[root@localhost grub2]# grub2-mkconfig -o /boot/grub2/grub.cfgGenerating grub configuration file ...Found linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64Found initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.imgFound linux image: /boot/vmlinuz-0-rescue-1ace541fd97c40e6a45fd1f7062adae8Found initrd image: /boot/initramfs-0-rescue-1ace541fd97c40e6a45fd1f7062adae8.imgdonecp /etc/selinux/config ./sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/configdiff config /etc/selinux/configsetenforce 0下面是c65中要设置的,c72可能不需要下面了。sed -i 's/tty\[1-6\]/tty\[1-2\]/g' /etc/init/start-ttys.confsed -i 's/tty\[1-6\]/tty\[1-2\]/g' /etc/sysconfig/initreboot第二步具体某项应用与功能,任务型的1.安装lxc,cs6.5环境下yum install epel-releaseyum install lxclxc-checkconfig //一开始检测,某些项是missing状态的rpm -ql lxc|morerpm -ql lxc-libs|moreyum install libcgroup //无依赖yum install lxc-templatesservice cgconfig startservice lxc start启动之后,在/cgroup目录下产生了很多目录与文件
安装lxc,cs7.2环境下
yum install epel-release
yum install lxc lxc-templates bridge-utilslxc-checkconfiglxc-create -n testA -t fedora以下是手工设置,永久生效cp /etc/sysconfig/network-scripts/ifcfg-eno1 /etc/sysconfig/network-scripts/ifcfg-br0vi /etc/sysconfig/network-scripts/ifcfg-eno1vi /etc/sysconfig/network-scripts/ifcfg-br0以下是临时生效,通过工具修改yum install bridge-utilsbrctl addbr br0brctl addif br0 eno1ip addr del 192.168.10.101/24 dev eno1ip addr add 192.168.10.101/24 dev br0ip link set br0 uprebootvi /var/lib/lxc/testA/config修改virbr0为br0lxc-start -n testA -dlxc-console -n testA -t 32.扫描网段,并登入某台linux机器,查看硬件与系统配置yum install --disablerepo=epel nmap或者直接下面的yum install nmapnmap 192.168.10.0/24ssh 192.168.10.45lscpucat /proc/cpuinfoyum install pciutilslspci3.抓包yum install tcpdump4.cobbler
5.kvm cs7.2环境下
安装gnome桌面后
systemctl disable NetworkManagersystemctl disable firewalld
vi /etc/selinux/configrebootyum install virt-manager
只需要安装上面这一个包就可以了,然后在打开virt-manager,在连接细节里》网络接口下添加桥网络就可以了,然后创建虚拟机,不需要在命令行下修改ifcfg-eth0,ifcfg-br0,还有brctl都不需要做。
[root@kvm1 img]# vi /etc/sysconfig/network-scripts/ifcfg-eno1 TYPE=EthernetDEVICE=eno1ONBOOT=yesBRIDGE=br0[root@kvm1 img]# vi /etc/sysconfig/network-scripts/ifcfg-br0 TYPE=BridgeDEVICE=br0ONBOOT=yesIPADDR=192.168.10.101PREFIX=24GATEWAY=192.168.10.6DNS1=8.8.8.8systemctl restart networksed -i 's/virbr0/br0/g' /etc/qemu-kvm/bridge.confmkdir iso,diskcd disk;qemu-img create -f qcow2 ub.qcow2 10G/usr/libexec/qemu-kvm -boot order=dc -hda disk/ub.qcow2 -cdrom iso/edubuntu-14.04.4-dvd-amd64.iso -m 1024 -smp 2 -net bridge -net nic -spice port=9987,password=12345然后通过windows机器上的spice客户端连上去进行安装步骤。
/usr/libexec/qemu-kvm -boot order=dc -hda disk/ub.qcow2 -m 1024 -smp 1 -net bridge -net nic -display vnc=:1,passwd='12345'
这是用vnc的方式去连接管理,好像不需要passwd这个参数,直接vnc就可以连上去。/usr/libexec/qemu-kvm -boot order=dc -hda disk/cs72-mysql.qcow2 -cdrom iso/CentOS-7-x86_64-Minimal-1511.iso -m 4096 -smp 2 -net bridge -net nic -vnc :1
/usr/libexec/qemu-kvm -boot order=dc -hda disk/cs72-mysql.qcow2 -m 4096 -smp 2 -net bridge -net nic -vnc :1
6.mysql主-从备份
主-主备份,首先AB机要保持数据一致,即先手工备份A机数据,然后在B机上恢复,之后就很简单了,只需要在B机上创建一个同步账号,并在A机上输入B机的那些参数然后启动slave start就实现了主-主双机热备。
主-从复制如下:
A:192.168.10.119:masterB:192.168.10.118:slave参数说明:需要同步的库名,多个用逗号隔开。binlog-do-db=world,city不需要同步的库名binlog-ignore-db=mysqlMYSQL_A作为主机,MYSQL_B作为从机。在MYSQL_A和MYSQL_B上分别创建好需要同步的数据库在A机上操作
vi /etc/my.cnf在mysqld中加入下面server-id=1log-bin=masbinlog-do-db=worldbinlog-ignore-db=mysqlservice mysqld restart同步账号GRANT REPLICATION SLAVE ON *.* TO 'syn'@'192.168.10.118' IDENTIFIED BY '123456';先导入数据mysql < world.sql再锁表FLUSH TABLES WITH READ LOCK;再导出数据mysqldump -uroot -p world >world1.sqlmysql> show master status;+------------+----------+--------------+------------------+| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |+------------+----------+--------------+------------------+| mas.000002 | 260 | world | mysql |+------------+----------+--------------+------------------+1 row in set (0.00 sec)这里的文件名与位置要在slave中输入。再释放锁unlock tables;在B机上操作server-id=2log-bin=slabinlog-do-db=worldbinlog-ignore-db=mysqlservice mysqld restart先将A机上备份的数据world1.sql导入进来,还原数据,保证二者之间的数据一致。设置主服务器的参数mysql> change master to -> MASTER_HOST='192.168.10.119', -> MASTER_USER='syn', -> MASTER_PASSWORD='123456', -> MASTER_CONNECT_RETRY=60, -> MASTER_LOG_FILE='mas.000002', -> MASTER_LOG_POS=260;Query OK, 0 rows affected (0.19 sec)slave start;show slave status\G;下面是做测试,在A机上删除数据,mysql> delete from City where id<10;Query OK, 6 rows affected (0.07 sec)mysql> show master status;在B机上查看,很快就同步过来了。msyql> show slave status\G;