转:http://www.senra.me/add-tun-tap-support-for-proxmox-ve-4-lxc-containers/

一.为什么

Proxmox VE 4将3代的OpenVZ支持去除换成了LXC,算是跟随趋势吧,但是LXC和OpenVZ还是有挺多不同的,在权限上更是如此,而网上最多的还是OVZ相关的教程,LXC的是真的少,不过一直以来没需求,所以没怎么折腾,最近在搞内网,所以为了用Tunnel还是得把TUN/TAP支持打开。

二.怎么办

首先当然是谷歌咯,关键词选得好马上出结果,proxmox官方论坛讨论贴 https://forum.proxmox.com/threads/tun-devices-in-ve-4-lxc.23473

总结一下

①.如果需要对所有(之后创建的)LXC容器全部开启tun/tap

那么需要修改/etc/lxc/default.conf,添加lxc.cgroup.devices.allow = c 10:200 rwm

当然,也可以创建/usr/share/lxc/config/common.conf.d/02-tuntap.conf 这样的配置文件来取得同样的效果

②.而如果只要对指定容器有效,则需要修改/etc/pve/lxc/[ID].conf , [ID]为你的容器编号

还没完,这样只是给了权限,实际上还没好,需要在容器的/etc/rc.local 自启动文件中添加如下

这样你执行需要tun/tap的程序时就不会出问题了

三.附录(记如何在v3版本的ovz下开启tun/tap)

a. 编辑vz.conf文件,添加iptable_nat ipt_state这2个东西

b. 手动关闭所有小鸡,重启openvz模块
/etc/init.d/vz restart

c. 对小鸡进行必要的设置(这里以小鸡100为例,100是指PID,WEB控制面板里可以看到)

d. 母鸡加载一次这些

e. 启动小鸡输入以下命令

Vultr是一家提供日本、美国、欧洲等多个国家和地区机房的VPS主机商,硬盘都是采用SSD,VPS主机都是KVM架构,VPS配置最少的内存768MB、硬盘为15GB的VPS只要5美元/月,vultr是根据时长来扣费的,使用多长时间就算多长时间,扣对应的款。

Vultr VPS新注册用户赠送50美元优惠活动(可免费使用VPS时间为2个月)

Vultr针对新用户的优惠又来了!! 这次直接注册即送50美金使用60天。60天后50美金自动失效! 本次活动需要信用卡或者或者paypal付款!paypal付款需要充值五美元,信用卡付款则会扣除2.5美元预授权费用(只是预授权,之后钱会回到你的信用卡的)。 2016年1月开始,vultr再次升级月流量,最低配置从原先的400GB增加到目前的1000GB,可以说非常超值,另外vultr 打算2016年一季度在亚洲扩充一个机房数据中心,目前选择是中国香港,韩国首尔,新加坡中的一个,所以,为了避免linode机房那种新用户限制选择东京机房的政策,如果未来有打算使用vultr上面机房数据中心的,建议现在就先注册好账号。

2016.4.7更新 vultr优惠码:NGINX20    新注册用户免费赠送20刀,有效期1年时间!

此外,Vultr VPS除了赠送50美元两个月的计划外,其他的计划都在打8折!无需输入优惠码! (vultr 是禁止用户重复注册账号的,即如果你的支付信息有2个账号在使用,那么你的账户会被关闭)

下面给出具体教程(2016.3.2vultr官网更新,本教程也相应更新):

点击这里查看官网:地址直达

3201

活动地址:http://www.vultr.com/freetrial/

注意:这个是一个新注册用户的优惠活动,所以需要新的账户。点击Sign Up and get $50 for free

3202

vultr 是禁止用户重复注册账号的,即如果你的支付信息有2个账号在使用,那么你的账户会被后台关闭的。简单的说就是一个账户的支付信息比如paypal 账号是对应唯一的一个的,如果你再次使用这个paypal支付另外一个新注册的账号的话,那么账户就会被关闭。所以,重复的注册账号是不可取的。

特别提醒

有部分朋友出现购买vultr的VPS在使用几天甚至付款验证后账户就被关闭,主要原因vultr 是禁止用户重复注册账号的,即如果你使用的paypal或者信用卡已经绑定了Vultr其他账号,那么你新注册的账户会被后台关闭的。简单的说就是一个账户的支付信息比如paypal 账号是对应唯一的一个的,如果你再次使用这个paypal支付另外一个新注册的账号的话,那么账户就会被关闭。所以,重复的注册账号是不可取的。

一 选择信用卡支付

填写信用卡信息,这个预扣款$2.5美元,后面会返还。另外使用优惠码 :NGINX20 可以获得vultr赠送的20美元一年使用权。

3203

这里一个很好的建议是你充值$10美元,防止你被误判恶意使用,如果你使用优惠码NGINX20 ,会被人工审核。这样你就可以免费使用VPS期限7个月了。

二 Paypal支付Vultr (仅限paypal 支付查看,信用卡支付的请忽略)

