Category: Life

  • H3C 5024P操作命令

    两种权限模式

    user-view和system-view,退出system-view输入quit或ctrl+z

    user-view可以进行的操作很小,可用的命令有:

     debugging Enable system debugging functions
     display Display current system information
     ping Ping function
     quit Exit from current command view
     reboot Reset switch
     reset Reset operation
     save Save current configuration   #保存当前配置到EEPROM
     system-view Enter the system view
     undo Cancel current setting

    进行配置基本上都在system-view下进行,可用的命令有:

     display Display current system information
     interface Specify the interface configuration view
     link-aggregation Ports aggregation mode
     mac-address Configure MAC address
     mirroring-port Specify mirroring port
     monitor-port Specify monitor port
     ping Ping function
     qos QOS configuration information
     queue-scheduler Specify queue scheduling mode and parameters
     quit Exit from current command view
     restore Restore configuration
     return Exit to user view
     super Modify super password parameters
     sysname Specify the host name
     storm-control Limit the rate of the specified packets of the switch
     snmp-agent Specify SNMP(Simple Network Management Protocol)
     configuration information
     undo Cancel current setting
     user-interface Enter user interface view
     vlan Configure VLAN

    system-view下修改密码

    super password bigadmin  这个是进入system-view及网页管理界面的密码
    set authentication password admin  这个是telnet的密码

    设置主机名

    sysname hostnameofswitch

    查看交换机运行信息

    [SW4_R2_R2]display version
     H3C S5024P Product Version S5024P-R0109
     Copyright (c) 2004-2009 Hangzhou H3C Technologies Co., Ltd. All rights Reserved.
     H3C S5024P uptime is 8 week(s),2 day(s),15 hour(s),17 minute(s)
    
     H3C S5024P with 17M 8051 Processor
     128K bytes SDRAM
     2048K bytes Flash Memory
     Config Register points to EEPROM
     Hardware Version is Ver.1.0
     Bootrom Version is 100
     [Subslot 0] 24 GE(4 COMBO) Hardware Version is Ver.1.0

    查看聚合信息

    display link-aggregation GigabitEthernet 0/21

    查看学习到的mac地址

    display mac-address

    设置snmp-agent信息

    snmp-agent community read abcdefg

    h3c s5024p重置交换机

    system-view下

    [H3C]restore default
    This will restore the default configuration in the EEPROM memory
    Are you sure?[Y/N]y
    *** Restoring to default configuration...
    *** Restore default configuration successfully!
    Reboot the switch to activate the default configuration!

    其他h3c交换机重置

    reset saved-configuration
    reboot
  • linux小命令

    enable -a显示当前用户可用的命令

    less -N abc.txt 显示行号

    ls 1>/dev/null 2>/dev/null 把标准输出和标准错误都定向到/dev/null

    ls >/dev/null 2>&1 将标准输出到/dev/null再把错误输出到1
    检查执行脚本的用户是不是为root
    if [ `id -u` -ne "0" ]; then
    echo "ERROR: This script must be run as root." 1>&2
    exit 1
    fi

    检查硬盘通电时间

    安装 smartmontools ,包含有smartctl命令,

    smartctl -A -v 9,msec24hour32 /dev/sda

    -v 9,msec24hour32表示将第9行显示的标准从毫秒转为小时

    结果是

    9 Power_On_Hours 0x0032 100 100 000 Old_age Always – 41h+37m+34.450s

    sftp使用不同于默认端口连接服务器

    sftp -oPort=222 [email protected]
  • 整理python的csv.reader和csv.writer

    以下脚本是读取以空格分开的字段(weight.txt)变成以逗号分隔(weight.csv)

    #!/usr/bin/env python
    #-*- coding:utf-8 -*-
    # author jpuyy.com
    import csv
    reader = csv.reader(open('weight.txt', 'rb'), delimiter=' ', quoting=csv.QUOTE_NONE)
    writer = csv.writer(open('weight.csv', 'wb'))
        for row in reader:
        writer.writerow(row)

    解决 csv 用 excel 打开乱码问题

    import codecs
    
    file_obj = open(csv_name, "wb+")
    file_obj.write(codecs.BOM_UTF8)
    f = csv.writer(file_obj)
    
    
  • 如何防止学成一个废柴

    04年家里有了电脑,05年上网,到今年有8个年头了。

    早在07年就使用淘宝购物,使用支付宝

    08年就接触php,discuz

    毕业一年多了,从事IT,感觉快要成为一个废柴,一只脚已经站在废柴堆里了。

    IT这行,面太大了,现在搞linux,网络,每一个细小的方向都需要一大堆知识。如果转编程,又有更多的方向和路线。很早之前就听人说要精一门需要一万个小时,到现在视力下降,目标却还是在飘移。看看自己的博客,这么多分类目录,没有一个关注点。

    问题是:只允许一种选择的方向。

    已经深深的感受到:干IT如果不会编程,那永远是个二流货色。(这句话只适用于我自己)

    一方面需要尽快定位好如何去提升技术,提高自己被替代的技术壁垒,因为总有比你更年轻,更有时间精力,更能接受低价格的人去取代你;另一方面,想办法将技术转化为金钱,有金钱不光可以使生活过的好一些,还意味着可以尝试更大的梦想。

    毕业一年多以来,了解同学的情况,自然而然要进行比较。小结一下:

    各行各业都不好干,但是有兴趣确实能让人在这行走的更远

    既然没有稳定的不愁吃住的工作,那就需要有强大的应变不稳定的能力,而这些不稳定确实有压力,冒险,刺激,需要玩的起,而且离钱很近。

    最有风险的职业,也是离钱最近的,比如抢银行很有风险,但搞成了直接拿到的是现金。销售等职位,离钱最近。

    IT的技术职位离钱很远,做不到精通,还不如转行,生活不可能不需要钱。既然是青春饭,就要在青春时把青春饭吃好。

     

  • 使用dhclient重新获取ip地址

    dhcp的全称是Dynamic Host Configuration Protocol

    dhclient则是Dynamic Host Configuration Protocol client

    使用dhclient重新在dhcp服务器攻取ip地址

    dhclient -r eth0
    ifconfig eth0 down
    ifconfig eth0 up
    dhclient eth0

    经过上面操作,就会获取到新的ip地址。

    centos6的dhclient的信息缓存在/var/lib/dhclient/dhclient-*.leases

  • 建立一个yum源

    使用的工具是createrepo

    首先创建目录,

    mkdir -p mirrors.jpuyy.com/centos/6.4/os/x86_64

    并进入到此目录,执行

    createrepo .

    在当前目录下生成了repodata目录,记录了repo的信息。
    最终的rpm包都要放到Packages下

    目录结构参考http://mirrors.sohu.com。centos6的目录软链接到centos6.4

    mirrors.jpuyy.com
    └── centos
        ├── 6 -> 6.4
        ├── 6.0
        └── 6.4
            ├── centosplus
            ├── contrib
            ├── cr
            ├── extras
            ├── fasttrack
            ├── isos
            ├── os
            │   └── x86_64
            │       ├── EFI
            │       ├── images
            │       ├── isolinux
            │       ├── Packages
            │       │   ├── MariaDB-5.5.31-centos6-x86_64-client.rpm
            │       │   ├── MariaDB-5.5.31-centos6-x86_64-common.rpm
            │       │   ├── MariaDB-5.5.31-centos6-x86_64-devel.rpm
            │       │   ├── MariaDB-5.5.31-centos6-x86_64-server.rpm
            │       │   ├── MariaDB-5.5.31-centos6-x86_64-shared.rpm
            │       │   └── MariaDB-5.5.31-centos6-x86_64-test.rpm
            │       └── repodata
            │           ├── 0c2ce006b4ccb96b4d0947584daab68e971f25f0c59a2f856895a3dcc4760e0b-primary.xml.gz
            │           ├── 2a827a63089cb7561b755baff2c1ae4c202cd74a1a92e1274e85f9e4dac569a0-other.sqlite.bz2
            │           ├── 3e5e63e57c07f479edc526404f28c63c1ad097670cde380d3866b63090d6f3e0-filelists.xml.gz
            │           ├── 44a30e7cd6fd27e8f820ba7a50d329c99428ea68b4f0904475c5ee8961c1c8ec-primary.sqlite.bz2
            │           ├── b3d59bc4f2a6c3c198798e188b4a0d0af99692efaa88f989c47df4c036fea210-filelists.sqlite.bz2
            │           ├── f94e27df58d67783e29dd0aeca51ff7ffec2bc501e0f82e0a4c7d843dcb2cb6c-other.xml.gz
            │           └── repomd.xml
            ├── updates
            └── xen4

    这里的repo使用http提供服务,所以在nginx下,如果要酷一些的页面,可以编译nginx,添加fancyindex模块,http://wiki.nginx.org/NginxNgxFancyIndex

    server {
        listen 80;
        server_name mirrors.jpuyy.com;
        location / {
            root /data/mirrors.jpuyy.com/;
            autoindex on;
        }
    }

    在需要使用此源服务器上,添加/etc/yum.repos.d/jpuyy-mirrors.repo,写入

    [mirror-of-jpuyy]
    name=mirror-of-jpuyy
    baseurl=http://mirrors.jpuyy.com/centos/$releasever/os/$basearch/
    enabled=1
    gpgcheck=0