supersun's space

  • 增大字号
  • 默认文字大小
  • 减小字号

AIX页面空间管理的一些操作


查看页面空间的信息

# lsps -a
Page Space      Physical Volume   Volume Group    Size %Used Active  Auto  Type
hd6             hdisk0            rootvg         512MB     1   yes   yes    lv

# lsps -c hd6
#Psname:Pvname:Vgname:Size:Used:Active:Auto:Type
hd6:hdisk0:rootvg:8:1:y:y:lv

# lsps -s
Total Paging Space   Percent Used
512MB               1%

清理无用的模块或代码
# slibclean

查看内存设备

# lsdev -Cc memory
L2cache0 Available  L2 Cache
mem0     Available  Memory

查看内存设备的属性
# lsattr -El mem0 -H
attribute value description                                user_settable
goodsize  1024  Amount of usable physical memory in Mbytes False
size      1024  Total amount of physical memory in Mbytes  False
查看二级缓存的属性
# lsattr -El L2cache0 -H
attribute value description                user_settable
size      1024  Size of L2 cache in Kbytes False


添加页面空间
# smit mkps
查看卷组的逻辑分区大小
# lsvg datavg
VOLUME GROUP:       datavg                   VG IDENTIFIER:  000c78cc00004c000000012567d527a9
VG STATE:           active                   PP SIZE:        16 megabyte(s)
VG PERMISSION:      read/write               TOTAL PPs:      2170 (34720 megabytes)
MAX LVs:            256                      FREE PPs:       2170 (34720 megabytes)
LVs:                0                        USED PPs:       0 (0 megabytes)
OPEN LVs:           0                        QUORUM:         2
TOTAL PVs:          1                        VG DESCRIPTORS: 2
STALE PVs:          0                        STALE PPs:      0
ACTIVE PVs:         1                        AUTO ON:        yes
MAX PPs per VG:     32512                                    
MAX PPs per PV:     3048                     MAX PVs:        10
LTG size (Dynamic): 256 kilobyte(s)          AUTO SYNC:      no
HOT SPARE:          no                       BB POLICY:      relocatable

# lsps -a
Page Space      Physical Volume   Volume Group    Size %Used Active  Auto  Type
hd6             hdisk0            rootvg         512MB     1   yes   yes    lv
创建页面空间:5个逻缉分区,-a系统启动时自动激活 -n 立即激活页面空间
# mkps -s5 -a -n datavg hdisk4
paging00

# lsps -a
Page Space      Physical Volume   Volume Group    Size %Used Active  Auto  Type
paging00        hdisk4            datavg          80MB     1   yes   yes    lv
hd6             hdisk0            rootvg         512MB     1   yes   yes    lv

使用mklv的方式添加页面空间,三步:
创建逻缉卷,指定类型为页面空间
# mklv -y pagespace00 -t paging datavg 5
pagespace00
设置系统启动时自动激活
# chps -a y pagespace00
当前激添页面空间
# swapon /dev/pagespace00

激活所有页面空间
# swapon -a
0517-075 swapon: Paging device /dev/hd6 is already active.
0517-075 swapon: Paging device /dev/pagespace00 is already active.

修改页面空间的属性
1、页面空间的大小更改;2、页面空间在系统启动时是否自动激活。
显示页面空间
# lsps -a
Page Space      Physical Volume   Volume Group    Size %Used Active  Auto  Type
pagespace00     hdisk4            datavg          80MB     1   yes   yes    lv
hd6             hdisk0            rootvg         512MB     1   yes   yes    lv
将页面空间pagespace00增加5个逻缉分区
# chps -s 5 pagespace00
显示页面空间
# lsps -a
Page Space      Physical Volume   Volume Group    Size %Used Active  Auto  Type
pagespace00     hdisk4            datavg         160MB     1   yes   yes    lv
hd6             hdisk0            rootvg         512MB     1   yes   yes    lv
将页面空间pagespace00减少8个逻缉分区
# chps -d 8 pagespace00
shrinkps: Temporary paging space paging00 created.
shrinkps: Paging space pagespace00 removed.
shrinkps: Paging space pagespace00 recreated with new size.
shrinkps: Resized and original paging space characteristics differ,
check the lslv command output.
显示页面空间
# lsps -a
Page Space      Physical Volume   Volume Group    Size %Used Active  Auto  Type
pagespace00     hdisk4            datavg          32MB     1   yes   yes    lv
hd6             hdisk0            rootvg         512MB     1   yes   yes    lv

