Entries Tagged as ''

在SecureCRT之类的终端仿真程序的标题显示远程server的全部ip地址

作为系统管理员

大概都有这种体会

管理的机器多了

经常同时用终端仿真程序连好几台机器

而且需要一会儿在这台上操作、一会儿又需要在那台机器上操作

很容易搞混机器:)

bash通过环境变量PROMPT_COMMAND支持在显示提示符PS1之前执行命令

而且xterm的终端类型又支持更改标题

所以……呵呵

我用bash的环境变量PROMPT_COMMAND+xterm

可以说已经解决了这个问题

具体的方法是

vi /etc/sysconfig/bash-prompt-xterm

添加一行,像下面这样:

echo -ne "\e]2;$(/sbin/ip -4 -o addr show | awk ‘{print $4}’ | awk -F/ ‘{print $1}’ | grep -v "^127\." | sed -e :a -e ‘$!N;s/\n/\//g;ta’)\a"

如果终端显示模式不是xterm的话

需要用命令export TERM=xterm将终端显示模式设置成为xterm

即可

其实这个问题也有别的解决方法

把每台机器的hostname设成这台机器的ip

然后再通过环境变量PS1来把ip地址显示在提示符里

不过这需要把环境变量PS1中的\h改成\H

\H能显示完整的ip地址

\h只能显示一个字节

像这样:

export PS1="[@\H \W]\\$ "

redhat不同版本下kickstart文件中%pre部分支持的命令的区别

今天上班整理了一下装机用的kickstart文件

发现一个问题

我在FC3(Fedora Core 3)下做的kickstart文件

在FC4(Fedora Core 4)下稍稍改改就能用

但在AS3(RedHat enterprise advance server 3)下死活有问题

后来搞半天才明白

原来是我在kickstart文件的%pre部分的shell程序的问题

我在这一段脚本里用了命令awk

这在FC3、FC4,以及AS4(RedHat enterprise advance server 4)下都没有问题

但在AS3下就是不行(command not found)

也就是说AS3的kickstart文件执行到%pre部分脚本的时候

还没有命令awk(%pre部分运行完毕就可以了)

没办法

只好把AS3下的kickstart文件里%pre部分用到awk命令的部分重新用sed和cut实现了一下

幸好还有命令sed和cut能用

否则我还真搞不定

我想这也许是这几个系统用的busybox的版本不一样造成的

怎样在浏览器的地址栏里显示网站自定义的小图标

用firefox看一些网站的时候

在地址栏里经常能看到一些各式各样的小图标

如果添加到bookmark里后

bookmark列表里地址前面也会有小图标

感觉挺有意思

就留意了一下

发现是在html代码里指定:

<link href="http://www.xiaoyuer.cn/gallery/images/favicon.ico" rel="shortcut icon"/>

 

这里的"http://www.xiaoyuer.cn/gallery/images/favicon.ico" 指的就是显示的小图标

注意:这个小图标只能是16×16像素、16色

在ie5以上的浏览器里,则只需要把favicon.ico放到网站根目录即可

怎样判断linux系统是用lilo起的还是用grub起的

以前在redhat下我总是来看文件/etc/lilo.conf存不存在

和/boot/grub/目录下文件的多寡来判断系统是用什么起的的

后来发现网上有人写了个脚本

 

if dd if=/dev/hda bs=446 count=1 | strings | grep -q GRUB; then

echo "Your bootloader is GRUB"

elif dd if=/dev/hda bs=446 count=1 | strings | grep LILO; then

echo "Your bootloader is LILO"

else

echo "Unknown bootloader"

fi

这里的/dev/hda应该是系统盘的设备号

如何避免Sun主机被拔掉键盘后进入OBP

转自fullbird的blog

Sun Sparc主机拔掉键盘系统会进入OBP(open boot prom),

这是由于在插拔这种键盘的时候会发出break信号,

这样系统检测到就会进入这个状态。