如果说你没有信用卡,但是你有Paypal 账号,那么你需要先点击上面的Expires 60Days From Today 后面的Remove按钮(谨慎操作,Vultr只给一次机会,选择信用卡的同学切勿选择,本操作仅限paypal支付同学使用 ),输入优惠码 NGINX20 获得20美元一年的使用权。

4701

三 服务器创建

账单信息确认完成,我们就可以点击右侧的3206 Deploy New Server  建立VPS了。

硬盘默认

服务器选择日本 东京(目前日本线路比较绕,选择洛杉矶比较好)

操作系统默认

服务器配置:默认即可。

其他信息默认即可。

点击 place order ,生成一个新VPS。

3207 3208 3209

进入 Servers ,稍等片刻服务器信息就生成了。

3212

点击 Cloud Instance 进行管理。

3211

Vultr 的这个控制面板还是比较清新的,VPS的所有功能都在一个页面集中,服务器停止,重新启动,重装系统,删除服务器等指示清晰,非常容易管理。

3210

按照上面的配置信息我们登录putty,注意vultr 端口号是22. 初次登录密码就是Initial Password 里面的信息,登录后就是我们常规的操作了。

简单简介下putty的使用

首先按照vultr 给我们的信息填写,IP选择控制面板的IP,端口22,选择SSH模式

461

点击open,会有一个窗口,选择是。

462

login as填写 root.密码填写vultr提供的密码。

putty的密码输入进去是不显示的,所以这里的正确操作步骤是:先复制vultr给的密码,注意复制的密码前后不能有空格(如上图正确密码cteyjukrieh!5),然后先鼠标左键点击下putty软件,再在绿色光标那里鼠标右键一下,然后回车键(Enter建)。这里最关键,好多朋友密码总是输入不对,要么是密码复制错误多了空格,要么就是因为没有看到密码显示就多鼠标右键,多复制了几次密码。正确复制密码回车后的界面是这个样子。

464

 vultr相关性能测试

如果你对速度还不爽,还可以做下优化,比如改进下TCP算法:hybla。 或者安装锐速.

TCP算法代码:

加载tcp_hybla模块(OpenVZ在这一步就会报错):

/sbin/modprobe tcp_hybla

然后查看是否已经正常加载:

lsmod |grep hybla

如果你的内核版本较新,比如CentOS 6.x的2.6.32,则可以用下列命令查看当前可用的拥堵算法,里面应该有hybla了:

sysctl net.ipv4.tcp_available_congestion_control

sysctl net.ipv4.tcp_congestion_control=hybla

编辑

vi /etc/sysctl.conf

在文档末行增加

net.ipv4.tcp_congestion_control= hybla

保存加载:

sysctl -p

然后重启即可。

其他可以参考:

我们用这个日本东京VPS来看视频,浏览网页的话是非常给力的。

在本站内购买vultr,加QQ:2102629796,获得免费搭建ss。

锐速给我们tcp连接加速

安装锐速

wget -N --no-check-certificate https://raw.githubusercontent.com/91yun/serverspeeder/master/serverspeeder-all.sh && bash serverspeeder-all.sh

卸载锐速

chattr -i /serverspeeder/etc/apx* && /serverspeeder/bin/serverSpeeder.sh uninstall -f

根据屏幕提示输入 serverSpeederInstaller 其他信息默认,遇到Y或者N的地方,全部选Y.

然后我们按照图片的数据指示,一路回车就可以了。

11707

现在打开你的浏览器试试速度吧,有图为证

vultr

如果你安装没有效果,编辑一下命令

vi /serverspeeder/etc/config

然后rsc和maxmode设置参数修改为1.然后在进行重启

/serverspeeder/bin/serverSpeeder.sh restart

常用命令

启动锐速:

/serverspeeder/bin/serverSpeeder.sh start

停止锐速:

/serverspeeder/bin/serverSpeeder.sh stop

查看锐速是否正常运行

service serverSpeeder status

检查是否有appex0模块:lsmod

lsmod

32

国内外vps主机提供商所提供的主机大多是基于Xen、OpenVZ、KVM、Hyper-V、VMWare五种虚拟化技术。

一、Xen 官网:http://xen.org/

Xen 由剑桥大学开发,它是基于硬件的完全分割,物理上有多少的资源就只能分配多少资源,因此很难超售。可分为Xen-PV(半虚拟化),和Xen-HVM(全虚拟化)。

Xen是不能超售内存和硬盘的,当母服务器只有16G内存以及100G硬盘时,当开Xen架构(任意一个虚拟化)的1G内存、25G硬盘的子机时,会直接占用服务器1G内存,以及25G硬盘,所以Xen的性能,相比OpenVZ在超售的情况下要好。

Xen-PV:半虚拟化,所以它仅仅适用于linux系列VPS,但它的性能损失比较少,大概相对于母机的4%-8%左右。
Xen-HVM:全虚拟化,可以安装windows或自由挂载ISO文件安装任意系统,由于是全虚拟化,所以性能损失较大,大概相对于母机性能损失8%-20%左右。