# cat /etc/swapspaces
* /etc/swapspaces
*
* This file lists all the paging spaces that are automatically put into
* service on each system restart (the 'swapon -a' command executed from
* /etc/rc swaps on every device listed here).
*
* WARNING: Only paging space devices should be listed here.
*
* This file is modified by the chps, mkps and rmps commands and referenced
* by the lsps and swapon commands.

hd6:
dev = /dev/hd6

pagespace00:
dev = /dev/pagespace00

设置启动系统时不自动激活pagespace00
# chps -a n pagespace00
查看启动系统时自动激活的页面空间
# cat /etc/swapspaces
* /etc/swapspaces
*
* This file lists all the paging spaces that are automatically put into
* service on each system restart (the 'swapon -a' command executed from
* /etc/rc swaps on every device listed here).
*
* WARNING: Only paging space devices should be listed here.
*
* This file is modified by the chps, mkps and rmps commands and referenced
* by the lsps and swapon commands.

hd6:
dev = /dev/hd6



删除页面空间
1、查看系统启动时加载页面空间的列表配置文件
# cat /etc/swapspaces
* /etc/swapspaces
*
* This file lists all the paging spaces that are automatically put into
* service on each system restart (the 'swapon -a' command executed from
* /etc/rc swaps on every device listed here).
*
* WARNING: Only paging space devices should be listed here.
*
* This file is modified by the chps, mkps and rmps commands and referenced
* by the lsps and swapon commands.

hd6:
dev = /dev/hd6


paging00:
dev = /dev/paging00
2、关闭要卸载的交换空间
# swapoff /dev/paging00
3、删除页面空间
# rmps paging00
rmlv: Logical volume paging00 is removed.
4、查看系统启动时加载页面空间的列表配置文件
# cat /etc/swapspaces
* /etc/swapspaces
*
* This file lists all the paging spaces that are automatically put into
* service on each system restart (the 'swapon -a' command executed from
* /etc/rc swaps on every device listed here).
*
* WARNING: Only paging space devices should be listed here.
*
* This file is modified by the chps, mkps and rmps commands and referenced
* by the lsps and swapon commands.

hd6:
dev = /dev/hd6

 

开心网超级大亨物品价格收集脚本

下载地址:

开心网超级大亨物品价格收集脚本

用法:

1、下载并安装Perl:
http://downloads.activestate.com/ActivePerl/Windows/5.10/ActivePerl-5.10.1.1006-MSWin32-x86-291086.msi
如果是Linux系统需安装HTML::TreeBuilder模块。

2、设置账号:在user.txt中第一行为账号,第二行为密码

3、点击运行kaixin001.pl,生成超级大亨中物品价格数据,保存到rich_kaixin001.db中,并生成index.html文件。

4、点击index.html,查看价格表,灰色背景为当前价格。

最后更新于: 2009-12-08 09:45
 

cacti插件学习手札---monitor

原文链接:http://blog.chinaunix.net/u1/55815/showart_1003664.html

很早以前就已经开始使用cacti了,但一直一来都是简单的使用,并没有真正的翻看过cacti的相关东西,发现cacti还是很强大的,有很多插件的支持,而且还有很多人写的模板,今天就先讲讲monitor的安装,装好后的具体摸样如下图
1,首先要下载Plugin Architecture,这个使得cacti可以使用插件,目前的版本是2.1下载地址是http://cactiusers.org/downloads/cacti-plugin-arch.tar.gz
tar zxvf cacti-plugin-arch.tar.gz

安装:

cd cacti-plugin-arch
mv cacti-plugin-0.8.7b-PA-v2.1.diff /usr/local/apache2/htdocs/cacti
cd /usr/local/apache2/htdocs/cacti
patch -p1 -N < cacti-plugin-0.8.7b-PA-v2.1.diff



配置:

vi include/global.php

找到$config['url_path'] = "/";这行