一般在我们公司是象Sun Enterprise系列如220R,420R,450,4500等都会这样,

尤其是我们使用kvm就会碰到这个问题,

对于Sun Fire系列没有这个问题,

是由于这种是新机型,

默认装系统时KEYBOARD_ABORT=alternate。

如果碰到这种情形,最快恢复系统的办法就是:

ok>go

为了避免这种情形发生,

修改下列参数(这个办法只是在solaris 8以后才支持):

vi /etc/default/kbd

KEYBOARD_ABORT=alternate

保存

kbd -i就可以了

注释:enable代表不允许拔掉键盘,

不禁止STOP+A这是默认设置

disable代表允许拔掉键盘,但会禁止STOP+A

alternate代表允许拔掉键盘,同时也不禁止STOP +A

转自fullbird的blog

resin3的log的rotate问题

有台机器跑的resin3.0.7

我对他的log一直比较困惑

显然log文件是根据某个条件rotate的

但是怎样限定保留log文件的个数呢

于是翻看了resin3的关于log的文档

这里面好像也没有什么解决方法

但是在"log"这个tags里举的例子里发现一个属性:rollover-count

看起来好像能实现这个功能

但整篇文档都没提到这个属性是作什么用的

也不知道能不能用在stdout-log、stderr-log和access-log这三种tags里

redhat as3下做yum server的问题

昨天在公司用一台as3的机器搭建一个yum server玩儿

原来是打算用来升级Fedora用的

按照一般方式

找了些文档

就开始做

先去官方站点下载yum装上(因为redhat没有发布yum的rpm包)

http://linux.duke.edu/projects/yum/download/2.2/yum-2.2.2-1.src.rpm

把这个当下来

rpmbuild –rebuild一下然后装上

看文档说yum-arch dir就可以了

做yum-arch的时候系统有一句提示:

THIS PROGRAM IS DEPRECATED!

You should be generating xml metadata instead.

Please see http://linux.duke.edu/metadata

当时没注意

我在Fedora Core 3的机器上配好yum.conf后

执行yum update的时候

却发现系统报一堆repodata目录下的东西找不到的错误

于是再回头yum-arch的时候才留意到这个错误

按照地址进去

发现要装一个createrepo的软件

Fedora自己带的有

但是as3没有

于是http://linux.duke.edu/projects/metadata/generate/createrepo-0.4.3-1.src.rpm

rpmbuild –rebuild了一把,装上

再个createrepo dir;yum-arch dir

这下再在Fedora Core 3上yum update再不报错了

这个问题在所有的中文文档上都没有提到过

看来有的时候还是需要自己摸索

用来生成/dev好些loop*设备文件的一个脚本(第一次用命令seq)

我的一台linux机器得mount好多好多的iso文件

缺省系统带的8个loop设备文件(从/dev/loop0到/dev/loop7)不够用

于是我在/etc/modprobe.conf中添加了一句:

options loop max_loop=200

然后用个脚本在/dev目录下生成设备文件loop8到loop199

<code>

for i in `seq 21 200`; do mknod -m 660 loop$i b 7, $i; chown root:disk loop$i; done

</code>

再重起

就ok了

hp585的服务器的远程控制器ilo居然也有被远程控制的漏洞!

日期: 05-8-9

文档描述: SSRT051005 rev.0 - HP ProLiant DL585 Servers Unauthorized Remote Access

文档代码: HPSBMA01220

你可以对此文档提供反馈

HP SECURITY BULLETIN

 

——————————————————————————–

 

HPSBMA01220     REVISION: 0

 

SSRT051005 rev.0 - HP ProLiant DL585 Servers Unauthorized Remote Access

 

——————————————————————————–

NOTICE:  

 There are no restrictions for distribution of this Security Bulletin provided that it remains complete and intact.

 

 The information in this Security Bulletin should be acted upon as soon as possible.

 

INITIAL RELEASE:    09 August 2005

 

