月归档:一月 2012

AIX常用命令之查看cpu/memory/swap/network/disk信息

一.查看CPU

--物理cpu数
1.prtconf
Processor Type: PowerPC_POWER5
Number Of Processors: 2
Processor Clock Speed: 2097 MHz
CPU Type: 64-bit

2.lsdev
-bash-3.00$ lsdev -Cc processor
proc0 Available 00-00 Processor
proc2 Available 00-02 Processor

--逻辑cpu数
3.bindprocessor
-bash-3.00$ bindprocessor -q
The available processors are:  0 1 2 3

4.vmstat
-bash-3.00$ vmstat

System configuration: lcpu=4 mem=1904MB

kthr    memory              page              faults        cpu    
----- ----------- ------------------------ ------------ -----------
 r  b   avm   fre  re  pi  po  fr   sr  cy  in   sy  cs us sy id wa
 1  1 386273 51470   0   0   0   0    1   0 120 5221 937  1  2 97  1

5.smtctl
因为无权限执行,没有测试

二.查看内存

1.lsattr
-bash-3.00$  lsdev -Cc memory
L2cache0 Available  L2 Cache
mem0     Available  Memory
-bash-3.00$  lsattr -El L2cache0
size 1920 Size of L2 cache in Kbytes False
-bash-3.00$  lsattr -El mem0    
goodsize 1904 Amount of usable physical memory in Mbytes False
size     1904 Total amount of physical memory in Mbytes  False

2.prtconf
-bash-3.00$ prtconf|grep Memory|grep -v +
Memory Size: 1904 MB
Good Memory Size: 1904 MB

3.vmstat
-bash-3.00$ vmstat

System configuration: lcpu=4 mem=1904MB

kthr    memory              page              faults        cpu    
----- ----------- ------------------------ ------------ -----------
 r  b   avm   fre  re  pi  po  fr   sr  cy  in   sy  cs us sy id wa
 1  1 387550 50188   0   0   0   0    1   0 120 5221 937  1  2 97  1

4.topas
 MEMORY
Real,MB    1904
% Comp     76
% Noncomp  13
% Client   13

三.查看交互分区

1.lsps
-bash-3.00$ lsps -a 
Page Space      Physical Volume   Volume Group    Size %Used Active  Auto  Type
hd6             hdisk0            rootvg         512MB    38   yes   yes    lv

2.lsps
-bash-3.00$  lsps -s
Total Paging Space   Percent Used
      512MB              38%

3.prtconf
Paging Space Information
        Total Paging Space: 512MB
        Percent Used: 38%

4.topas
PAGING SPACE
Size,MB     512
% Used     38
% Free     62

四.查看网络配置

--网络硬件信息
1.lsdev
-bash-3.00$ lsdev -Cc adapter|grep ent
ent0      Available 0D-08 2-Port 10/100/1000 Base-TX PCI-X Adapter (14108902)
ent1      Available 0D-09 2-Port 10/100/1000 Base-TX PCI-X Adapter (14108902)

2.lscfg
-bash-3.00$ lscfg -vl ent0
  ent0             U788C.001.AAA8364-P1-T1  2-Port 10/100/1000 Base-TX PCI-X Adapter (14108902)

      2-Port 10/100/1000 Base-TX PCI-X Adapter:
        Network Address.............001125C5CDA4
        ROM Level.(alterable).......DV0210
        Hardware Location Code......U788C.001.AAA8364-P1-T1

--网络配置信息
3.ifconfig
-bash-3.00$ ifconfig -a
en0: flags=5e080863,c0<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),PSEG,LARGESEND,CHAIN>
        inet 192.168.1.18 netmask 0xffffff00 broadcast 192.168.1.255
         tcp_sendspace 131072 tcp_recvspace 65536
lo0: flags=e08084b<UP,BROADCAST,LOOPBACK,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT>
        inet 127.0.0.1 netmask 0xff000000 broadcast 127.255.255.255
        inet6 ::1/0
         tcp_sendspace 131072 tcp_recvspace 131072 rfc1323 1

