|
|
July 31 ESX 各种紫屏的原因以及解决方案.相当狠!
FYI. July 27
引用
[转]LINUX常用命令和目录架构
/ 根目录 /bin 常用的命令 binary file 的目錄 /boot 存放系统启动时必须读取的档案,包括核心 (kernel) 在内 /boot/grub/menu.lst GRUB设置 /boot/vmlinuz 内核 /boot/initrd 核心解壓縮所需 RAM Disk /dev 系统周边设备 /etc 系统相关设定文件 /etc/DIR_COLORS 设定颜色 /etc/HOSTNAME 设定用户的节点名 /etc/NETWORKING 只有YES标明网络存在 /etc/host.conf 文件说明用户的系统如何查询节点名 /etc/hosts 设定用户自已的IP与名字的对应表 /etc/hosts.allow 设置允许使用inetd的机器使用 /etc/hosts.deny 设置不允许使用inetd的机器使用 /etc/hosts.equiv 设置远端机不用密码 /etc/inetd.conf 设定系统网络守护进程inetd的配置 /etc/gateways 设定路由器 /etc/protocols 设定系统支持的协议 /etc/named.boot 设定本机为名字服务器的配置文件 /etc/sysconfig/network-scripts/ifcfg-eth0 设置IP /etc/resolv.conf 设置DNS /etc/X11 X Window的配置文件,xorg.conf 或 XF86Config 這兩個 X Server 的設定檔 /etc/fstab 记录开机要mount的文件系统 /etc/inittab 设定系统启动时init进程将把系统设置成什么样的runlevel /etc/issue 记录用户登录前显示的信息 /etc/group 设定用户的组名与相关信息 /etc/passwd 帐号信息 /etc/shadow 密码信息 /etc/sudoers 可以sudo命令的配置文件 /etc/securetty 设定哪些终端可以让root登录 /etc/login.defs 所有用户登录时的缺省配置 /etc/exports 设定NFS系统用的 /etc/init.d/ 所有服務的預設啟動 script 都是放在這裡的,例如要啟動或者關閉 /etc/xinetd.d/ 這就是所謂的 super daemon 管理的各項服務的設定檔目錄 /etc/modprobe.conf 内核模块额外参数设定 /etc/syslog.conf 日志设置文件 /home 使用者家目录 /lib 系统会使用到的函数库 /lib/modules kernel 的相关模块 /var/lib/rpm rpm套件安装处 /lost+found 系統不正常產生錯誤時,會將一些遺失的片段放置於此目錄下 /mnt 外设的挂载点 /media 与/mnt类似 /opt 主机额外安装的软件 /proc 虚拟目录,是内存的映射 /proc/version 内核版本 /proc/sys/kernel 系统内核功能 /root 系统管理员的家目录 /sbin 系统管理员才能执行的指令 /srv 一些服務啟動之後,這些服務所需要取用的資料目錄 /tmp 一般使用者或者是正在執行的程序暫時放置檔案的地方 /usr 最大的目录,存许应用程序和文件 /usr/X11R6: X-Window目录 /usr/src: Linux源代码 /usr/include:系统头文件 /usr/openwin 存放SUN的OpenWin /usr/man 在线使用手册 /usr/bin 使用者可執行的 binary file 的目錄 /usr/local/bin 使用者可執行的 binary file 的目錄 /usr/lib 系统会使用到的函数库 /usr/local/lib 系统会使用到的函数库 /usr/sbin 系统管理员才能执行的指令 /usr/local/sbin 系统管理员才能执行的指令 /var 日志文件 /var/log/secure 記錄登入系統存取資料的檔案,例如 pop3, ssh, telnet, ftp 等都會記錄在此檔案中 /var/log/wtmp 記錄登入者的訊息資料, last /var/log/messages 幾乎系統發生的錯誤訊息 /var/log/boot.log 記錄開機或者是一些服務啟動的時候,所顯示的啟動或關閉訊息 /var/log/maillog 紀錄郵件存取或往來( sendmail 與 pop3 )的使用者記錄 /var/log/cron 記錄 crontab 這個例行性服務的內容 /var/log/httpd, /var/log/news, /var/log/mysqld.log, /var/log/samba, /var/log/procmail.log: 分別是幾個不同的網路服務的記錄檔 一些常用的基本命令: uname -a 查看内核版本 ls -al 显示所有文件的属性 pwd 显示当前路径 cd - 返回上一次目录 cd ~ 返回主目录 date s 设置时间、日期 cal 显示日历 cal 2006 bc 计算器具 man & info 帮助手册 locale 显示当前字体 locale -a 所有可用字体 /etc/sysconfig/i18n设置文件 LANG=en 使用英文字体 sync 将数据同步写入硬盘 shutdonw -h now & half & poweroff 关机 reboot 重启 startx & init 5 进入图形介面 /work & ?work 向上、下查找文档内容 chgrp 改变档案群组 chgrp testing install.log chown 改变所属人 chown root:root install.log chmod 改变属性 chmod 777 install.log read=4 write=2 execute=1 cp 复制 cp filename rm 删除文件 rm -rf filename 强制删除文件 rmdir 删除文件夹 mv 移动 mv 123.txt 222.txt 重命名 mkdir 创建文件夹 touch 创建文件 更新当前时间 cat 由第一行开始显示 cat |more 分页 nl 在内容前加行号 more & less 一面一面翻动 head -n filename 显示第N行内容 tail -n filename 显示后N行内容 od 显示非纯文档 df -h 显示分区空间 du 显示目录或文件的大小 fdisk 分区设置 fdisk -l /dev/hda 显示硬盘分区状态 mkfs 建立各种文件系统 mkfs -t ext3 /dev/ram15 fsck 检查和修复LINUX档案 ln 硬链接 ln -s 软件链接 whereis 查找命令 locate 查找 find 查找 find / -name "***.***" which 查看工具 whoami 显示当前用户 gcc -v 查看GCC版本 chattr +i filename 禁止删除 chattr -i filename 取消禁止 lsattr 显示隐藏档属性 updatedb 更新资料库 mke2fs 格式化 mkfs -t ext3 dd if=/etc/passwd of=/tmp/passwd.bak 备份 mount 列出系统所有的分区 mount -t iso9660 /dev/cdrom /mnt/cdrom 挂载光盘 mount -t vfat /dev/fd0 /mnt/floppy 挂载软盘 mount -t vfat -o iocharset=utf8,umask=000 /dev/hda2 /mnt/hda2 挂载fat32分区 mount -t ntfs -o nls=utf8,umask=000 /dev/hda3 /mnt/hda3 挂载ntfs分区 Linux-NTFS Project: http://linux-ntfs.sourceforge.net/ umount /mnt/hda3 缷载 ifconfig 显示或设置网络设备 service network restart 重启网卡 ifdown eth0 关闭网卡 ifup eth0 开启网卡 clear 清屏 history 历史记录 !55 执行第55个指令 stty 设置终端 stty -a fdisk /mbr 删除GRUB at 僅進行一次的工作排程 crontab 循環執行的例行性命令 [e]编辑,[l]显示,[r]删除任务 & 后台运行程序 tar -zxvf 123.tar.gz & --------->后台运行 jobs 观看后台暂停的程序 jobs -l fg 将后台程序调到前台 fg n ------>n是数字,可以指定进行那个程序 bg 让工作在后台运行 kill 结束进程 kill -9 PID [9]强制结束,[15]正常结束,[l]列出可用的kill信号 ps aux 查看后台程序 top 查看后台程序 top -d 2 每两秒更新一次 top -d 2 -p10604 观看某个PID top -b -n 2 > /tmp/top.txt ----->將 top 的資訊進行 2 次,然後將結果輸出到 /tmp/top.txt pstree 以树状图显示程序 [A]以 ASCII 來連接, 列出PID, [p]列出帐号 killall 要刪除某個服務 killall -9 httpd free 显示内存状态 free -m -------->以M为单位显示 uptime 显示目前系统开机时间 netstat 显示网络状态 netstat -tulnp------>找出目前系統上已在監聽的網路連線及其 PID dmesg 显示开机信息 demsg | more nice 设置优先权 nice -n -5 vi & ----->用 root 給一個 nice 植為 -5 ,用於執行 vi renice 调整已存在优先权 runlevel 显示目前的runlevel depmod 分析可载入模块的相依性 lsmod 显示已载入系统的模块 modinfo 显示kernel模块的信息 insmod 载入模块 modprobe 自动处理可载入模块 rmmod 删除模块 chkconfig 检查,设置系统的各种服务 chkconfig --list ----->列出各项服务状态 ntsysv 设置系统的各种服务 cpio 备份文件 压缩命令: *.Z compress 程式壓縮的檔案; *.bz2 bzip2 程式壓縮的檔案; *.gz gzip 程式壓縮的檔案; *.tar tar 程式打包的資料,並沒有壓縮過; *.tar.gz tar 程式打包的檔案,其中並且經過 gzip 的壓縮 compress filename 压缩文件 加[-d]解压 uncompress gzip filename 压缩 加[-d]解压 zcat 123.gz 查看压缩文件内容 bzip2 -z filename 压缩 加[-d]解压 bzcat filename.bz2 查看压缩文件内容 tar -cvf /home/123.tar /etc 打包,不压缩 tar -xvf 123.tar 解开包 tar -zxvf /home/123.tar.gz 以gzip解压 tar -jxvf /home/123.tar.bz2 以bzip2解压 tar -ztvf /tmp/etc.tar.gz 查看tar内容 cpio -covB > [file|device] 份份 cpio -icduv < [file|device] 还原
vi一般用法 一般模式 编辑模式 指令模式 h 左 a,i,r,o,A,I,R,O :w 保存 j 下 进入编辑模式 :w! 强制保存 k 上 dd 删除光标当前行 :q! 不保存离开 l 右 ndd 删除n行 :wq! 保存后离开 0 移动到行首 yy 复制当前行 :e! 还原原始档 $ 移动到行尾 nyy 复制n行 :w filename 另存为 H 屏幕最上 p,P 粘贴 :set nu 设置行号 M 屏幕中央 u 撤消 :set nonu 取消行号 L 屏幕最下 [Ctrl]+r 重做上一个动作 ZZ 保存离开 G 档案最后一行 [ctrl]+z 暂停退出 :set nohlsearch 永久地关闭高亮显示 /work 向下搜索 :sp 同时打开两个文档 ?work 向上搜索 [Ctrl]+w 两个文档设换 gg 移动到档案第一行 :nohlsearch 暂时关闭高亮显示
认识SHELL alias 显示当前所有的命令别名 alias lm="ls -al" 命令别名 unalias lm 取消命令别名 type 类似which exprot 设置或显示环境变量 exprot PATH="$PATH":/sbin 添加/sbin入PATH路径 echo $PATH 显示PATH路径 bash 进入子程序 name=yang 设定变量 unset name 取消变量 echo $name 显示变量的内容 myname="$name its me" & myname='$name its me' 单引号时$name失去变量内容 ciw=/etc/sysconfig/network-scripts/ 设置路径 env 列出所有环境变量 echo $RANDOM 显示随意产生的数 set 设置SHELL PS1='[\u@\h \w \A #\#]\$ ' 提示字元的設定 [root@linux ~]# read [-pt] variable -----------读取键盘输入的变量 參數: -p :後面可以接提示字元! -t :後面可以接等待的『秒數!』 declare 声明 shell 变量 ulimit -a 显示所有限制资料 ls /tmp/yang && echo "exist" || echo "not exist" 意思是說,當 ls /tmp/yang 執行後,若正確,就執行echo "exist" ,若有問題,就執行echo "not exist" echo $PATH | cut -d ':' -f 5 以:为分隔符,读取第5段内容 export | cut -c 10-20 读取第10到20个字节的内容 last | grep 'root' 搜索有root的一行,加[-v]反向搜索 cat /etc/passwd | sort 排序显示 cat /etc/passwd | wc 显示『行、字数、字节数』 正规表示法 [root@test root]# grep [-acinv] '搜尋字串' filename 參數說明: -a :將 binary 檔案以 text 檔案的方式搜尋資料 -c :計算找到 '搜尋字串' 的次數 -i :忽略大小寫的不同,所以大小寫視為相同 -n :順便輸出行號 -v :反向選擇,亦即顯示出沒有 '搜尋字串' 內容的那一行! grep -n 'the' 123.txt 搜索the字符 -----------搜尋特定字串 grep -n 't[ea]st' 123.txt 搜索test或taste两个字符---------利用 [] 來搜尋集合字元 grep -n '[^g]oo' 123.txt 搜索前面不为g的oo-----------向選擇 [^] grep -n '[0-9]' 123.txt 搜索有0-9的数字 grep -n '^the' 123.txt 搜索以the为行首-----------行首搜索^ grep -n '^[^a-zA-Z]' 123.txt 搜索不以英文字母开头 grep -n '[a-z]$' 123.txt 搜索以a-z结尾的行---------- 行尾搜索$ grep -n 'g..d' 123.txt 搜索开头g结尾d字符----------任意一個字元 . grep -n 'ooo*' 123.txt 搜索至少有两个oo的字符---------重複字元 * sed 文本流编辑器 利用脚本命令来处理文本文件 awd 模式扫描和处理语言 nl 123.txt | sed '2,5d' 删除第二到第五行的内容 diff 比较文件的差异 cmp 比较两个文件是否有差异 patch 修补文件 pr 要打印的文件格式化 帐号管理 /etc/passwd 系统帐号信息 /etc/shadow 帐号密码信息 经MD5 32位加密 在密码栏前面加『 * 』『 ! 』禁止使用某帐号 /etc/group 系统群组信息 /etc/gshadow newgrp 改变登陆组 useradd & adduser 建立新用户 ---------> useradd -m test 自动建立用户的登入目录 useradd -m -g pgroup test --------->指定所属级 /etc/default/useradd 相关设定 /etc/login.defs UID/GID 有關的設定 passwd 更改密码 -----------> passwd test usermod 修改用户帐号 userdel 删除帐号 ----------->userdel -r test chsh 更换登陆系统时使用的SHELL [-l]显示可用的SHELL;[-s]修改自己的SHELL chfn 改变finger指令显示的信息 finger 查找并显示用户信息 id 显示用户的ID -----------> id test groupadd 添加组 groupmod 与usermod类似 groupdel 删除组 su test 更改用户 su - 进入root,且使用root的环境变量 sudo 以其他身份来执行指令 visudo 编辑/etc/sudoers 加入一行『 test ALL=(ALL) ALL 』 %wheel ALL = (ALL) ALL 系统里所有wheel群组的用户都可用sudo %wheel ALL = (ALL) NOPASSWD: ALL wheel群组所有用户都不用密码NOPASSWD User_Alias ADMPW = vbird, dmtsai, vbird1, vbird3 加入ADMPW组 ADMPW ALL = NOPASSWD: !/usr/bin/passwd, /usr/bin/passwd [A-Za-z]*, \ !/usr/bin/passwd root 可以更改使用者密码,但不能更改root密码 (在指令前面加入 ! 代表不可) PAM (Pluggable Authentication Modules, 嵌入式模組) who & w 看谁在线 last 最近登陆主机的信息 lastlog 最近登入的時間 读取 /var/log/lastlog talk 与其他用户交谈 write 发送信息 write test [ctrl]+d 发送 mesg 设置终端机的写入权限 mesg n 禁止接收 mesg y wall 向所有用户发送信息 wall this is q test mail 写mail /etc/default/useradd 家目录默认设置 quota 显示磁盘已使用的空间与限制 quota -guvs ----->秀出目前 root 自己的 quota 限制值 quota -vu 查询 quotacheck 检查磁盘的使用空间与限制 quotacheck -avug ----->將所有的在 /etc/mtab 內,含有 quota 支援的 partition 進行掃瞄 [-m] 强制扫描 quota一定要是独立的分区,要有quota.user和quota.group两件文件,在/etc/fstab添加一句: /dev/hda3 /home ext3 defaults,usrquota,grpquota 1 2 chmod 600 quota* 设置完成,重启生效 edquota 编辑用户或群组的quota 用户,[g]群组,[p]复制,[t]设置宽限期限 edquota -a yang edquota -p yang -u young ----->复制 quotaon 开启磁盘空间限制 quotaon -auvg -------->啟動所有的具有 quota 的 filesystem quotaoff 关闭磁盘空间限制 quotaoff -a -------->關閉了 quota 的限制 repquota -av 查閱系統內所有的具有 quota 的 filesystem 的限值狀態 Quota 從開始準備 filesystem 的支援到整個設定結束的主要的步驟大概是: 1、設定 partition 的 filesystem 支援 quota 參數: 由於 quota 必須要讓 partition 上面的 filesystem 支援才行,一般來說, 支援度最好的是 ext2/ext3 , 其他的 filesystem 類型鳥哥我是沒有試過啦! 啟動 filesystem 支援 quota 最簡單就是編輯 /etc/fstab , 使得準備要開放的 quota 磁碟可以支援 quota 囉; 2、建立 quota 記錄檔: 剛剛前面講過,整個 quota 進行磁碟限制值記錄的檔案是 aquota.user/aquota.group, 要建立這兩個檔案就必須要先利用 quotacheck 掃瞄才行喔! 3、編輯 quota 限制值資料: 再來就是使用 edquota 來編輯每個使用者或群組的可使用空間囉; 4、重新掃瞄與啟動 quota : 設定好 quota 之後,建議可以再進行一次 quotacheck ,然後再以 quotaon 來啟動吧!
开机流程简介 1、載入 BIOS 的硬體資訊,並取得第一個開機裝置的代號; 2、讀取第一個開機裝置的 MBR 的 boot Loader (亦即是 lilo, grub, spfdisk 等等) 的開機資訊; 3、載入 Kernel 作業系統核心資訊, Kernel 開始解壓縮,並且嘗試驅動所有硬體裝置; 4、Kernel 執行 init 程式並取得 run-level 資訊; 5、init 執行 /etc/rc.d/rc.sysinit 檔案; 6、啟動核心的外掛模組 (/etc/modprobe.conf); 7、init 執行 run-level 的各個批次檔( Scripts ); 8、init 執行 /etc/rc.d/rc.local 檔案; 9、執行 /bin/login 程式,並等待使用者登入; 10、登入之後開始以 Shell 控管主機。 在/etc/rc.d/rc3.d內,以S开头的为开机启动,以K开头的为关闭,接着的数字代表执行顺序 GRUB vga设定 彩度\解析度 640x480 800x600 1024x768 1280x1024 bit 256 769 771 773 775 8 bit 32768 784 787 790 793 15 bit 65536 785 788 791 794 16 bit 16.8M 786 789 792 795 32 bit
./configure 检查系统信息 ./configure --help | more 帮助信息 make clean 清除之前留下的文件 make 编译 make install 安装 rpm -q ----->查询是否安装 rpm -ql ------>查询该套件所有的目录 rpm -qi ----->查询套件的说明资料 rpm -qc[d] ----->设定档与说明档 rpm -ivh ---->安装 rpm -V -------->查看套件有否更动过 rpm -e ------>删除 rpm -Uvh ------->升级安装 --nodeps ----->强行安装 --test ----->测试安装 July 22 [root@localhost ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 1305. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only)
Command (m for help):
命令还是敲得少吖,今天扩展了一下Linux 的磁盘,想新建一个分区来使用使用,才发现命令在用时方恨少吖..幸好人还不至于很笨.. 命令基本就如上图..可以使用:
fdisk /dev/sd*
然后按n..新建一个分区,这时候会提示你是要建立一个逻辑分区?还是一个主分区,看这选吧.
如果只建一个分区,基本上都是回车即可.不过如果你要建多个分区,那么就得计算磁柱与block size的数量了..
完毕后,按w.将table 写入到disk. 完毕后,需要重启操作系统,然后才能认到新的dev.
OK. init 6 完毕后, 格式化刚才划分好的分区,命令:
mkfs.etx3 /dev/sd**
OK.完毕.是时候挂载分区了.挂在哪,见人见志. If 我划分的分区是打算用来存储一些ISO,作为NFS服务器的根目录,OK, 那么我建立一个文件夹:
mkidr /nfs
mount /dev/sd** /nfs
OK.一切完毕,这时候你可以使用 df -h or fdisk -l 这两个命令是否已经挂载好了该dev.
最后,如果你需要以后每次都使用挂分区,你还得在/etc/fstab里面家上该语句:
vi /etv/fstab
add:
/dev/sd** /nfs ets3 defaults 1 2
好像就这语句,语句语法不太正确的话,看下上面的提示照搬即可.我也是凭着记忆写而已...希望可以对大家有点帮助...
Kt.CHoeng.
July 14 应该值得开心一下!
因为终于使用VCB有点体会了.
楼下丹麦哥们备份的shell写的不错,如果在整个过程中加上echo,会更完美些..
不过总体而言,速度还是不错的,毕竟在本地上进行备份,可以避免不少的麻烦,但是备份后再scp?虽然这是官方推荐,但是我觉得有些恶心,毕竟这就是蜗牛的速度了.
这也是没有共享存储,而又想体验一下VCB的方法.
总觉得VCB不能鱼和熊掌兼得.如果在本机上做备份,即使虚拟机是Linux,那么也照样备份,这确实很理想,如果是远程的VCB PROXY,那么就等于废了,对于使用Linux的用户简直就是噩梦..
不过,还是想尝试尝试,结合Tooms的bash.
1)在远程机器Windows 2003上共享一文件夹,命名"vcb_remote"
2)在ESX内挂载该文件夹.
[root@esx102 tmp]# mkdir vcb_remote [root@esx102 tmp]# mount -t smbfs -o username=administrator,password=VMware.com //192.168.11.22/vcb_remote /tmp/vcb_remote
(注意端口是否开放)
3)在Tooms的bash上将备份路径修改为/tmp/vcb_remote即可.
4)备份:
执行 ./backup
=======================================================
整个过程还是很安静,很缓慢的过程.毕竟这和先备份再scp没分别..出奇的慢, 每秒5M的速度,备份一个15G的Virtual machine要老半天,怎么混..
=======================================================
不过庆幸的是,各种各样的方法总是有的...在多方面的约束下还能实现,才是最重要的...
I was looking around the internet for a backup script to backup the VM guests on a standalone ESX 3.0 and was not finding any so I start to make my own. Things I need the script to-do was.
- HOT Backup of all VM guest on the server
- Backup of VM guests in any power state
- Backup to a local folder on the server where the remote backup server will pick them from and put it to tapes
- Auto cleanup of old backup log and VM files (older then 1 day)
- Execute one script if there was a error and another if there was no error
- No SAN, work on a standalone ESX server with local storage
and yes I know esxRanger 2.0 for ESX 3.0 can do all this, but that product was not finish and public when I start to make this script, maybe I will change to esxRanger but that will time tell or maybe I will use them both
Please be nice as this is my first Linux bash script and I am just a windows admin ;-) so there is for sure a number of error and smarter ways to do thing, but it works for me.. and if you give me feedback I will fix the script.
Here is the script and how to use it
1. login login as root on the ESX 3.0 console
2. edit backuptools.conf First edit the /etc/vmware/backuptools.conf file by running the command "nano /etc/vmware/backuptools.conf" This is need in order for the vmware backup tools to work... Out comment the red lines and put in the blue lines
|
# # URL for the VC SDK instance to connect to. The format is # [:port] # # VCHOST=myvirtualcenter.company.com VCHOST=localhost
# # Username to use for VC SDK authentication # # USERNAME=backup USERNAME=root
# # Password to user for VC SDK authentication # WARNING: It is recommended that you don't specify the # password in the configuration file. # # PASSWORD=XXX PASSWORD=YourPassword
| note the best thing will be to make a account for backup and not use the root account.
3. make a folder for the backup script make a folder with the command "mkdir /etc/esxbackup"
4. backup script make the script by using the command "nano /etc/esxbackup/backup.bash" and copy the script below into it. change the $TOfolder to be where you like the backup to be put.
|
########################################################################### #!/bin/bash # # ESX 3.0 Backup script build by Tooms@tooms.dk # # 20060905 Minor fixs by tooms # 20060830 First version by tooms # # Change the $TOfolder to be the folder where the backup files will be placed in # #
########################################################################### # Path the vmware apps need. PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
########################################################################### # the base Path where the backup will be placed # Change this path to match your setup TOfolder=/vmfs/volumes/storage1/backup
############################################################################ # make the sub folder name ready from date/time DTfolder=$(date '+%Y%m%d-%H%M')
############################################################################ # making the base folders ready if not exist if test ! -x "$TOfolder" ; then mkdir -p $TOfolder fi
############################################################################ # make a log file ready rm -f $TOfolder/backup.log Backuplog=$TOfolder/backup.log echo " " >>$Backuplog echo "The Date/time is $(date '+%Y%m%d-%H%M%S')" >>$Backuplog echo " " >>$Backuplog
############################################################################ # making the sub-folders ready if there not exist if test ! -x "$TOfolder/$DTfolder" ; then echo "Make folder: $TOfolder/$DTfolder" >>$Backuplog mkdir -p $TOfolder/$DTfolder fi if test ! -x "$TOfolder/$DTfolder/vm" ; then echo "Make folder: $TOfolder/$DTfolder/vm" >>$Backuplog mkdir -p $TOfolder/$DTfolder/vm fi if test ! -x "$TOfolder/$DTfolder/log" ; then echo "Make folder: $TOfolder/$DTfolder/log" >>$Backuplog mkdir -p $TOfolder/$DTfolder/log fi
############################################################################ # move backup log to the new subfolder mv $TOfolder/backup.log $TOfolder/$DTfolder/log/ Backuplog=$TOfolder/$DTfolder/log/backup.log echo " " >>$Backuplog echo "Move backup log to $Backuplog" >>$Backuplog
############################################################################ # build content log of $TOfolder before backup and cleanup echo " " >>$Backuplog echo "Build content_before.log of $TOfolder before backup and cleanup" >>$Backuplog ls -R -la $TOfolder >>$TOfolder/$DTfolder/log/content_before.log
############################################################################ # Delete content from the $TOfolder there is older then 1 day echo " " >>$Backuplog echo "Delete content from the $TOfolder there is older then 1 day" >>$Backuplog find $TOfolder/* -type d -maxdepth 0 -mtime +1 -exec rm -d -r -f -v {} >>$Backuplog \;
############################################################################ # Delete old vcbSnapAll logfiles from /var/log/vmware/ there is older then 1 day echo " " >>$Backuplog echo "Delete old vcbSnapAll logfiles from /var/log/vmware/ there is older then 5 min." >>$Backuplog find /var/log/vmware/vcbSnapAll-* -type d -maxdepth 0 -mtime +1 -exec rm -d -r -f -v {} >>$Backuplog \;
############################################################################ # make the VM export/backup echo " " >>$Backuplog echo "Laver export af alle VM" >>$Backuplog vcbSnapAll -a any -r $TOfolder/$DTfolder/vm/ -L 6 >>$Backuplog
############################################################################ # Getting the exitcode from vcbSnapAll vcbSnapAll_exitcode=$(expr $?) echo " " >>$Backuplog echo "The exitcode is $vcbSnapAll_exitcode" >>$Backuplog
############################################################################ # copy the vcbSnapAll logfiles to the logfolder echo " " >>$Backuplog echo "copy the vcbSnapAll logfiles to $TOfolder/$DTfolder/log/" >>$Backuplog cp -r -v /var/log/vmware/vcbSnapAll-* $TOfolder/$DTfolder/log/ >>$Backuplog
############################################################################ # build content log of $TOfolder after backup and cleanup echo " " >>$Backuplog echo "Build content_after.log of $TOfolder after backup and cleanup" >>$Backuplog ls -R -la $TOfolder >>$TOfolder/$DTfolder/log/content_after.log
############################################################################ # write end time in logfile echo " " >>$Backuplog echo "The Date/time is $(date '+%Y%m%d-%H%M%S')" >>$Backuplog
############################################################################ # Checking for errors echo " " >>$Backuplog if [ $vcbSnapAll_exitcode = 0 ]; then echo "Error: none" >>$Backuplog echo " " >>$Backuplog #run script if all okey ! else echo "Error: got exitcode $vcbSnapAll_exitcode" >>$Backuplog echo " " >>$Backuplog #run script if there is a error ! fi
| 5. Make it a scriptrun this command "chmod 777 /etc/esxbackup/backup.bash" to make it a script there can be run from the commandline 6. When to run the backup
edit the crontap fil with the command "nano /etc/crontap" to run the script at 21:00 every evening Add the line mark with blue
SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/
# run-parts 01 * * * * root run-parts /etc/cron.hourly 02 4 * * * root run-parts /etc/cron.daily 22 4 * * 0 root run-parts /etc/cron.weekly 42 4 1 * * root run-parts /etc/cron.monthly 00 21 * * * root /etc/esxbackup/backup.bash | 7. Try the script
Try the script by running the command "/etc/esxbackup/backup.bash"
8. Look at the backup log Look at the backup log with the command "nano /vmfs/volumes/storage1/backup/20060905-1800/log/backup.log" note that the path will offcource not be the same when you use it...
9. Backup to tape Now setup your remote backup server to backup any thing in the /vmfs/volumes/storage1/backup folder, I use Backup Exec 10D on a windows server with the backup exec 9.1 linux agent installed in the ESX 3.0 server COS. That works very well with backup speed at around 1500mb/min over a 1gbit network with a LTO3 24 tape autoloader from Dell on the windows server.
And yes before you ask how to restore a VM from the backup folder...... First turn off the VM there need to be restore and do like this
[root@ESX3 root]# vcbRestore -s /vmfs/volumes/storage1/backup/20060905-1800/vm/vm01/ -b overwrite [2006-09-06 18:30:00.140 'App' 3076448384 info] Current working directory: /root [2006-09-06 18:30:00.157 'BaseLibs' 11344816 warning] [Vmdb_Unset] Unsetting unknown path: /vmomi/
Converting "/vmfs/volumes/storage2//VM_vm01/vm01.vmdk" (VMFS (flat)): 0%=====================50%=====================100% **************************************************
[root@ESX3 root]# |
Now turn on the VM that is just restore and verify it is working.
hope this help you on the way and works on your box, let me know in the forum if you have any smart things there need to be add to the backup script and I will then update it from time to time...
not bad from a windows admin with only a very little linux skills ;-)
July 05 fuser -v /folder/ --察看该目录的使用状况
fuser -km /folder/ --结束该目录下所有活动
Connecting Network Resources
=======================
NFS
-----------------------------
to disconver : showmount -e ip
to connection : mount ip:/share/dir /mnt/nfs
========================
!!!绿色部分需要修改!!!
SMB
-------------------------------
to disconver : smbclient -L ip -N
to connection : mount //ip/share_name /mnt/smb -o username=account%password
========================
[root@localhost /]#vmkfstools -C vmfs3 -b 8M -S name /vmfs/devices/disks/vmhba0\:0\:0\:2
其中
-C 添加/格式vmfs分区
-b 设置block size:1M,2M,4M,8M
-S 设置存储的名字
/vmfs/devices/disks/vmhba0\:0\:0\:2 指定格式化的位置,可以简化成直 vmhba0\:0\:0\:2
查看相对应的hba卡地址,可以使用:
esxcfg-vmhbadevs
or
esxcfg-vmhbadevs -m
|