LAST UPDATED: 11 August 2005

 

POTENTIAL SECURITY IMPACT:    Unauthorized remote access

 

SOURCE:    Hewlett-Packard Company

HP Software Security Response Team

 

VULNERABILITY SUMMARY:

A potential vulnerability has been identified with the HP ProLiant DL585 server, where a remote unauthorized user may gain access to the server controls, when the server is powered down. 

REFERENCES:    None

 

SUPPORTED SOFTWARE VERSIONS*:  ONLY impacted versions are listed.

HP ProLiant DL585 Integrated Lights Out (ILO) firmware prior to version 1.81 

BACKGROUND:

For a PGP signed version of this Security Bulletin please write to security-alert@hp.com

RESOLUTION:

Until a new version of the Integrated Lights-Out firmware (version 1.81) for ProLiant DL585 servers is available, HP is providing the following workaround:

To eliminate this vulnerability until ILO version 1.81 becomes available, unplug the power cord whenever the server is powered down. This will prohibit the remote access exploit.

This Bulletin will be updated when version 1.81 of the Integrated Lights-Out (ILO) firmware becomes available.

 

BULLETIN REVISION HISTORY:

Initial release

    9 August 2005 

SUPPORT: For further information, contact normal HP Services support channel.

 

REPORT: To report a potential security vulnerability with any HP supported product, send Email to: security-alert@hp.com. It is strongly recommended that security related information being communicated to HP be encrypted using PGP, especially exploit information. To obtain the security-alert PGP key please send an e-mail message to security-alert@hp.com with the Subject of ‘get key’ (no quotes).

 

SUBSCRIBE: To initiate a subscription to receive future HP Security Bulletins via Email:

http://h30046.www3.hp.com/driverAlertProfile.php?regioncode=NA&langcode=USENG&jumpid=in_SC-GEN__driverITRC&topiccode=ITRC

On the web page: ITRC security bulletins and patch sign-up

Under Step1: your IRTC security bulletins and patches

     - check ALL categories for which alerts are required and continue.

Under Step2: your IRTC operating systems

     - verify your operating system selections are checked and save.

To update an existing subscription:

http://h30046.www3.hp.com/subSignIn.php

Log in on the web page Subscriber’s choice for Business: sign-in.

On the Web page: Subscriber’s Choice: your profile summary - use Edit Profile to update appropriate sections.

To review previously published Security Bulletins visit: http://www.itrc.hp.com/service/cki/secBullArchive.do

 

* The Software Product Category that this Security Bulletin relates to is represented by the 5th and 6th characters of the Bulletin number:

GN = HP General SW, MA = HP Management Agents, MI = Misc. 3rd party SW, MP = HP MPE/iX, NS = HP NonStop Servers, OV = HP OpenVMS, PI = HP Printing & Imaging, ST = HP Storage SW, TL = HP Trusted Linux, TU = HP Tru64 UNIX, UX = HP-UX, VV = HP Virtual Vault

 

System management and security procedures must be reviewed frequently to maintain system integrity. HP is continually reviewing and enhancing the security features of software products to provide customers with current secure solutions.

 

"HP is broadly distributing this Security Bulletin in order to bring to the attention of users of the affected HP products the important security information contained in this Bulletin. HP recommends that all users determine the applicability of this information to their individual situations and take appropriate action. HP does not warrant that this information is necessarily accurate or complete for all user situations and, consequently, HP will not be responsible for any damages resulting from user’s use or disregard of the information provided in this Bulletin. To the extent permitted by law, HP disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose, title and non-infringement."

Mysql调优

安装时的优化

(以下测试数据都来自于mysql的官方网站)

不要用rpm或其他二进制方式安装

要用源代码自己编译

如果是奔腾系统,推荐用pgcc编译器

且使用-O6的编译参数

这样编出来的mysql比用gcc2.95的要快1%

仅用用得着的字符集编译MySql