如果你的cacti安装路径是

http://servername/projects/cacti/testing/

那就需要把这个参数改成

$config['url_path'] = "/projects/cacti/testing/";

如果你的cacti安装路径是

http://servername/cacti/

那这个参数就应该是

$config['url_path'] = "/cacti/";

保存后重启apache就ok了



2,接下来下载Monitor这个插件,目前最新版本0.8.2,地址:http://cactiusers.org/downloads/monitor.tar.gz
tar zxvf monitor.tar.gz -C /usr/local/apache2/htdocs/cacti/plugins
解压完毕后进入到/usr/local/apache2/htdocs/cacti/plugins/monitor目录
执行mysql -u root -p cacti
然后编辑cacti目录下的include/global.php文件
$plugins = array(); 找到这行,然后在他的下面添加
$plugins[] = 'monitor';
保存退出后就重启apache就可以看到monitor了

=================================

supersun

如果还使用了其他的插件,可以这样写:

$plugins = array();
//$plugins[] = 'thold';
$plugins[0] = 'weathermap';
$plugins[1] = 'monitor';

 

最后更新于: 2009-12-07 02:33
 

weathermap作为cacti插件的配置过程

安装步骤

  1. 安装apache
  2. 安装mysql
  3. 安装rrdtool
  4. 安装snmp
  5. 安装php
  6. 安装cacti及cacti-plugin
  7. 安装weathermap

详细步骤

1、安装apache

下载源码包:
wget http://apache.freelamp.com/httpd/httpd-2.2.14.tar.bz2

指定apache的安装目录为/home/httpd,并让其可支持动态模块加载
tar jxvf httpd-2.2.14.tar.bz2
cd httpd-2.2.14
./configure --prefix=/home/httpd --enable-so
make
make install
启动apache,并测试访问

 

2、安装mysql

下载地址
http://dev.mysql.com/downloads/mysql/5.1.html#linux-rhel4-x86-32bit-rpms

rpm -e mysql-4.1.20-1.RHEL4.1.i386 --nodeps
rpm -ivh MySQL-server-community-5.1.39-0.rhel4.i386.rpm
rpm -ivh MySQL-client-community-5.1.39-0.rhel4.i386.rpm
rpm -ivh MySQL-devel-community-5.1.39-0.rhel4.i386.rpm
rpm -ivh MySQL-shared-community-5.1.39-0.rhel4.i386.rpm

 

3、安装rrdtool

 

阅读doc/rrdbuild.txt,按照文档安装rrdtool的依赖包,在此我将编译依赖包的命令整理了一下(仅针对rrdtool-1.3.8,根椐自己的实际情况,更改脚本前的几个变量),放在了文章的最后。

 

为了使生成的图形中显示中文日期,可作以下修改文件src/rrd_graph.c:

a、定位至xlab_t处


"%d"    改为 “%d日”
"%a"    改为 "周%a"
"Week %V"改为  "%V周"


b、定位至setlocale处:

setlocale(LC_ALL,"zh_CN")

 

编译rrdtool,注意此处的几个变量,应和前面脚本中的相同

 

export INSTALL_DIR="/usr/local/rrdtool"
export BUILD_DIR="/opt/rrdtool"
export CFLAGS="-O3 -fPIC"
export LDFLAGS="-Wl,--rpath -Wl,${INSTALL_DIR}/lib"
export PKG_CONFIG=$INSTALL_DIR/bin/pkg-config

cd $BUILD_DIR/rrdtool-1.3.8
./configure --prefix=$INSTALL_DIR --disable-tcl --disable-python
make clean
make
make install

 

4、安装snmp

 

安装以下几个RPM包:

 

net-snmp-perl
net-snmp-libs
net-snmp-devel
net-snmp-utils
net-snmp

 

5、安装php

 

可以自己的情况设定./configure的参数:

 

./configure --prefix=/home/php --with-apxs2=/home/httpd/bin/apxs --enable-sockets --with-mysql --with-zlib-dir=/usr/local/rrdtool/ --with-freetype-dir=/usr/local/rrdtool/ --with-png-dir=/usr/local/rrdtool/ --with-iconv-dir --with-ttf --with-gd --with-snmp --enable-mbstring
make && make install

 