Xen适用人群:预算较为充足,且希望VPS有较高性能的客户
Xen注意事项:注意Xen-PV和Xen-HVM的区别。
Xen可用系统:Xen-PV:纯Linux,Xen-HVM:支持Windows、Linux等。
Xen代表商家:Linode.com

二、OpenVZ 官网:openvz.org/" target="_blank">http://openvz.org/

OpenVZ(简 称OVZ)采用SWsoft的Virutozzo虚拟化服务器软件产品的内核,是基于Linux平台的操作系统级服务器虚拟化架构。这个架构直接调用母服务器(母机)中的内核,模拟生成出子服务器(VPS,小机),所以,它经过虚拟化后相对于母服务器,性能损失大概只有的1-3%。

当然 OpenVZ可以超售,意思味着一台服务器总共16G内存,他可以开出配置为1G内存×17台以上的子服务器。因为他的虚拟架构关系属于:客户用多少,就扣除母服务器多少,所以OpenVZ架构的VPS较为便宜。但由于存在超售因素,如果服务商毫无休止的超售会导致服务器的性能急剧下降。

OpenVZ另一个特点是,它是直接调用母服务器的内核,所以会导致部分软件无法使用,以及部分内核文件是无法修改。

OpenVZ适用人群:新手、低预算客户
OpenVZ注意事项:资源不是自己独有的,安装VPN服务需要注意检测虚拟网卡支持。
OpenVZ可用系统:Linux(不支持Windows)
OpenVZ代表商家:Buyvm.net

三、KVM 网站:http://www.linux-kvm.org/

KVM是Linux下的全功能虚拟化架构,基于KVM架构的VPS,默认是没有系统的,可自己上传ISO或调用服务商自带的ISO手动安装系统。这个非常适合热爱DIY自己VPS的客户。

由于KVM架构全功能虚拟化架构,甚至拥有独立的BIOS控制,所以对母服务器性能影响较大,所以基于KVM的VPS较贵,但KVM VPS相对其它架构的VPS较为自由。

KVM适用人群:折腾帝
KVM注意事项:虚拟化性能比Xen略低
KVM可用系统:Windows、Linux系列
KVM代表商家:Hostgation.com

四、Hyper-V 网站:http://www.microsoft.com/zh-cn/server-cloud/

Hyper-V是微软的一款虚拟化产品,大部分国内的VPS服务商使用这个架构,主要是因为其转为Windows定制,管理起来较为方便。目前的Hyper-V也支持Linux,只不过性能损失比较严重。

Hyper-V完美支持Windows系统,包括32位和64位。如果大家选购Hyper-V架构的VPS,强烈建议使用Windows。

Hyper-V目前不能超售内存,但可超售硬盘,硬盘是根据客户使用情况扣除。一般来说,服务器的硬盘不会100%用完,这点不用担心。

Hyper-V适用人群:Windows系统爱好者
Hyper-V注意事项:Linux操作系统性能较低
Hyper-V可用系统:Windows、Linux

五、VMWare 网站:http://www.vmware.com/

VMWare 是全球桌面到数据中心虚拟化解决方案的领导厂商开发的一款全功能完全虚拟化的软件。但由于VMWare用于开设类似VPS(含独立面板)的系列产品授权费用非常昂贵,所以大部分使用VMWare服务商会使用 VMware工作站(VMware Workstation)提供VPS。

使用VMware工作站(VMware Workstation)开设的VPS是无控制面板的,操作系统需要服务商手动安装,但现在网上寻找VMware Workstation的神KEY非常容易,对于VPS服务商来说节省不少成本。一般用于新创业的VPS服务商。

使用VMWare Workstation实质上的VPS可以超售,因为其和OpenVZ架构一样,子机用多少内存,就扣除系统多少内存,但如果物理内存不足时可能导致母服务器使用Windows虚拟内存。

VMWare适用人群:认真建站或挂机的客户
VMWare注意事项:无控制面板
VMWare可用系统:Windows、Linux系列

以上衡量超售指的是内存、磁盘,其它硬件条件,如网络带宽、CPU等不在考虑范围内。

六、Xen和OpenVZ的区别
Xen由dom0和domU组成,Dom0是虚拟出CPU, IO总路线等资源,供工作于DomU上的不同的kernel运行。
这样的好处是,
1. 对可以运行的操作系统限制较少。
2. domU上系统的crash不会影响其他的dom. 当然Dom0发生故障时还是会有问题。
坏处:
1. 由于需要虚拟CPU,BUS等物理资源,开销会更大点。

OpenVZ使用了完全不同的方式,它所创造的虚拟机都使用工作在同一个kernel下。
这样的好处是
1. 性能好。
坏处:
1. 任何一个kernel bug都会危及所有的虚拟机。 因kernel bug所crash的可能性大大增加。
2. 他需要对内核作很多的改动。

区分上最明显的,XEN VPS有swap区,基于RHEL5的OpenVZ VPS没有swap区,基于RHEL6的OpenVZ VPS有VSwap区。

 