mysql目前支持多达34种不同的字符集(mysql4.1.11)

但我们常用的也无非就是latin1、gbk、utf8这三种而已

所以一般用编译参数

–with-charset=latin1 –with-extra-charsets=gbk,utf8

就行

用静态方式编译mysqld

用编译参数

–with-mysqld-ldflags=-all-static

在linux下将会提高13%的速度

编译时不要用参数–with-debug或者是–with-debug=all

–with-debug=all致使几乎所有的查询慢20%,有的更甚

仅是–with-debug也会带来15%的查询速度下降

如果编译的时候加了–with-debug=all参数

那么可以用–skip-safemalloc来启动服务器

这样速度影响跟–with-debug差不多

在跑在x86上的linux下用gcc不用frame pointers编译

也就是用参数-fomit-frame-pointer

或者是-fomit-frame-pointer -ffixed-ebp

这样会使mysqld快1-4%

用命令strip mysqld strip一下mysqld的二进制文件将会提高4%的速度

用unix socket来连本机的mysql服务器比用tcp/ip要快7.5%

(unix下,连主机名localhost缺省用的是unix socket)

所以仅从本机来连的mysql服务器

可以用参数–skip-networking来启动(将不监听3306端口)

用tcp/ip来连远程的mysql服务器比连本地的mysql服务器要慢8-11%

慎重使用secure connection(所有数据都会被ssl支持加密)

因为这样会比不加密慢55%

 

数据库设计时的优化

不要用ISAM类型表

ISAM是mysql最早的表类型,也是非事务性表类型

现在已经被MyISAM表类型所取代

MySQL4.1的版本里虽然还保留的有ISAM表类型

但已经不推荐使用

从Mysql5开始,ISAM表类型已被删掉

Mysql从3.23开始引入MyISAM和HEAP表类型

MyISAM用来提高ISAM表类型性能

HEAP就是所谓内存表

Mysql从3.23.25开始引入MERGE表类型

这种表类型允许把一些MyISAM表当作一个表来操作

MyISAM、HEAP、MERGE这三种表类型都是非事务性表类型

注:HEAP表类型已改名为MEMORY表类型

InnoDB和BDB是所谓的事务性表类型

也就是支持回滚的表类型

大约从Mysql3.23后面的一些版本开始被支持

从Mysql4.0开始被缺省支持

EXAMPLE表类型从Mysql4.1.3开始被引入

他其实没什么用

既不能存数据

也不能从里面取数据

只能做为演示用:)

NDB Cluster表类型用来实现把一个表分布到不同的计算机上

他从Mysql4.1.2的源代码发布和

Mysql-max4.1.3二进制发布里开始可用

ARCHIVE表类型从Mysql4.1.3开始被引入

他用来存储没有索引的巨大数目的数据在很小的脚印(footpring?)里

CVS表类型从Mysql4.1.4开始被引入

他用来存储用逗号分隔的格式的文本到文本文件里

FEDERATED表类型从Mysql5.0.3开始被引入

他用来在远程的服务器上存储数据

目前仅支持Mysql数据库

且用的是Mysql C Client API

非事务性表的优点:

速度快、存储省空间、update时省内存

 

Mysql服务器的优化

如果内存足够大,建议取消swap区

因为有些系统是那怕你还有free的内存他都要使用swap区的

使用参数–skip-external-locking来启动mysql

除非你在一台机器上跑着多个Mysql服务器

而且还存取同样的数据文件

可以使用参数–skip-name-resolve来启动mysql服务器

不过这样的话在grant权限给某台机器的时候就只能使用ip地址了

可以用命令mysqld –verbose –help来看mysql server的当前参数值

4.1版本的mysql可以忽略–verbose

如果mysql正在跑着

show variables显示服务器信息

show status显示系统状态和一些统计学数据

这两种信息也可以通过命令

mysqladmin variables和mysqladmin extended-status来获得

这些系统参数里最重要的是key_buffer_size和table_cache