4.netstat
-bash-3.00$ netstat -in|grep en
en0   1500  link#2      0.11.25.c5.cd.a4  1071676281     0 688122516     4     0
en0   1500  192.168.1   192.168.1.18      1071676281     0 688122516     4     0

5.lsattr
-bash-3.00$ lsattr -El en0
alias4                      IPv4 Alias including Subnet Mask           True
alias6                      IPv6 Alias including Prefix Length         True
arp           on            Address Resolution Protocol (ARP)          True
authority                   Authorized Users                           True
broadcast                   Broadcast Address                          True
mtu           1500          Maximum IP Packet Size for This Device     True
netaddr       192.168.1.18  Internet Address                           True
netaddr6                    IPv6 Internet Address                      True
netmask       255.255.255.0 Subnet Mask                                True
prefixlen                   Prefix Length for IPv6 Internet Address    True
remmtu        576           Maximum IP Packet Size for REMOTE Networks True
rfc1323                     Enable/Disable TCP RFC 1323 Window Scaling True
security      none          Security Level                             True
state         up            Current Interface Status                   True
tcp_mssdflt                 Set TCP Maximum Segment Size               True
tcp_nodelay                 Enable/Disable TCP_NODELAY Option          True
tcp_recvspace               Set Socket Buffer Space for Receiving      True
tcp_sendspace               Set Socket Buffer Space for Sending        True

--配置网络
ifconfig en0 192.168.0.5 netmask 255.255.255.0 up
chdev -l en1 -a netaddr='192.168.1.1' -a netmask='255.255.255.0'

五.查看硬盘

--硬盘使用情况
1.df
-bash-3.00$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/hd4              5.2G   77M  5.1G   2% /
/dev/hd2              5.5G  1.6G  4.0G  28% /usr
/dev/hd9var           640M  640M     0 100% /var
/dev/hd3              128M   48M   81M  38% /tmp
/dev/fwdump           128M  348K  128M   1% /var/adm/ras/platform
/dev/hd1              640M  580M   61M  91% /home0
/proc                    -     -     0   -  /proc
/dev/hd10opt          2.3G  496M  1.8G  22% /opt
192.168.2.5:/store/home
                      2.3T  576G  1.7T  26% /home
--物理硬盘
2.lspv
-bash-3.00$ lspv
hdisk0          000b45c0688a5c5d                    rootvg          active
hdisk1          00c97ac06a9cef35                    None            

-bash-3.00$ lspv hdisk0
PHYSICAL VOLUME:    hdisk0                   VOLUME GROUP:     rootvg
PV IDENTIFIER:      000b45c0688a5c5d VG IDENTIFIER     000b45c00000d7000000011b688a6044
PV STATE:           active                                     
STALE PARTITIONS:   0                        ALLOCATABLE:      yes
PP SIZE:            128 megabyte(s)          LOGICAL VOLUMES:  11
TOTAL PPs:          546 (69888 megabytes)    VG DESCRIPTORS:   2
FREE PPs:           417 (53376 megabytes)    HOT SPARE:        no
USED PPs:           129 (16512 megabytes)    MAX REQUEST:      256 kilobytes
FREE DISTRIBUTION:  109..90..00..109..109                      
USED DISTRIBUTION:  01..19..109..00..00  

3.lsdev
-bash-3.00$ lsdev -Cc disk
hdisk0 Available 0G-08-01-8,0 16 Bit LVD SCSI Disk Drive
hdisk1 Available 0G-08-01-5,0 16 Bit LVD SCSI Disk Drive

4.lsattr
-bash-3.00$ lsattr -El hdisk0
PCM             PCM/friend/scsiscsd                         Path Control Module           False
algorithm       fail_over                                   Algorithm                     True
dist_err_pcnt   0                                           Distributed Error Percentage  True
dist_tw_width   50                                          Distributed Error Sample Time True
hcheck_interval 0                                           Health Check Interval         True
hcheck_mode     nonactive                                   Health Check Mode             True
max_transfer    0x40000                                     Maximum TRANSFER Size         True
pvid            000b45c0688a5c5d0000000000000000            Physical volume identifier    False
queue_depth     3                                           Queue DEPTH                   False
reserve_policy  single_path                                 Reserve Policy                True
size_in_mb      73400                                       Size in Megabytes             False
unique_id       2B08004F478B0FHUS153073VL380008IBM   H0scsi Unique device identifier      False