转:https://qiaodahai.com/xen-openvz-kvm-hyper-v-vmware-virtualization.html

开启TUN

vzctl set 800 --devnodes net/tun:rw --save
vzctl set 800 --devices c:10:200:rw --save
vzctl set 800 --capability net_admin:on --save
vzctl exec 800 mkdir -p /dev/net
vzctl exec 800 chmod 600 /dev/net/tun

开启PPP

vzctl set 800 --features ppp:on --save
vzctl set 800 --devices c:108:0:rw --save
vzctl exec 800 mknod /dev/ppp c 108 0
vzctl exec 800 chmod 600 /dev/ppp

 

确认是否成功,在虚拟机下运行:

[root@vpn ~]# cat /dev/net/tun
cat: /dev/net/tun: File descriptor in bad state

[root@vpn ~]# cat /dev/ppp
cat: /dev/ppp: No such device or address

即代表成功

包括 安装epel源、导入国内数据源、系统支持中文、调整时区等简单功能
适用于模板:centos-6-x86_64-minimal.tar.gz
wget "http://www.151051.com/soft/init/init_centos.sh" -O - | bash
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/centos-5-x86-devel.tar.gz">centos-5-x86-devel.tar.gz 21-Oct-2014 22:12 197M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/centos-5-x86-devel.tar.gz.asc">centos-5-x86-devel.tar.gz.asc 21-Oct-2014 22:36 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/centos-5-x86.tar.gz">centos-5-x86.tar.gz 21-Oct-2014 22:11 174M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/centos-5-x86.tar.gz.asc">centos-5-x86.tar.gz.asc 21-Oct-2014 22:37 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/centos-5-x86_64-devel.tar.gz">centos-5-x86_64-devel.tar.gz 21-Oct-2014 22:15 213M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/centos-5-x86_64-devel.tar.gz.asc">centos-5-x86_64-devel.tar.gz.asc 21-Oct-2014 22:36 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/centos-5-x86_64.tar.gz">centos-5-x86_64.tar.gz 21-Oct-2014 22:13 189M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/centos-5-x86_64.tar.gz.asc">centos-5-x86_64.tar.gz.asc 21-Oct-2014 22:36 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/centos-6-x86-devel.tar.gz">centos-6-x86-devel.tar.gz 21-Oct-2014 22:07 234M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/centos-6-x86-devel.tar.gz.asc">centos-6-x86-devel.tar.gz.asc 21-Oct-2014 22:37 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/centos-6-x86-minimal.tar.gz">centos-6-x86-minimal.tar.gz 21-Oct-2014 22:06 103M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/centos-6-x86-minimal.tar.gz.asc">centos-6-x86-minimal.tar.gz.asc 21-Oct-2014 22:37 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/centos-6-x86.tar.gz">centos-6-x86.tar.gz 21-Oct-2014 22:05 203M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/centos-6-x86.tar.gz.asc">centos-6-x86.tar.gz.asc 21-Oct-2014 22:37 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/centos-6-x86_64-devel.tar.gz">centos-6-x86_64-devel.tar.gz 21-Oct-2014 22:10 249M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/centos-6-x86_64-devel.tar.gz.asc">centos-6-x86_64-devel.tar.gz.asc 21-Oct-2014 22:37 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/centos-6-x86_64-minimal.tar.gz">centos-6-x86_64-minimal.tar.gz 21-Oct-2014 22:09 103M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/centos-6-x86_64-minimal.tar.gz.asc">centos-6-x86_64-minimal.tar.gz.asc 21-Oct-2014 22:37 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/centos-6-x86_64.tar.gz">centos-6-x86_64.tar.gz 21-Oct-2014 22:08 216M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/centos-6-x86_64.tar.gz.asc">centos-6-x86_64.tar.gz.asc 21-Oct-2014 22:37 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/centos-7-x86_64-minimal.tar.gz">centos-7-x86_64-minimal.tar.gz 21-Oct-2014 22:16 131M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/centos-7-x86_64-minimal.tar.gz.asc">centos-7-x86_64-minimal.tar.gz.asc 21-Oct-2014 22:38 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/centos-7-x86_64.tar.gz">centos-7-x86_64.tar.gz 21-Oct-2014 22:16 201M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/centos-7-x86_64.tar.gz.asc">centos-7-x86_64.tar.gz.asc 21-Oct-2014 22:38 198
openvz.org/icons/folder.gif" alt="[DIR]" /> openvz.org/template/precreated/contrib/">contrib/ 18-Nov-2014 13:04 -
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/debian-6.0-x86-minimal.tar.gz">debian-6.0-x86-minimal.tar.gz 21-Oct-2014 22:03 77M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/debian-6.0-x86-minimal.tar.gz.asc">debian-6.0-x86-minimal.tar.gz.asc 21-Oct-2014 22:38 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/debian-6.0-x86.tar.gz">debian-6.0-x86.tar.gz 21-Oct-2014 22:02 148M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/debian-6.0-x86.tar.gz.asc">debian-6.0-x86.tar.gz.asc 21-Oct-2014 22:38 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/debian-6.0-x86_64-minimal.tar.gz">debian-6.0-x86_64-minimal.tar.gz 21-Oct-2014 22:04 79M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/debian-6.0-x86_64-minimal.tar.gz.asc">debian-6.0-x86_64-minimal.tar.gz.asc 21-Oct-2014 22:38 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/debian-6.0-x86_64.tar.gz">debian-6.0-x86_64.tar.gz 21-Oct-2014 22:04 150M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/debian-6.0-x86_64.tar.gz.asc">debian-6.0-x86_64.tar.gz.asc 21-Oct-2014 22:38 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/debian-7.0-x86-minimal.tar.gz">debian-7.0-x86-minimal.tar.gz 21-Oct-2014 22:00 84M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/debian-7.0-x86-minimal.tar.gz.asc">debian-7.0-x86-minimal.tar.gz.asc 21-Oct-2014 22:38 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/debian-7.0-x86.tar.gz">debian-7.0-x86.tar.gz 21-Oct-2014 21:59 224M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/debian-7.0-x86.tar.gz.asc">debian-7.0-x86.tar.gz.asc 21-Oct-2014 22:39 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/debian-7.0-x86_64-minimal.tar.gz">debian-7.0-x86_64-minimal.tar.gz 21-Oct-2014 22:01 84M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/debian-7.0-x86_64-minimal.tar.gz.asc">debian-7.0-x86_64-minimal.tar.gz.asc 21-Oct-2014 22:38 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/debian-7.0-x86_64.tar.gz">debian-7.0-x86_64.tar.gz 21-Oct-2014 22:01 224M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/debian-7.0-x86_64.tar.gz.asc">debian-7.0-x86_64.tar.gz.asc 21-Oct-2014 22:38 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/fedora-19-x86.tar.gz">fedora-19-x86.tar.gz 21-Oct-2014 21:50 190M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/fedora-19-x86.tar.gz.asc">fedora-19-x86.tar.gz.asc 21-Oct-2014 22:39 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/fedora-19-x86_64.tar.gz">fedora-19-x86_64.tar.gz 21-Oct-2014 21:52 190M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/fedora-19-x86_64.tar.gz.asc">fedora-19-x86_64.tar.gz.asc 21-Oct-2014 22:39 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/fedora-20-x86.tar.gz">fedora-20-x86.tar.gz 21-Oct-2014 21:48 184M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/fedora-20-x86.tar.gz.asc">fedora-20-x86.tar.gz.asc 21-Oct-2014 22:39 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/fedora-20-x86_64.tar.gz">fedora-20-x86_64.tar.gz 21-Oct-2014 21:49 185M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/fedora-20-x86_64.tar.gz.asc">fedora-20-x86_64.tar.gz.asc 21-Oct-2014 22:39 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/scientific-6-x86.tar.gz">scientific-6-x86.tar.gz 21-Oct-2014 22:18 197M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/scientific-6-x86.tar.gz.asc">scientific-6-x86.tar.gz.asc 21-Oct-2014 22:40 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/scientific-6-x86_64.tar.gz">scientific-6-x86_64.tar.gz 21-Oct-2014 22:19 210M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/scientific-6-x86_64.tar.gz.asc">scientific-6-x86_64.tar.gz.asc 21-Oct-2014 22:39 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/suse-12.3-x86.tar.gz">suse-12.3-x86.tar.gz 21-Oct-2014 21:42 190M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/suse-12.3-x86.tar.gz.asc">suse-12.3-x86.tar.gz.asc 21-Oct-2014 22:40 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/suse-12.3-x86_64.tar.gz">suse-12.3-x86_64.tar.gz 21-Oct-2014 21:43 191M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/suse-12.3-x86_64.tar.gz.asc">suse-12.3-x86_64.tar.gz.asc 21-Oct-2014 22:40 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/suse-13.1-x86-minimal.tar.gz">suse-13.1-x86-minimal.tar.gz 21-Oct-2014 21:45 55M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/suse-13.1-x86-minimal.tar.gz.asc">suse-13.1-x86-minimal.tar.gz.asc 21-Oct-2014 22:40 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/suse-13.1-x86.tar.gz">suse-13.1-x86.tar.gz 21-Oct-2014 21:45 229M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/suse-13.1-x86.tar.gz.asc">suse-13.1-x86.tar.gz.asc 21-Oct-2014 22:40 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/suse-13.1-x86_64-minimal.tar.gz">suse-13.1-x86_64-minimal.tar.gz 21-Oct-2014 21:47 56M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/suse-13.1-x86_64-minimal.tar.gz.asc">suse-13.1-x86_64-minimal.tar.gz.asc 21-Oct-2014 22:40 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/suse-13.1-x86_64.tar.gz">suse-13.1-x86_64.tar.gz 21-Oct-2014 21:47 232M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/suse-13.1-x86_64.tar.gz.asc">suse-13.1-x86_64.tar.gz.asc 21-Oct-2014 22:40 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/ubuntu-10.04-x86.tar.gz">ubuntu-10.04-x86.tar.gz 21-Oct-2014 21:57 133M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/ubuntu-10.04-x86.tar.gz.asc">ubuntu-10.04-x86.tar.gz.asc 21-Oct-2014 22:41 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/ubuntu-10.04-x86_64.tar.gz">ubuntu-10.04-x86_64.tar.gz 21-Oct-2014 21:58 137M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/ubuntu-10.04-x86_64.tar.gz.asc">ubuntu-10.04-x86_64.tar.gz.asc 21-Oct-2014 22:41 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/ubuntu-12.04-x86-minimal.tar.gz">ubuntu-12.04-x86-minimal.tar.gz 21-Oct-2014 21:55 57M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/ubuntu-12.04-x86-minimal.tar.gz.asc">ubuntu-12.04-x86-minimal.tar.gz.asc 21-Oct-2014 22:41 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/ubuntu-12.04-x86.tar.gz">ubuntu-12.04-x86.tar.gz 21-Oct-2014 21:55 123M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/ubuntu-12.04-x86.tar.gz.asc">ubuntu-12.04-x86.tar.gz.asc 21-Oct-2014 22:41 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/ubuntu-12.04-x86_64-minimal.tar.gz">ubuntu-12.04-x86_64-minimal.tar.gz 21-Oct-2014 21:56 58M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/ubuntu-12.04-x86_64-minimal.tar.gz.asc">ubuntu-12.04-x86_64-minimal.tar.gz.asc 21-Oct-2014 22:41 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/ubuntu-12.04-x86_64.tar.gz">ubuntu-12.04-x86_64.tar.gz 21-Oct-2014 21:56 125M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/ubuntu-12.04-x86_64.tar.gz.asc">ubuntu-12.04-x86_64.tar.gz.asc 21-Oct-2014 22:41 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/ubuntu-14.04-x86-minimal.tar.gz">ubuntu-14.04-x86-minimal.tar.gz 21-Oct-2014 21:53 73M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/ubuntu-14.04-x86-minimal.tar.gz.asc">ubuntu-14.04-x86-minimal.tar.gz.asc 21-Oct-2014 22:41 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/ubuntu-14.04-x86.tar.gz">ubuntu-14.04-x86.tar.gz 21-Oct-2014 21:52 145M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/ubuntu-14.04-x86.tar.gz.asc">ubuntu-14.04-x86.tar.gz.asc 21-Oct-2014 22:41 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/ubuntu-14.04-x86_64-minimal.tar.gz">ubuntu-14.04-x86_64-minimal.tar.gz 21-Oct-2014 21:54 75M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/ubuntu-14.04-x86_64-minimal.tar.gz.asc">ubuntu-14.04-x86_64-minimal.tar.gz.asc 21-Oct-2014 22:41 198
openvz.org/icons/compressed.gif" alt="[ ]" /> openvz.org/template/precreated/ubuntu-14.04-x86_64.tar.gz">ubuntu-14.04-x86_64.tar.gz 21-Oct-2014 21:54 147M
openvz.org/icons/text.gif" alt="[TXT]" /> openvz.org/template/precreated/ubuntu-14.04-x86_64.tar.gz.asc">ubuntu-14.04-x86_64.tar.gz.asc 21-Oct-2014 22:41 198

