Virtualization Basic Notes
How to read paper
- abstract, introduction, related works, conclusion
- reference
- paper refers it (by Google Scholar)
LXC
Linux Namespaces
LXC 所实现的隔离性主要是来自内核的命名空间
- PID Namespace: 隔离进程
- Network Namespace: 隔离网络
- IPC Namespace: 隔离消息
- Mount Namespace: 隔离文件系统
- UTS Namespace: 隔离 hostname
- Users Namespace
package main
import (
"log"
"os"
"os/exec"
"syscall"
)
func main() {
switch os.Args[1] {
case "run":
run()
case "child":
child()
default:
log.Fatal("Invalid command")
}
}
func run() {
cmd := exec.Command("/proc/self/exe", append([]string{"child"}, os.Args[2:]...)...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.SysProcAttr = &syscall.SysProcAttr {
CloneFlags: syscall.CLONE_NEWUTS | syscall.CLONE_NEWPID
| syscall.CLONE_NEWNS | syscall.CLONE_NEWUSER,
Credential: &syscall.Credential{Uid: 0, Gid: 0},
UidMappings: []syscall.SysProcIDMap{
{ContainerID: 0, HostID: os.Getuid(), Size: 1},
},
GidMappings: []syscall.SysProcIDMap{
{ContainerID: 0, HostID: os.Getgid(), Size: 1},
},
}
must(cmd.Run())
}
func child() {
log.Printf("running %v as PID %d\n", os.Args[2:], os.Getpid())
// cg()
cmd := exec.Command(os.Args[2], os.Args[3:]...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
must(syscall.Sethostname([]byte("mocker")))
must(syscall.Chroot("/home/sabertazimi/rootfs"))
must(syscall.Chdir("/"))
must(syscall.Mount("proc", "proc", "proc", 0, ""))
must(cmd.Run())
must(syscall.Unmount("proc", 0))
}
func must(err error) {
if err != nil {
log.Fatal(err)
}
}
chroot
must(syscall.Chroot("/home/sabertazimi/rootfs"))
must(syscall.Chdir("/"))
must(syscall.Mount("proc", "proc", "proc", 0, ""))
Control Groups
cgroups
, resources limitation:
CPU, Memory, Disk I/O,
Process numbers, Network, Device.
func cg() {
cgroups := "/sys/fs/cgroup/"
pids := filepath.Join(cgroups, "pids")
os.Mkdir(filepath.Join(pids, "sabertazimi"), 0755)
must(ioutil.WriteFile(filepath.Join(pids, "sabertazimi/pids.max"),
[]byte("20"), 0700))
must(ioutil.WriteFile(filepath.Join(pids, "sabertazimi/notify_on_release"),
[]byte("1"), 0700))
must(ioutil.WriteFile(filepath.Join(pids, "sabertazimi/cgroup.procs"),
[]byte(strconv.Itoa(os.Getpid())), 0700))
}
大数据处理典型问题:
- 数据一致性问题
- 数据容错与恢复问题
- 节点通信问题
- 能耗问题
In-Memory Computing Thesis Notes
内存计算特点:
- 硬件: 大内存
- 软件: 良好编程模型和编程接口
- 面向数据密集型应用: 数据规模大, 实时性要求高
- 大多支持并行处理数据
内存计算分类:
- 单节点
- 分布式集群
- 新型混合内存 (Hybrid Memory)
单节点内存计算
节点拥有 1/n 个处理器(单/多核) + 共享内存 (Shared Memory)