5.lscfg
-bash-3.00$ lscfg -vpl hdisk0
  hdisk0           U788C.001.AAA8364-P1-T11-L8-L0  16 Bit LVD SCSI Disk Drive (73400 MB)

        Manufacturer................IBM   H0
        Machine Type and Model......HUS153073VL3800 
        FRU Number..................03N5282     
        ROS Level and ID............53343130
        Serial Number...............004F478B
        EC Level....................H17923Y   
        Part Number.................03N5281     
        Device Specific.(Z0)........000004129F00013A
        Device Specific.(Z1)........VBPSS410    
        Device Specific.(Z2)........0068
        Device Specific.(Z3)........08076
        Device Specific.(Z4)........0001
        Device Specific.(Z5)........22
        Device Specific.(Z6)........H17923Y   
        Brand.......................H0


  PLATFORM SPECIFIC

  Name:  sd
    Node:  sd
    Device Type:  block                      

--逻辑卷
6.lsvg
-bash-3.00$ lsvg
rootvg
-bash-3.00$ lsvg -l rootvg
rootvg:
LV NAME             TYPE       LPs     PPs     PVs  LV STATE      MOUNT POINT
hd5                 boot       1       1       1    closed/syncd  N/A
hd6                 paging     4       4       1    open/syncd    N/A
hd8                 jfs2log    1       1       1    open/syncd    N/A
hd4                 jfs2       41      41      1    open/syncd    /
hd2                 jfs2       44      44      1    open/syncd    /usr
hd9var              jfs2       5       5       1    open/syncd    /var
hd3                 jfs2       1       1       1    open/syncd    /tmp
hd1                 jfs2       5       5       1    open/syncd    /home0
hd10opt             jfs2       18      18      1    open/syncd    /opt
fwdump              jfs2       1       1       1    open/syncd    /var/adm/ras/platform
lg_dumplv           sysdump    8       8       1    open/syncd    N/A

7.lslv
-bash-3.00$ lslv  hd5
LOGICAL VOLUME:     hd5                    VOLUME GROUP:   rootvg
LV IDENTIFIER:      000b45c00000d7000000011b688a6044.1 PERMISSION:     read/write
VG STATE:           active/complete        LV STATE:       closed/syncd
TYPE:               boot                   WRITE VERIFY:   off
MAX LPs:            512                    PP SIZE:        128 megabyte(s)
COPIES:             1                      SCHED POLICY:   parallel
LPs:                1                      PPs:            1
STALE PPs:          0                      BB POLICY:      relocatable
INTER-POLICY:       minimum                RELOCATABLE:    no
INTRA-POLICY:       edge                   UPPER BOUND:    32
MOUNT POINT:        N/A                    LABEL:          primary_bootlv
MIRROR WRITE CONSISTENCY: on/ACTIVE                              
EACH LP COPY ON A SEPARATE PV ?: yes                                    
Serialize IO ?:     NO                    

8.prtconf
Volume Groups Information
============================================================================== 
rootvg:
PV_NAME           PV STATE          TOTAL PPs   FREE PPs    FREE DISTRIBUTION
hdisk0            active            546         417         109..90..00..109..109
============================================================================== 

9.topas
Disk    Busy%     KBPS     TPS KB-Read KB-Writ 
hdisk0   21.0     3.2K   20.0     0.0     3.2K
hdisk1    0.0     0.0     0.0     0.0     0.0 
cd0       0.0     0.0     0.0     0.0     0.0

六.说明
1.cpu/memory/swap/network/disk的主要信息都可以通过topas和parconf查看
2.这些命令还和shell的类型有很多关系,这里是bash

发表在 AIX | 评论关闭

dd操作数据文件

1.dd主要参数

       Copy a file, converting and formatting according to the operands.

       bs=BYTES
              force ibs=BYTES and obs=BYTES

       cbs=BYTES
              convert BYTES bytes at a time

       count=BLOCKS
              copy only BLOCKS input blocks

       ibs=BYTES
              read BYTES bytes at a time

       if=FILE
              read from FILE instead of stdin

       obs=BYTES
              write BYTES bytes at a time

       of=FILE
              write to FILE instead of stdout

       seek=BLOCKS
              skip BLOCKS obs-sized blocks at start of output

       skip=BLOCKS
              skip BLOCKS ibs-sized blocks at start of input