http://download.openvz.org/template/precreated/

URL:http://www.oneasiahost.com/

QQ截图20130819153639

 

现在只有OpenVZ主机,SSD少量到货。最低只要$12/年,注意不要选用Core VPS,这个是没有中国线路的。商家还很贴心的用中文写了“中国客户注意 - CORE VPS 没有直接的中国网络, 通过美国. Ping 400ms+ 连接中国速度慢, 较适合在中国以外的地区或需要使用高頻寬的用户”

可以安装PPTPD VPN,访问谷歌、youtube、twitter、非死不可(facebook)嗖嗖的。

------------20131210-----------

要开启 TUN/TAP和PPP

QQ截图20131209151832

http://pve.proxmox.com/wiki/OpenVZ_Console

官方给文档了,这里记录一下:

Centos 6

Login via SSH (or use the VNC "Shell") to your Proxmox VE host and 'vzctl enter CTID' the container:

List all running container:

proxmox-ve:~# vzlist
     CTID      NPROC STATUS    IP_ADDR         HOSTNAME
      108         23 running   192.168.9.20    ubuntu-1204.proxmox.com
      109         18 running   192.168.9.21    centos63-64.proxmox.com
      111         15 running   192.168.9.23    centos5-64.proxmox.com
      114         14 running   192.168.9.30    deb6-32.proxmox.com
      115         15 running   192.168.9.31    deb7-32.proxmox.com
      122         14 running   192.168.9.36    deb5.proxmox.com

