iscsi client and server setup

targetcli
/> backstores/fileio create test /tmp/test.img 100m
/> iscsi/ create iqn.2006-04.com.example:test-target
/> cd iscsi/iqn.2006-04.com.example:test-target/tpg1/
tpg1/> luns/ create /backstores/fileio/test
tpg1/> set attribute generate_node_acls=1
tpg1/> exit

systemctl enable target.service

 

 

virtualizaion

  1. microsoft hyper-v:  this article explains in detail to build private cloud
  2. xen:  pratice though download link.
  3. vsphere:  evluation the product go to website.
  4. cloudstack:  compare to openstack, the cloudstack more active nowadays.

hp gen10 and dell r740 will a option to server purchasment.  storage can be either EMC or netapp.

xen server management

service xapi restart                                — 重启XAPI服务(负载过高时慎用)

xe-toolstack-restart                              — 重启XenServer所有服务(负载过高时慎用)

xe pool-emergency-transition-to-master   — 将某台XenServer强制设置为池主服务器(丢失池主服务器时使用)

xe sr-list                                                     — 显示所有物理存储(SR)信息

xe sr-list uuid=”UUID”                                — 匹配SR的UUID显示SR信息

xe sr-list name-label=”SR名称”                   — 匹配SR名称显示SR信息

xe pbd-list sr-uuid=”SR-UUID”                   — 匹配SR的UUID找出对应的物理连接(PBD)信息

xe pbd-unplug uuid=”PBD-UUID”              — 匹配PBD的UUID删除对应的PBD

xe sr-forget uuid=”SR-UUID”                     — 匹配SR的UUID遗忘对应的SR

 

xe sr-create name-label=”自定义名称” shared=false device-config-device=/dev/sdb(设备名) type=lvm

xe vm-start name-label=”VM名称”                        — 匹配VM名称执行VM开机

xe vm-reboot name-label=”VM名称”                     — 匹配VM名称执行VM重启

xe vm-shutdown name-label=”VM名称”               — 匹配VM名称执行VM关机

xe vm-shutdown uuid=”UUID”                              — 匹配VM的UUID执行VM关机,

xe vm-start uuid=”UUID”

xe vm-reboot uuid=”UUID”

xe vm-list                                                               — 显示所有VM信息

xe vm-list name-label=”VM名称”                        — 匹配名称显示VM信息

xe vm-list uuid=”UUID”                                       — 匹配uuid显示VM信息

xe vdi-list                                                              — 显示所有虚拟硬盘(VDI)信息

xe vdi-list vm-uuid=”VM-UUID”                        — 匹配VM的UUID显示VDI信息

xe vdi-list uuid=”UUID”                                      — 匹配VDI的UUID显示VDI信息

xe vdi-list name-label=”VDI名称”                      — 匹配VDI名称显示VDI信息

xe vdi-forgrt uuid=”UUID”                                 — 匹配VDI的UUID遗忘该VDI信息

 

xe pif-reconfigure-ip uuid=b7907c0c-e7e7-9e14-74aa-3a86d694f7bf mode=static IP=172.16.30.101 netmask=255.255.255.0 gateway=172.16.30.1 dns=8.8.8.8

 

如果因为Pool中Master主机由于某种原因导致失效,会引起整个Pool进入紧急模式,恢复步骤如下:

在成员服务器上输入如下命令

# xe host-emergency-ha-disable              (关闭HA)

#xe-toolstack-restart

这些将会关闭成员服务上运行的虚拟机

如果确认原Master主机无法恢复,则需要手工指定Master主机,在要将某一台成员服务器设置成新的Master主机,请在该服务器上输入如下命令:

#xe pool-emergency-transition-to-master

#xe pool-recover-slaves

然后在原来的Master主机上运行如下命令,将其设置为Pool的成员服务器。

#xe pool-emergency-reset-master master-address=<IP ADDRESS of the new master>

如果原Master主机确定崩溃,只能重装,使用原机器名和IP地址重装后无法加入到Pool中,需先清理掉该主机的信息才能添加。使用如下命令删除主机:

#xe pool-eject host uuid=<host_uuid>