2.拷贝数据文件头部

[oracle@node1 chf]$ dd if=system01.dbf of=/tmp/dd_xifenfei01.dbf bs=8192 count=1
1+0 records in
1+0 records out
8192 bytes (8.2 kB) copied, 6.2e-05 seconds, 132 MB/s
[oracle@node1 chf]$ ll /tmp/dd_xifenfei01.dbf
-rw-r--r-- 1 oracle oinstall 8192 01-13 16:49 /tmp/dd_xifenfei01.dbf


BBED> set filename '/tmp/dd_xifenfei01.dbf'
        FILENAME        /tmp/dd_xifenfei01.dbf

BBED> set block 1
        BLOCK#          1

BBED> dump
 File: ././dd_xifenfei01.dbf (0)
 Block: 1                Offsets:    0 to  511           Dba:0x00000000
------------------------------------------------------------------------
 00a20000 0000c0ff 00000000 00000000 64590000 00200000 00a30200 7d7c7b7a 
 a0810000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 

 <32 bytes per line>

BBED> set block 2
BBED-00309: out of range block number (2)


BBED> set offset 8190
        OFFSET          8190

BBED> dump
 File: ././dd_xifenfei01.dbf (0)
 Block: 1                Offsets: 8190 to 8191           Dba:0x00000000
------------------------------------------------------------------------
 0000 

 <32 bytes per line>
--证明只有1个数据块(8192),并且拷贝数据文件头部成功

3.模拟创建文件

[oracle@node1 tmp]$ ll /tmp/dd_xifenfei02.dbf -h
-rw-r--r-- 1 oracle oinstall 1.0G 01-13 16:58 /tmp/dd_xifenfei02.dbf

4.拷贝数据块到一个文件中

[oracle@node1 chf]$ dd if=/tmp/dd_xifenfei01.dbf of=/tmp/dd_xifenfei02.dbf bs=8192 count=1
1+0 records in
1+0 records out
8192 bytes (8.2 kB) copied, 6e-05 seconds, 137 MB/s
[oracle@node1 chf]$ bbed
Password: 

BBED: Release 2.0.0.0.0 - Limited Production on Fri Jan 13 17:01:02 2012

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

************* !!! For Oracle Internal Use only !!! ***************

BBED> set filename '/tmp/dd_xifenfei02.dbf'

BBED> set block 1
        BLOCK#          1

BBED> dump
 File: ././dd_xifenfei02.dbf (0)
 Block: 1                Offsets:    0 to  511           Dba:0x00000000
------------------------------------------------------------------------
 00a20000 0000c0ff 00000000 00000000 64590000 00200000 00a30200 7d7c7b7a 
 a0810000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 

 <32 bytes per line>


BBED> set block 2
BBED-00309: out of range block number (2)


BBED> set offset 8190
        OFFSET          8190

BBED> dump
 File: ././dd_xifenfei02.dbf (0)
 Block: 1                Offsets: 8190 to 8191           Dba:0x00000000
------------------------------------------------------------------------
 0000 

 <32 bytes per line>

通过对比在2步骤中拷贝出来的数据文件头部,证明现在已经把该头部拷贝到了3步骤创建的新文件中

发表在 Linux | 一条评论

诡异dblink问题解决–dblink insert操作数据类型发生改变

1.展示列属性

[oracle@saas-xunzhi-db1 ~]$ sqlplus testga/testga

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Jan 12 16:26:56 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options

SQL> desc t_xifenfei;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 PROCESS_INSTANCE_ID                       NOT NULL NUMBER(10)
 STATUS_NEW                                         NUMBER
 PACKAGE_NAME                                       VARCHAR2(50)

