Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6885001
  • 博文数量: 3857
  • 博客积分: 6409
  • 博客等级: 准将
  • 技术积分: 15948
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-02 16:48
个人简介

迷彩 潜伏 隐蔽 伪装

文章分类

全部博文(3857)

文章存档

2017年(5)

2016年(63)

2015年(927)

2014年(677)

2013年(807)

2012年(1241)

2011年(67)

2010年(7)

2009年(36)

2008年(28)

分类: 虚拟化

2014-01-04 21:23:26

原文地址:fedora20 linux container试用 作者:minminmsn

Fedora20  lxc 试用


What's LXC? 
LXC is a userspace interface for the Linux kernel containment features. 
Through a powerful API and simple tools, it lets Linux users easily create and manage system or application containers. 


Features 
Current LXC uses the following kernel features to contain processes: 


Kernel namespaces (ipc, uts, mount, pid, network and user) 
Apparmor and SELinux profiles 
Seccomp policies 
Chroots (using pivot_root) 
Kernel capabilities 
Control groups (cgroups) 
As such, LXC is often considered as something in the middle between a chroot on steroids and a full fledged virtual machine. The goal of LXC is to create an environment as close as possible as a standard Linux installation but without the need for a separate kernel. 


Components 
LXC is currently made of a few separate components: 


The liblxc library 
Several language bindings (python3, lua and Go) 
A set of standard tools to control the containers 
Container templates


1,yum -y install lxc*



2,lxc宿主主机配置 
首先介绍几个文件夹(默认通过yum安装将自动生成以下文件/文件夹) 
1). /etc/lxc/default.conf 
创建容器时若未指定配置文件,则默认使用这个default.conf作为该容器的配置文件 

2). /usr/share/lxc/templates/ 
该目录下保存了LXC支持的各种发行版的linux模板,通常有: 

 

3). /var/lib/lxc/ 
这个目录是用来存放容器实例的,默认情况下该文件夹只有管理员才有权限访问读写其中文件 

4). /var/cache/lxc/ 
第一次创建容器,需要下载一最小化安装版的容器系统,很快就好了,创建好后,将会在该目录下创建缓存,再次创建直接采用缓存无须再网上下载.


3,检验lxc是否已安装好 
lxc-verison 
如果显示 lxc version: x.x.x表示安装成功。这里x表示版本号,我安装的是lxc version:0.9.0 
lxc-checkconfig 



4,lxc基本命令用法 
lxc-create -t oracle  -n o1
这里以lxc-oracle为模板,由于本机是fedora20,我发现还可以用lxc-fedora为模板,但是用lxc-ubuntu和lxc-debian时创建时不成功。
创建时需要比较长的时间先到镜像点下载对应镜像我这里是oracle


lxc-start  -n o1 
开启容器o1,用oracle用户名,oracle密码登陆


lxc-ls --fancy o1
查看容器基本信息


lxc-console -n o1
连接容器o1,这是lxc容器里面的基本操作,更单独机器差不多,除了网络单独分出来,cpu和内存共享主机的。


lxc-stop -n o1
停止容器o1 
还有其他命令,如想加深了解可以看man帮助

阅读(542) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~