Enter the container:

proxmox-ve:~# vzctl enter 109
root@centos63-64:/# nano /etc/init/tty.conf

Change/Create the file that it looks exactly like this:

# This service maintains a getty on tty1 from the point the system is
# started until it is shut down again.

start on stopped rc RUNLEVEL=[2345]

stop on runlevel [!2345]

respawn
exec /sbin/agetty -8 tty1 38400

Save the changes and shutdown/start the container via Console.

yum -y install wget --noplugins
wget freevps.us/downloads/nginx-centos-6.sh -O - | bash

注意安装完成后 php-fpm 默认跑在 apache 用户上。

安装完成后,如果你需要的 PHP 扩展未安装,可输入如下命令查询:

yum list | grep ^php*

找到了扩展的名字,就可以直接安装了:

# 以 php memcache 扩展为例
yum install -y php-pecl-memcached

此外还遇到的问题是 DOMDocument 找不到,直接 yum 安装 php-xml:

yum install -y php-xml

所有扩展 yum 安装完成后都需要重新启动 / 载入 php-fpm。
贴下内容来看看(非最新版本,请直接下载 .sh 文件):

#!/bin/bash

##################
# disable apache #
##################
service httpd stop 
chkconfig httpd off
service xinetd stop
chkconfig xinetd off
service saslauthd stop
chkconfig saslauthd off
service sendmail stop
chkconfig sendmail off
service postfix stop
chkconfig postfix off