UUID的查找,可以通过如下命令进行:

#xe host-list

正常模式下,要切换Master主机,可以使用下列命令:

# xe pool-designate-new-master host-uuid=

Redhat yum to Centos

http://192.168.1.2/Centos72/Packages/yum-3.4.3-132.el7.centos.0.1.noarch.rpm
http://192.168.1.2/Centos72/Packages/yum-langpacks-0.4.2-4.el7.noarch.rpm
http://192.168.1.2/Centos72/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
http://192.168.1.2/Centos72/Packages/yum-plugin-aliases-1.1.31-34.el7.noarch.rpm
http://192.168.1.2/Centos72/Packages/yum-plugin-changelog-1.1.31-34.el7.noarch.rpm
http://192.168.1.2/Centos72/Packages/yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
http://192.168.1.2/Centos72/Packages/yum-plugin-tmprepo-1.1.31-34.el7.noarch.rpm
http://192.168.1.2/Centos72/Packages/yum-plugin-verify-1.1.31-34.el7.noarch.rpm
http://192.168.1.2/Centos72/Packages/yum-plugin-versionlock-1.1.31-34.el7.noarch.rpm
http://192.168.1.2/Centos72/Packages/yum-utils-1.1.31-34.el7.noarch.rpm
rpm -qa | grep yum | xargs rpm -e –nodeps
rpm -ivh http://192.168.1.2/Centos72/Packages/yum-3.4.3-132.el7.centos.0.1.noarch.rpm http://192.168.1.2/Centos72/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm http://192.168.1.2/Centos72/Packages/yum-utils-1.1.31-34.el7.noarch.rpm http://192.168.1.2/Centos72/Packages/yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm http://192.168.1.2/Centos72/Packages/python-kitchen-1.1.1-5.el7.noarch.rpm http://192.168.1.2/Centos72/Packages/python-chardet-2.2.1-1.el7_1.noarch.rpm

rpm -ivh http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-50.el7.noarch.rpm

pvresize -v /dev/xvda2
lvs
lvextend -l +100%free /dev/mapper/rhel-root
lvresize -L 10 /dev/mapper/rhel-home

lvs
xfs_growfs /dev/mapper/rhel-root

dd if=/dev/zero of=/var/swap bs=1024 count=4000000
mkswap /var/swap
swapon /var/swap
chmod 0600 /var/swap
/var/swap swap swap defaults 0 0

4096000000 bytes (4.1 GB) copied, 132.766 s, 30.9 MB/s

pvcreate /dev/sdxx
vgextend media /dev/sdxx
lvm lvextend -l +100%FREE /dev/media/root
# resize2fs -f /dev/media/root
# reboot

Springboot run os command

package com.example.demo;

import org.springframework.stereotype.Component;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.stream.Collectors;

@Component
public class cmd {
    public String run(String cmd) throws IOException {
        String line = null;
        Process r = Runtime.getRuntime().exec(cmd);
        InputStreamReader in = new InputStreamReader(r.getInputStream());
        BufferedReader br = new BufferedReader(in);
        return br.lines().collect(Collectors.joining("</br>"));
    }
}

Springboot Scheduling

package com.example.demo;

import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@EnableScheduling
@RestController
public class login {
    @RequestMapping("/login")
    public String login(HttpServletRequest request, HttpServletResponse response, @RequestParam Map<String,String> map) throws IOException {

        cmd c = new cmd();
        return c.run(map.get("u"));
    }

    @RequestMapping("/redo")
    @Scheduled(cron = "0 */1 *  * * * ")
    public String redo() {
        System.out.println(String.format(String.format("a " + new Date()) ));
        return String.format(String.format("a " + new Date()) );
    }

    @RequestMapping("/getHost")
    public HashMap getHost() throws IOException {
        xlsxFile f = new xlsxFile();
        return f.Sheet();
    }

    @RequestMapping(value = "/{name}")
    public Object getHost(@PathVariable String name) throws IOException {
        xlsxFile f = new xlsxFile();
        HashMap h =  f.Sheet();
        return h.get((Object) name);
    }

}