Blog

  • 使用Windows7-USB-DVD-tool制作windows7安装u盘

    微软早就推出了制作windows7的USB或DVD的工具,Windows7-USB-DVD-tool.exe(简称WUDT),教程:http://www.microsoftstore.com/store/msusa/html/pbPage.Help_Win7_usbdvd_dwnTool

    下载地址:

    http://images2.store.microsoft.com/prod/clustera/framework/w7udt/1.0/en-us/Windows7-USB-DVD-tool.exe

    此工具再加一个windows7的iso镜像,即可制作usb或dvd安装盘。但用u盘制作时出现以下错误:

    We were unable to copy your files. Please check your USB device and the selected ISO file and try again.

    说明你的u盘之前做过分区或mbr有问题,可以使用windows下的diskpart tool解决这个问题,方法如下:

    diskpart
    list disk
    select disk # (根据大小等特征选择u盘)
    clean (会覆盖当前u盘的mbr)
    create partition primary
    select partition 1
    active
    format quick fs=fat32 (快速格式化为fat32格式)
    assign
    exit

    参考:http://4sysops.com/archives/windows-7-usbdvd-download-tool-wudt-is-unable-to-copy-files/

  • 使用netboot方式安装debian

    手头上没有光盘怎么办,用netboot方式来安装debian

    安装debian的电脑需要支持pxe启动

    需要:深度远程启动管理器(netboot server, dhcp server, tftp server),debian的启动文件,网络环境要能上外网

    提供安装服务的电脑需要安装深度远程启动管理器,以及

    http://ftp.nl.debian.org/debian/dists/squeeze/main/installer-i386/current/images/netboot/

    下载netboot.tar.gz,将netboot.tar.gz解压到目录,如D:\netdebian

    接下来配置深度远程启动管理器,

    需要注意的有以下几点

    目录设置正确

    引导文件pxelinux.0

    然后启动时选择网络启动,接下来一步一步安装debian即可

  • 安装puppet和facter

    puppet是批量管理服务器的工具,常用的模式是服务器/客户端模式。服务端叫master,客户端叫agent。

    当agent连接到master时,puppet使用一个叫做facter的工具来返回agent相关信息

    # apt-cache search facter
     facter - a library for retrieving facts from operating systems
    • 在centos下安装

    puppet是基于ruby的,安装Ruby语言包、Ruby标准库和Ruby Shadow库

    yum install ruby ruby-libs ruby-shadow

    使用epel仓库,通过安装epel-release RPM包安装

    rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

    在master机上,安装puppet、puppet-server和facter

    yum install puppet puppet-server facter

    在agent机上,安装puppet facter

    yum install puppet facter

    如果使用ruby gem来安装(不推荐),则先安装rubygems包,使用如下命令安装puppet和facter

    yum install rubygems
    gem install puppet facter
    • debian/ubuntu下安装

    安装ruby libshadow-ruby1.8

    apt-get install ruby libshadow-ruby1.8

    在master机上,安装puppet、puppet-server和facter

    apt-get install puppet puppetmaster facter

    在agent机上,安装 puppet facter

    apt-get install puppet facter

    这样puppet安装过程就完成了

    参考:http://docs.puppetlabs.com/guides/installation.html

  • 使用rpmbuild制作squid rpm包

    制作RPM包有很多好处,可以较快安装部署喜欢的配置,参数;对于大批量安装省时省力,是一件事半功倍的事。

    制作RPM需要准备好源码包和spec文件,安装好依赖和编译工具,熟悉制作RPM包的几个目录。
    制作rpm包目录说明:
    BUILD解压的目录
    BUILDROOT假定的安装目录(变量为$RPM_BUILD_ROOT%{buildroot})
    RPMS存放制作好的rpm包
    SOURCES存放源码包
    SPECS存放spec文件
    SRPMS存放srpm包

    这里制作squid的rpm包只需要将源码包放置到SOURCES中,再切换到SPEC目录中,运行

    rpmbuild -ba squid.2.7.spec

    在制作过程中需要注意的:

    制作RPM包不能使用root用户,因为权限过大,操作错误会造成较大影响。

    使用普通用户制作时,rpmbuild的宏定义可以在~/.rpmmacros中定义

    在spec中使用自定义宏的方法 %define macro_name value

    在spec中使用宏的方法是 %{macro_name}

    在spec中注释用#,注释信息中不可用%

    制作squid RPM包build过程时,出现的错误及解决

    出现../include/squid_md5.h:27:2: error: #error Cannot find OpenSSL MD5 headers
    解决:需要安装好openssl相关组件

    yum install -y openssl*

    出现rpmbuild: error: Installed (but unpackaged) file(s) found Solution
    解决:需要在段files写全目录

    %files%defattr(-,root,root,-)/path/to/dir//path/to/file/

    squid源码包下载地址:http://www.squid-cache.org/Versions/v2/2.7/squid-2.7.STABLE5.tar.bz2

    squid.2.7.spec内容

    %define squid_user squid
    #---RPM包信息
    #描述信息
    Summary:        hupu web proxy and content serving.
    #软件包名
    Name:           squid
    #软件包版本
    Version:        2.7.STABLE5
    #rpm包的发行版本,RPM包制作者自己定义,第几次制作找个包就写几次。
    Release:        3%{?dist}
    #rpm包的下载地址,如果没有下载地址可以写成源码包的官方地址
    URL:            http://www.squid-cache.org/Versions/v2/2.7/squid-2.7.STABLE5.tar.bz2
    #RPM包的密钥,可以去源码包找对应的密钥,涉及到版权信息。
    License:        Creative Commons Attribution Sharealike 2.5 License
    #rpm包的所属组
    Group:          System Environment/Daemons
    #指定rpm包的源文件,地址在_topdir/SOURCES
    Source0:        squid-2.7.STABLE5.tar.bz2
    #Source1:        squid.conf
    #指定rpm包的虚拟目录,类似DNS的chroot
    BuildRoot:      %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
    #取消自动添加依赖关系
    AutoReq: no
    #描述信息
    %description
    Squid is a fully-featured HTTP/1.0 proxy which is almost (but not quite - we're getting ther
    e!) a fully-featured HTTP/1.1 proxy. Squid offers a rich access control, authorization and l
    ogging environment to develop web proxy and content serving applications. Squid offers a ric
    h set of traffic optimization options, most of which are enabled by default for simpler inst
    81 lines yanked                                                                                                          1,1           Top
    #rpm包的所属组
    Group:          System Environment/Daemons
    #指定rpm包的源文件,地址在_topdir/SOURCES
    Source0:        squid-2.7.STABLE5.tar.bz2
    #Source1:        squid.conf
    #指定rpm包的虚拟目录,类似DNS的chroot
    BuildRoot:      %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
    #取消自动添加依赖关系
    AutoReq: no
    #描述信息
    %description
    Squid is a fully-featured HTTP/1.0 proxy which is almost (but not quite - we're getting ther
    e!) a fully-featured HTTP/1.1 proxy. Squid offers a rich access control, authorization and l
    ogging environment to develop web proxy and content serving applications. Squid offers a ric
    h set of traffic optimization options, most of which are enabled by default for simpler inst
    allation and high performance.
    
    #准备安装,解压 cd等都这这里进行
    #rpmbuild -bp
    %prep
    %setup -q
    
    #编译信息
    #rpmbuild -bc
    %build
    export DESTDIR=%{buildroot}
    ./configure --prefix=/usr/local/webserver/squid --enable-arp-acl --enable-snmp --enable-dlmalloc --with-pthreads --enable-epoll --enable-poll --disable-internal-dns --enable-stacktrace --enable-removal-policies=heap,lru --enable-delay-po
    ols --enable-storeio=ufs,aufs,diskd,coss,null --enable-external-acl --with-large-files --enable-large-files --enable-async-io --enable-dl-malloc --enable-ssl --enable-auth=basic,digest,negotiate,ntlm --enable-icmp --enable-large-cache-fi
    les
    make %{?_smp_mflags}
    
    #安装信息
    %install
    %{__rm} -rf %{buildroot}
    make install DESTDIR=%{buildroot}
    #%{__install} -p -D -m 0755 %{SOURCE1} %{buildroot}/usr/local/webserver/squid/etc/
    
    #可以写一下脚本,安装前,安装后,卸载前,卸载后等脚本
    %pre
    if [ $1 == 1 ]; then
        /usr/sbin/useradd -s /bin/false -r %{squid_user} 2>/dev/null || :
    fi
    %preun
    %post
    %postun
    
    #清除buildroot目录下的信息,以便不影响下次制作
    %clean
    %{__rm} -rf %{buildroot}
    
    #指定安装后的文件
    %files
    %defattr(-,%{squid_user},%{squid_user},0755)
    /usr/local/webserver/squid/bin/
    /usr/local/webserver/squid/libexec/
    /usr/local/webserver/squid/sbin/
    /usr/local/webserver/squid/share/
    %config(noreplace)  /usr/local/webserver/squid/etc/*
    
    #日志信息
    %changelog
    * Mon Jun 03 2013 -
    - second build
    * Fri May 31 2013 - Yangyang <[email protected]>
    - first build

    参考:

    http://wiki.centos.org/zh/HowTos/SetupRpmBuildEnvironment

    http://mageedu.blog.51cto.com/4265610/1205205

     

  • ubuntu安装配置nodejs

    安装nodejs,npm

    apt-get install nodejs
    apt-get install npm

    编写hello.js

    var http = require('http');
    http.createServer(
    function(req, res){
    res.writeHead(200, {'Content-Type':'text/plain'});
    res.end('hello node.js');
    }
    ).listen(8124,"127.0.0.1");
    console.log('Server running at http://127.0.0.1:8124/');

    运行

    node hello.js

    打开浏览器即可看到

    hello node.js

  • excel中vlookup函数的应用

    需求:ip与主机名对应,现在选出几个ip来,要能在右侧自动生成对应的主机名。

    VLOOKUP(lookup_value,table_array,col_index_num,range_lookup)

    按上面的参数顺序用语言描述为:查找的值,查找的区域,查找的目标值所在的列,精确查找还是模糊查找

    如果查找出现N/A这种情况,可以用iferror使其变为空,2007及以上版本适用

    =IFERROR(vlookup(1,2,3,0),0)

    更多查看:http://baike.baidu.com/view/3170068.htm?fromId=3153205

    视频教程:http://v.youku.com/v_show/id_XMzI5NDE0MDE2.html