#Optimize yum on OpenVZ
if [ -e "/proc/user_beancounters" ]
then
  sed -i 's/plugins=1/plugins=0/' /etc/yum.conf
fi

#remove all current PHP and MySQL, will reinstall later. Also, remove apache 
yum -y remove httpd php mysql rsyslog sendmail postfix

###################
# Add a few repos #
###################
# install the Atomic repo for php and nginx (may use epel for nginx depending on version)
wget -q -O - http://www.atomicorp.com/installers/atomic | sh

# RPMForge for nginx dependencies
rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm

#EPEL for syslog-ng and nginx (may use atomic for nginx depending on version)
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm

################################
# Install PHP, NGINX and MySQL #
################################
#yum install GeoIP libGeoIP.so.1 --enablerepo=repoforge
yum -y install mysql-server php-fpm php-mysql php-gd nginx nano exim syslog-ng

#################
# install MySQL #
#################
#yum -y install mysql-server
cat > /etc/my.cnf <<END
[mysqld]
default-storage-engine = myisam
key_buffer = 8M
query_cache_size = 8M
query_cache_limit = 4M
max_connections=25
thread_cache=1
skip-innodb 
query_cache_min_res_unit=0
tmp_table_size = 4M
max_heap_table_size = 4M
table_cache=256
concurrent_insert=2 
END
echo  Do not worry if you see a error stopping MySQL or NGINX
/etc/init.d/mysqld stop
/etc/init.d/mysqld start

####################
# Set up NGINX PHP #
####################
cat > /etc/nginx/php <<END
index index.php index.html index.htm;

location ~ \.php$ {

   include fastcgi_params;
    fastcgi_intercept_errors on;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
  try_files \$uri =404;
    fastcgi_pass 127.0.0.1:9000;
    error_page 404 /404page.html; #makes nginx return it's default 404 
#	page instead of a blank page

} 
END

cat > /etc/nginx/nginx.conf <<END
user              nginx nginx;
worker_processes  2;

error_log         logs/error.log;