httpd.conf中添加以下几条指令使其识别php文件:

 

LoadModule php5_module        modules/libphp5.so

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
DirectoryIndex index.html index.htm index.php

 

6、安装cacti及cacti-plugin

首先创建库及mysql账号

[root@localhost htdocs]# mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.39-community MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database cacti;
Query OK, 1 row affected (0.13 sec)

mysql> grant all on cacti.* to cactiuser@localhost identified by 'cactiuser';
Query OK, 0 rows affected (0.13 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

 

修改include/config.php配置cacti连接mysql的参数(偷懒了一下,在上一步操作中建立的库为cacti,用户名、密码都是cactiuser。

 

导入数据

 

mysql -ucactiuser -p cacti

 

 

添加cron

 

*/5 * * * *  /home/php/bin/php /var/www/html/cacti/poller.php > /dev/null 2>&1

 

设置目录权限(因为运行apache的用户是nobody)


chown -R nobody rra/ log/


下载cacti-plugin,并将其解压至cacti目录下

 

unzip /home/cacti-plugin-0.8.7e-PA-v2.5.zip

less Readme.txt

 

打补丁

 

patch -p1 -N < cacti-plugin-0.8.7e-PA-v2.5.diff

 

导入数据

 

mysql -ucactiuser -p cacti

 

更改include/global.php,在$plugins = array();下一行添加


$plugins[] = 'weathermap';

通过浏览器访问cacti,并对其进行设置

 

7、安装配置weathermap

 

将weathermap解压至plugins目录下,并设定文件的属主

 

登陆cacti

console-->user managerment-->admin-->Realm Permissions:



上面三项打勾

刷新console

在Management段多出Weathermaps

在Configuration段多出Plugin management

 

关于weatherap中node标签的中文问题:

 

可使用web编缉器定位node的位置,手动编缉weather.conf文件,修改需要添写中文信息部分(如节点的标签名等)。(使用在web编缉器编缉weathermap.conf时中文可能会出现乱码)(我的系统编码设定为zh_CN.UTF-8)。

 

参考文章

相关链接

其他

rrdtool依赖包编译脚本内容

#!/bin/sh

export INSTALL_DIR="/usr/local/rrdtool"
export BUILD_DIR="/opt/rrdtool"

export CFLAGS="-O3 -fPIC"
export LDFLAGS="-Wl,--rpath -Wl,${INSTALL_DIR}/lib"

test -d $BUILD_DIR || mkdir -p $BUILD_DIR


#download software
download_software (){
cd $BUILD_DIR
wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.3.8.tar.gz
wget http://pkgconfig.freedesktop.org/releases/pkg-config-0.23.tar.gz
wget http://oss.oetiker.ch/rrdtool/pub/libs/zlib-1.2.3.tar.gz
wget http://oss.oetiker.ch/rrdtool/pub/libs/libpng-1.2.18.tar.gz
wget http://oss.oetiker.ch/rrdtool/pub/libs/freetype-2.3.5.tar.gz
wget http://oss.oetiker.ch/rrdtool/pub/libs/libxml2-2.6.32.tar.gz
wget http://oss.oetiker.ch/rrdtool/pub/libs/fontconfig-2.4.2.tar.gz
wget http://oss.oetiker.ch/rrdtool/pub/libs/pixman-0.10.0.tar.gz
wget http://oss.oetiker.ch/rrdtool/pub/libs/cairo-1.6.4.tar.gz
wget http://oss.oetiker.ch/rrdtool/pub/libs/glib-2.15.4.tar.gz
wget http://oss.oetiker.ch/rrdtool/pub/libs/pango-1.21.1.tar.bz2
}

check_error (){
echo "安任意键将安装$1";
read hello;
}


download_software;

check_error pkg-config
gunzip -c pkg-config-0.23.tar.gz | tar xf -
cd pkg-config-0.23
./configure --prefix=$INSTALL_DIR
make
make install

export PKG_CONFIG=$INSTALL_DIR/bin/pkg-config

check_error zlib
cd $BUILD_DIR
gunzip -c zlib-1.2.3.tar.gz | tar xf -
cd zlib-1.2.3
./configure --prefix=$INSTALL_DIR --shared
make
make install


check_error libpng
cd $BUILD_DIR
gunzip -c libpng-1.2.18.tar.gz | tar xf -
cd libpng-1.2.18
./configure --prefix=$INSTALL_DIR
make
make install

check_error freetype
cd $BUILD_DIR
gunzip -c freetype-2.3.5.tar.gz | tar xf -
cd freetype-2.3.5
./configure --prefix=$INSTALL_DIR CFLAGS="-O3 -fPIC"
make
make install

export EGREP=egrep

check_error libxml2
cd $BUILD_DIR
gunzip -c libxml2-2.6.32.tar.gz | tar xf -
cd libxml2-2.6.32
./configure --prefix=$INSTALL_DIR
make
make install

check_error fontconfig
cd $BUILD_DIR
gunzip -c fontconfig-2.4.2.tar.gz   | tar xf -
cd fontconfig-2.4.2
./configure --prefix=$INSTALL_DIR --with-freetype-config=$INSTALL_DIR/bin/freetype-config
make
make install

check_error pixman
cd $BUILD_DIR
gunzip -c pixman-0.10.0.tar.gz  | tar xf -
cd pixman-0.10.0
./configure --prefix=$INSTALL_DIR
make
make install

check_error pixman
cd $BUILD_DIR
gunzip -c cairo-1.6.4.tar.gz   | tar xf -
cd cairo-1.6.4
./configure --prefix=$INSTALL_DIR \
--enable-xlib=no \
--enable-xlib-render=no \
--enable-win32=no
make
make install

check_error glib
cd $BUILD_DIR
gunzip -c glib-2.15.4.tar.gz  | tar xf -
cd glib-2.15.4
./configure --prefix=$INSTALL_DIR
make
make install

check_error pango
cd $BUILD_DIR
bunzip2 -c pango-1.21.1.tar.bz2 | tar xf -
cd pango-1.21.1
./configure --prefix=$INSTALL_DIR --without-x
make
make install

最后更新于: 2009-10-22 05:05
 

perl连接SQLite

需要安装DBD::SQLite模块

[root@localhost ~]# cat create_db.pl

#!/usr/bin/perl -w
use strict;

use DBI;

my $db_file="data.db";
#建立连接
my $dbh = DBI->connect("dbi:SQLite:dbname=$db_file","","");

#建表
$dbh->do("CREATE TABLE users(
username varchar(255),
password varchar(100),
born date,
test1 date,
test2 varchar(500),
test3 varchar(500),
urlt varchar(500))");

#建索引

$dbh->do("CREATE INDEX idx_name_users ON users(username)");
#插入数据
my $sth = $dbh->prepare(q{INSERT INTO users VALUES (?,?,?,?,?,?,?)});

foreach my $i (1,2,3,4){
$sth->bind_param(1,"ssss$i");
$sth->bind_param(2,"passwd");
$sth->bind_param(3,20090102);
$sth->bind_param(4,20090102);
$sth->bind_param(5,"none");
$sth->bind_param(6,"none");
$sth->bind_param(7,"http://www.supersun.biz");
$sth->execute or die $dbh->errstr;
}

$dbh->disconnect;


 

查询数据

[root@localhost ~]# cat db_view.pl


#!/usr/bin/perl -w
use strict;

use DBI;

my $db_file="data.db";

my $dbh = DBI->connect("dbi:SQLite:dbname=$db_file","","");

my $ary_ref=$dbh->selectall_arrayref(q{SELECT * FROM users});
foreach my $entry (@$ary_ref){
print "@$entry\n";
}

$dbh->disconnect;
[root@localhost ~]# perl db_view.pl
ssss1 passwd 20090102 20090102 none none http://www.supersun.biz
ssss2 passwd 20090102 20090102 none none http://www.supersun.biz
ssss3 passwd 20090102 20090102 none none http://www.supersun.biz
ssss4 passwd 20090102 20090102 none none http://www.supersun.biz

 

参考链接:http://updatedb.blog.hexun.com/7069108_d.html

 

 

最后更新于: 2009-10-15 06:24
 


页 3 总共 4