SQL> desc wf_proc_inst@oldmoa
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ID                                        NOT NULL NUMBER(10)
 NAME                                               VARCHAR2(500)
 PROC_ID                                   NOT NULL NUMBER(10)
 PARE_INST_ID                              NOT NULL NUMBER(10)
 PARE_ACTI_ID                              NOT NULL NUMBER(10)
 INST_CREATOR                                       VARCHAR2(40)
 CREAT_DATE                                         DATE
 STATUS                                             CHAR(1)
 ATT1                                               NUMBER(10)
 ATT2                                               VARCHAR2(255)
 SEQVALUE                                           VARCHAR2(50)

从这里可以看出,原表的status列是char,而目标表的STATUS_NEW列是number类型

2.通过dblink查询列值

SQL> select t.inst_id as ID,
  2         case w.status
  3           when '0' then
  4            4
  5           when '2' then
  6            3
  7           else
  8            1
  9         end as  status_new,
 10         p.name as PACKAGE_NAME
 11    from wf_proc_inst@oldmoa i
 12    left join wf_proc_info_inst@oldmoa t on t.inst_id = i.id
 13    left join wf_proc_type@oldmoa p on t.type_id = p.id
 14    left join wf_proc_inst@oldmoa w on t.inst_id = w.id
 15   where t.inst_id = i.id
 16     and t.proc_id <> 53
 17     and t.is_ok = 1
 18     AND t.inst_id <= 4837 
 19     AND t.inst_id>=4735;

        ID STATUS_NEW PACKAGE_NAME
---------- ---------- --------------------------
      4755          3 呈批处理
      4836          3 公文处理

从这里可以看出来,case工作正常,传入的char类型,通过case转换为number类型

3.使用dblink插入数据并查询

SQL> INSERT INTO t_xifenfei
  2  select t.inst_id as ID,
  3         case w.status
  4           when '0' then
  5            4
  6           when '2' then
  7            3
  8           else
  9            1
 10         end as  status_new,
 11         p.name as PACKAGE_NAME
 12    from wf_proc_inst@oldmoa i
 13    left join wf_proc_info_inst@oldmoa t on t.inst_id = i.id
 14    left join wf_proc_type@oldmoa p on t.type_id = p.id
 15    left join wf_proc_inst@oldmoa w on t.inst_id = w.id
 16   where t.inst_id = i.id
 17     and t.proc_id <> 53
 18     and t.is_ok = 1
 19     AND t.inst_id <= 4837 
 20     AND t.inst_id>=4735;

2 rows created.

SQL> commit;

Commit complete.

SQL> col package_name for a10
SQL> select * from t_xifenfei;

PROCESS_INSTANCE_ID STATUS_NEW PACKAGE_NA
------------------- ---------- ----------
               4755          1 呈批处理
               4836          1 公文处理

这里出现异常,怀疑case中传入的值,都走到else那边了,怀疑是在使用dblink 的时候,char的类型发生的改变,转为了number,导致case匹配失败,所以走到else。

4.在dblink端创建视图,插入数据

SQL> CREATE VIEW GZZJ.v_xifenfei
  2  AS
  3  select t.inst_id as ID,
  4         case to_char(w.status)
  5           when '0' then
  6            4
  7           when '2' then
  8            3
  9           else
 10            1
 11         end as  status_new,
 12         p.name as PACKAGE_NAME
 13    from GZZJ.wf_proc_inst i
 14    left join GZZJ.wf_proc_info_inst t on t.inst_id = i.id
 15    left join GZZJ.wf_proc_type p on t.type_id = p.id
 16    left join GZZJ.wf_proc_inst w on t.inst_id = w.id
 17   where t.inst_id = i.id
 18     and t.proc_id <> 53
 19     and t.is_ok = 1
 20     AND t.inst_id <= 4837 
 21     AND t.inst_id>=4735;

View created.

SQL> insert into t_xifenfei 
  2  select * from v_xifenfei@oldmoa;

2 rows created.

SQL> commit;

Commit complete.

SQL> select * from t_xifenfei;

PROCESS_INSTANCE_ID STATUS_NEW PACKAGE_NA
------------------- ---------- ----------
               4755          3 呈批处理
               4836          3 公文处理

通过远程视图,接触数据类型发生改变异常(怀疑是dblink 在insert时候,char数据类型变成了number,但是未得到官方或者权威的确认)

发表在 Oracle | 一条评论