pid               logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    client_max_body_size 64M;
    sendfile        on;
    tcp_nopush      on;

    keepalive_timeout  3;

    gzip  on;
    gzip_comp_level 2;
    gzip_proxied any;
    gzip_types      text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    server_tokens off;

    include /etc/nginx/conf.d/*;
} 
END
rm /etc/nginx/conf.d/*
cat > /etc/nginx/conf.d/default.conf <<END
server {
    listen 80 default;
    server_name _;
    root /var/www/html;
    include php;

  } 
END
mkdir /usr/share/nginx/logs/
service nginx restart
chkconfig nginx on
chkconfig mysqld on

cat > /etc/php-fpm.d/www.conf <<END
; Start a new pool named 'www'.
[www]

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific address on
;                            a specific port;
;   'port'                 - to listen on a TCP socket to all addresses on a
;                            specific port;
;   '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9000

; Set listen(2) backlog. A value of '-1' means unlimited.
; Default Value: -1
;listen.backlog = -1

; List of ipv4 addresses of FastCGI clients which are allowed to connect.
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
; must be separated by a comma. If this value is left blank, connections will be
; accepted from any ip address.
; Default Value: any
listen.allowed_clients = 127.0.0.1

; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions. 
; Default Values: user and group are set as the running user
;                 mode is set to 0666
;listen.owner = nobody
;listen.group = nobody
;listen.mode = 0666

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = apache
; RPM: Keep a group allowed to write in log dir.
group = apache

; Choose how the process manager will control the number of child processes.
; Possible Values:
;   static  - a fixed number (pm.max_children) of child processes;
;   dynamic - the number of child processes are set dynamically based on the
;             following directives:
;             pm.max_children      - the maximum number of children that can
;                                    be alive at the same time.
;             pm.start_servers     - the number of children created on startup.
;             pm.min_spare_servers - the minimum number of children in 'idle'
;                                    state (waiting to process). If the number
;                                    of 'idle' processes is less than this
;                                    number then some children will be created.
;             pm.max_spare_servers - the maximum number of children in 'idle'
;                                    state (waiting to process). If the number
;                                    of 'idle' processes is greater than this
;                                    number then some children will be killed.
; Note: This value is mandatory.
pm = dynamic

; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes to be created when pm is set to 'dynamic'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI.
; Note: Used when pm is set to either 'static' or 'dynamic'
; Note: This value is mandatory.
pm.max_children = 5

; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
pm.start_servers = 1

; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.min_spare_servers = 1

; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 3

; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
pm.max_requests = 500

; The URI to view the FPM status page. If this value is not set, no URI will be
; recognized as a status page. By default, the status page shows the following
; information:
;   accepted conn    - the number of request accepted by the pool;
;   pool             - the name of the pool;
;   process manager  - static or dynamic;
;   idle processes   - the number of idle processes;
;   active processes - the number of active processes;
;   total processes  - the number of idle + active processes.
; The values of 'idle processes', 'active processes' and 'total processes' are
; updated each second. The value of 'accepted conn' is updated in real time.
; Example output:
;   accepted conn:   12073
;   pool:             www
;   process manager:  static
;   idle processes:   35
;   active processes: 65
;   total processes:  100
; By default the status page output is formatted as text/plain. Passing either
; 'html' or 'json' as a query string will return the corresponding output
; syntax. Example:
;   http://www.foo.bar/status
;   http://www.foo.bar/status?json
;   http://www.foo.bar/status?html
; Note: The value must start with a leading slash (/). The value can be
;       anything, but it may not be a good idea to use the .php extension or it
;       may conflict with a real PHP file.
; Default Value: not set 
;pm.status_path = /status

; The ping URI to call the monitoring page of FPM. If this value is not set, no
; URI will be recognized as a ping page. This could be used to test from outside
; that FPM is alive and responding, or to
; - create a graph of FPM availability (rrd or such);
; - remove a server from a group if it is not responding (load balancing);
; - trigger alerts for the operating team (24/7).
; Note: The value must start with a leading slash (/). The value can be
;       anything, but it may not be a good idea to use the .php extension or it
;       may conflict with a real PHP file.
; Default Value: not set
;ping.path = /ping

; This directive may be used to customize the response of a ping request. The
; response is formatted as text/plain with a 200 response code.
; Default Value: pong
;ping.response = pong

; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_terminate_timeout = 0

; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_slowlog_timeout = 0

; The log file for slow requests
; Default Value: /var/log/php-fpm.log.slow
;slowlog = /var/log/php-fpm.log.slow

; Set open file descriptor rlimit.
; Default Value: system defined value
;rlimit_files = 1024

; Set max core size rlimit.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0

; Chroot to this directory at the start. This value must be defined as an
; absolute path. When this value is not set, chroot is not used.
; Note: chrooting is a great security feature and should be used whenever 
;       possible. However, all PHP paths will be relative to the chroot
;       (error_log, sessions.save_path, ...).
; Default Value: not set
;chroot = 

; Chdir to this directory at the start. This value must be an absolute path.
; Default Value: current directory or / when chroot
;chdir = /var/www

; Redirect worker stdout and stderr into main error log. If not set, stdout and
; stderr will be redirected to /dev/null according to FastCGI specs.
; Default Value: no
;catch_workers_output = yes

; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment.
; Default Value: clean env
;env[HOSTNAME] = $HOSTNAME
;env[PATH] = /usr/local/bin:/usr/bin:/bin
;env[TMP] = /tmp
;env[TMPDIR] = /tmp
;env[TEMP] = /tmp

; Additional php.ini defines, specific to this pool of workers. These settings
; overwrite the values previously defined in the php.ini. The directives are the
; same as the PHP SAPI:
;   php_value/php_flag             - you can set classic ini defines which can
;                                    be overwritten from PHP call 'ini_set'. 
;   php_admin_value/php_admin_flag - these directives won't be overwritten by
;                                     PHP call 'ini_set'
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.

; Defining 'extension' will load the corresponding shared extension from
; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
; overwrite previously defined php.ini values, but will append the new value
; instead.

; Default Value: nothing is defined by default except the values in php.ini and
;                specified at startup with the -d argument
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
;php_flag[display_errors] = off
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M
php_admin_value[upload_max_filesize] = 32M
END

mkdir /var/www
mkdir /var/www/html/
useradd apache
service php-fpm start
chkconfig php-fpm on
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
service iptables save

wget freevps.us/downloads/setup-vhost.sh -O /bin/setup-vhost
chmod 755 /bin/setup-vhost
echo "alias nano='nano -w'" >> ~/.bashrc
clear
echo Installation done.
echo to create a vhost, run
echo setup-vhost example.com
echo do not include the www. subdomain.