VMware 中Linux 调整分区大小

VMware 中Linux 调整分区大小

Fedora_logo

Precondition :VMware Player 中安装的Fedora 17 Linux 32bit,个人较久远的测试环境,安装时没有进行磁盘规划,默认20G空间(动态调整),安装在根/下。
Background :在上述环境中安装IBM DB2 Express-C 10.5(v10.5fp1_linuxia32_expc.tar.gz),安装时/tmp空间不足,无法安装。
Plan:需要进行磁盘扩容。考虑到使用VMware Player虚拟机。

1.首先调整虚拟机大小:player_vm_fedora

2.虚拟机开机,使用fdisk 命令新建新区 fdisk  /dev/sda 添加 /dev/sda3

3.接下来就贴代码了:

Fedora release 17 (Beefy Miracle)
Kernel 3.4.0-1.fc17.i686 on an i686 (0)

[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 6.5G 6.0G 529M 92% /
devtmpfs 494M 0 494M 0% /dev
tmpfs 502M 0 502M 0% /dev/shm
tmpfs 502M 940K 502M 1% /run
/dev/mapper/vg-lv_root 6.5G 6.0G 529M 92% /
tmpfs 502M 0 502M 0% /sys/fs/cgroup
tmpfs 502M 0 502M 0% /media
/dev/sda1 497M 81M 392M 17% /boot

[root@localhost ~]# # fdisk /dev/sda

[root@localhost ~]# fdisk -l

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders, total 62914560 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00002255

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 16777215 7875584 8e Linux LVM
/dev/sda3 16777216 62914559 23068672 83 Linux

Disk /dev/mapper/vg-lv_swap: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders, total 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/vg-lv_root: 6979 MB, 6979321856 bytes
255 heads, 63 sectors/track, 848 cylinders, total 13631488 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

[root@localhost ~]# pvcreate /dev/sda3
Writing physical volume data to disk "/dev/sda3"
Physical volume "/dev/sda3" successfully created

[root@localhost ~]# vgextend /dev/mapper/vg /dev/sda3 
Volume group "vg" successfully extended
[root@localhost ~]# lvextend -L +20G /dev/mapper/vg-lv_root
Extending logical volume lv_root to 26.50 GiB
Logical volume lv_root successfully resized

[root@localhost ~]# resize2fs /dev/mapper/vg-lv_root 
resize2fs 1.42 (29-Nov-2011)
Filesystem at /dev/mapper/vg-lv_root is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/mapper/vg-lv_root is now 6946816 blocks long.

[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 27G 6.2G 21G 24% /
devtmpfs 494M 0 494M 0% /dev
tmpfs 502M 0 502M 0% /dev/shm
tmpfs 502M 956K 502M 1% /run
/dev/mapper/vg-lv_root 27G 6.2G 21G 24% /
tmpfs 502M 0 502M 0% /sys/fs/cgroup
tmpfs 502M 0 502M 0% /media
/dev/sda1 497M 81M 392M 17% /boot
[root@localhost ~]#

至此,操作结束,空间调整为30GB,满足使用需求。当然,此方案针对虚拟机中已安装的没有采用LVM的linux分区大小调整,其它不必参考此方案。

AIX db2嵌入式SQL(sqc)编译

AIX db2嵌入式SQL(sqc)编译

编译SQC

使用C语言编写嵌入式SQL以访问DB2的程序,DB2预编译器可以将SQL语法直接转换为DB2行时服务应用程序编程接口(API)调用。

bind的主要作用是根据SQC中的SQL语句使用的表和操作指定访问时DB要使用的策略,是一种优化作用,以加快数据访问的速度。

aix_sqc 编译

 

预编译命令:

db2 prep *.sqc bindfile

bindfile参数作用是生成和sqc文件同名的.bnd文件。

接下来就和一般的C程序一样进行编译了,来看看这个简单的Makefile,AIX 编译64位的应用。

CHMOD =chmod 755
RM =rm -f
#export OBJECT_MODE=64
DB2_HOME=/opt/IBM/db2/V9.1
CFLAGS=  -q64 -qchars=signed -I.  -g -I$(DB2_HOME)/include
LDFLAGS = -b64 -g -L $(DB2_HOME)/lib64 -ldb2
DB2 =db2
BINHOME=$(HOME)/batch/bin

CC= xlc_r

#DB CONFIGURE
DBNAME = db2name
USEID = db2user
PASWD = db2pswd

ALL =$(BINHOME)/ApsBatchWS
all:$(ALL)
.SUFFIXES:
.SUFFIXES:.sqc .cpp .c .o
OBJS = dbcons.o serv.o util.o log.o flow.o

.sqc.o:
        $(DB2)  connect to $(DBNAME) user $(USEID) using $(PASWD)
        @$(RM)   *.bnd $*.c
        @$(DB2)  prep $< bindfile
        @$(DB2)  bind $*.bnd
        @$(DB2)  connect reset
        @$(DB2)  terminate
        @$(CC)  $(CFLAGS) -s -c  $*.c
.c.o:
        $(CC) -c $(CFLAGS)  $<
.cpp.o:
        $(CC) -c  $(CFLAGS)  $<

$(ALL) : $(OBJS)
        $(CC) $(CFLAGS)  $(OBJS) $(LDFLAGS) -o  $@
        $(CHMOD)  $@

clean:
        $(RM) *.o dbcon.c dbcons.bnd $(ALL)

看这里还有好多的例子:点击这里查看

sqc的编写方法这里就不再赘述,相关的文章已经太多了。