使用xen-shell来管理xen vps
XEN 的强大管理工具 XEN-SHELL,用他来管理XEN的虚拟机,简直是太方便了。太强大了,支持系统重装,VPS 启动、重启、关机、暂停,连接控制台。
wget http://xen-tools.org/software/xen-shell/xen-shell-1.9.tar.gztar zxvf xen-shell-1.9.tar.gz
cd xen-shell
make
make install1.建立连接VPS的用户与密码
useradd eric
passwd eric
useradd yangzi
passwd yangzi2.给用户 sudo 的命令权限,和登录shell
vim /etc/sudoers
#加入以下
User_Alias XENUSERS = eric,yangzi
Cmnd_Alias XEN = /usr/sbin/xm
Cmnd_Alias XENIMG = /usr/bin/xen-create-image
XENUSERS ALL = NOPASSWD: XEN,XENIMG# 执行下列命令,让用户登录到 xen-shell
chsh -s /usr/local/bin/xen-login-shell eric
chsh -s /usr/local/bin/xen-login-shell yangzi3.修改xen 虚拟机的配置文件,加入
xen_shell = "eric"例如:
kernel = "/boot/vmlinuz-2.6.24-28-xen"
ramdisk = "/boot/initrd.img-2.6.24-28-xen"
memory = "64"
name = "xenyang"
xen_shell = "eric"
disk = ['phy:/dev/md0,sda1,w']
root = "/dev/sda1 ro"
on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'restart'
vcpus = '2'
extra = 'xencons=tty1'
vif = [ '' ]4.(可选)如果你需要用xen-shell 来重装系统的话,就做这步
在eric 的home 目录下新建image.sh
cd /home/eric
vim image.sh
#!/bin/sh
/usr/bin/sudo /usr/bin/xen-create-image --hostname=yang \
--size=1.5Gb \
--ide \
--ip=192.168.6.36 \
--netmask=255.255.255.0 \
--gateway=192.168.6.1 \
--force \
--kernel=/boot/vmlinuz-2.6.24-28-xen \
--dist=hardy \
--mirror=http://mirrors.163.com/Ubuntu/ \
--arch=i386 \
--passwd \
--dir=/home/eric5.使用xen-shell 来控制 vps
打开putty 填入 xen 服务器IP地址 输入新建的用户名 eric
xen-shell v1.9
The following commands are available within this shell:
Use of uninitialized value in sprintf at /usr/bin/xen-shell line 1603.
author -
boot - Boot the Xen guest.
console - Gain access to a Xen guest via the serial console.
exit - Exit the shell.
help - Show general, or command-specific, help information.
passwd - Change the password used to access this host.
pause - This will pause the Xen guest.
quit - Exit this shell.
reboot - Reboot the Xen guest.
reimage - Reset your system to a pristine installation.
serial - Gain access to the Xen guest via the serial console.
shutdown - Shutdown the Xen guest.
status - Show the status of the Xen guest.
sysreq - Send a 'sysreq' keystroke to the guest.
top - Show system resource usage.
unpause - This will unpause the Xen guest.
uptime - Show the uptime information of your guest system and this host.
version - Show the version of this shell, and of Xen.
whoami - Show the user you're connected to the host system as.
For command-specific help run "help command".
xen-shell> ###下面是 命令介绍 ####
xen-shell> boot # 启动vps
xen-shell> console# 登录VPS,如果用SSH连不上 VPS,你这样可以登录VPS修改IP地址等。
xen-shell> exit# 退出 xen-shell
xen-shell> help# 查看帮助信息,显示命令
xen-shell> passwd # 修改用户登录密码
xen-shell>pause# 将暂停VPS
xen-shell>quit# 退出 xen-shell
xen-shell>reboot# 重启 VPS
xen-shell>reimage# 重新安装系统
xen-shell>serial# 也是登录VPS控制台
xen-shell> shutdown# 关闭 vps 虚拟机
xen-shell> status# VPS 运行的状态
xen-shell>sysreq# 发送‘sysreq’按键 到VPS
xen-shell>top# 显示系统资源使用率
xen-shell>unpause# 取消暂停
xen-shell>uptime# 显示您的客户系统和该主机的正常运行时间信息
xen-shell>version# 显示 xen-shell 和 XEN 的版本信息
xen-shell>whoami# 显示您已经连接到主机系统的用户。