不管是管理1台,或者是上万台机器,puppet都能轻松搞定。让你的所有配置工作整齐划一。所谓配置管理系统,就是管理机器里面诸如文件,用户,进程,软件包这些资源。传统的方法要管理1千台相同的机器,可以选择cfengine,或者是for循环,其实for循环是用的最多的方法。

用puppet,可以运行一个服务器端,然后每个客户端通过ssl证书连接服务器,得到本机器的配置列表,然后更加列表的来完成配置工作。

所以如果硬件配置好了,你在一天之内配置好上万台机器是很轻松的事情。前提是大部分机器配置类似。google用puppet管理了6000多台mac桌面机器。

这个是puppet的官方主页:http://reductivelabs.com/projects/puppet

个人用户也很有用,可以把你常用的配置记录成puppet格式的配置文件,下次重装系统,只需要运行这个配置就能配置到你指定的状态。比如我自己的机器,就是所有的软件包和各种各样的配置全都搞好了。

性能测试工具sysbench简介

[不指定 2011/06/29 13:23 | by ipaddr ]

sysbench是一款开源的多线程性能测试工具,可以执行CPU/内存/线程/IO/数据库等方面的性能测试。数据库目前支持MySQL/Oracle/PostgreSQL。本文只是简单演示一下几种测试的用法,后续准备利用sysbench来对MySQL进行一系列的测试。具体的一些参数设置,需要根据不同的测试要求来进行调整。

下载
http://sourceforge.net/projects/sysbench/

第一部分
在Linux中可以将一部分内存mount为分区来使用,通常称之为RamDisk。
RamDisk有三种实现方式:
第一种就是传统意义上的,可以格式化,然后加载。
这在Linux内核2.0/2.2就已经支持,其不足之处是大小固定,之后不能改变。
为了能够使用Ramdisk,我们在编译内核时须将block device中的Ramdisk支持选上,它下面还有两个选项,一个是设定Ramdisk的大小,默认是4096k;另一个是initrd的支持。
如果对Ramdisk的支持已经编译进内核,我们就可以使用它了:
查看一下可用的RamDisk,使用ls /dev/ram*
首先创建一个目录,比如test,运行mkdir /mnt/test;
然后对/dev/ram0 创建文件系统,运行mke2fs /dev/ram0;
最后挂载 /dev/ram0,运行mount /dev/ram /mnt/test,就可以象对普通硬盘一样对它进行操作了。

更详细的内容可以参考: http://www.linuxfocus.org/ChineseGB/November1999/article124.html                                                 http://www.vanemery.com/Linux/Ramdisk/ramdisk.html

另两种则是内核2.4才支持的,通过Ramfs或者Tmpfs来实现:
它们不需经过格式化,用起来灵活,其大小随所需要的空间而增加或减少。

Ramfs顾名思义是内存文件系统,它它处于虚拟文件系统(VFS)层,而不像ramdisk那样基于虚拟在内存中的其他文件系统(ex2fs)。

因而,它无需格式化,可以创建多个,只要内存足够,在创建时可以指定其最大能使用的内存大小。
如果你的Linux已经将Ramfs编译进内核,你就可以很容易地使用Ramfs了。创建一个目录,加载Ramfs到该目录即可:
                  # mkdir  /testRam
                  # mount -t ramfs none /testRAM
缺省情况下,Ramfs被限制最多可使用内存大小的一半。可以通过maxsize(以kbyte为单位)选项来改变。
                  # mount -t ramfs none /testRAM -o maxsize=2000 (创建了一个限定最大使用内存为2M的ramdisk)


Tmpfs是一个虚拟内存文件系统,它不同于传统的用块设备形式来实现的Ramdisk,也不同于针对物理内存的Ramfs。
  Tmpfs可以使用物理内存,也可以使用交换分区。在Linux内核中,虚拟内存资源由物理内存(RAM)和交换分区组成,这些资源是由内核中的虚拟内存子系统来负责分配和管理。
  Tmpfs向虚拟内存子系统请求页来存储文件,它同Linux的其它请求页的部分一样,不知道分配给自己的页是在内存中还是在交换分区中。同Ramfs一样,其大小也不是固定的,而是随着所需要的空间而动态的增减。
   使用tmpfs,首先你编译内核时得选择"虚拟内存文件系统支持(Virtual memory filesystem support)" 。
  然后就可以加载tmpfs文件系统了:
            # mkdir -p /mnt/tmpfs
            # mount tmpfs /mnt/tmpfs -t tmpfs
  同样可以在加载时指定tmpfs文件系统大小的最大限制:
           # mount tmpfs /mnt/tmpfs -t tmpfs -o size=32m

使用df -aT命令可以看到有个/dev/shm目录,该目录的文件系统是tmpfs的,因此这个目录下的文件访问是非常快的,但是其大小可能不同机器都不一样,而且每次重启后文件也就丢失了。

第二部分
LINUX下我所接触过的内存文件系统有三个:

(1)ramdisk,使用前需要先创建文件系统,并且调整文件系统大小比较麻烦,需要修改内核引导参数并重新启动操作系统,在繁杂多变的应用与需要 7X24不间断运行的系统来说,并不是一个可以接受的选择.好处是自2.0版本起内核便支持(这也算好处?嗯,确实算,如果你手头真有这样的系统的话)

(2)ramfs,使用前不需要去创建文件系统了,直接通过mount的方式即可挂载上来用,需要的时候可以使用"mount -o remount,maxsize=..."这种方式来调整大小.

(3)tmpfs,同ramfs在表面上基本上一样啦,不同于ramfs针对"物理内存",tmpfs是在虚拟内存下分配空间的,也就是说tmpfs实例中存储的文件既可能存在于物理内存中,也可能存在于交换分区中,具体存在哪里,是由"虚拟内存子系统"来调度的.

纯性能角度讲,ramfs会在进程占用内存使用较多的情况下会优于tmpfs,在没有交换分区或进程占用内存较小而不发生swap行为的情况下,两者性能不会有差异(这个结论没有实测过,我"想当然"用猜的)

基本情况介绍完毕,下面介绍tmpfs的应用,(没办法,我手头机器内存不是那么宽裕...)

0,根据需要创建挂载目录,例:

mkdir -p $DIR_TMP;

1,挂载

mount my_tmpfs $DIR_TMP -t tmpfs -o size=512m

my_tmpfs
这个名字需要起,一个标识而已,会出现在df 的Filesytem一列,起个别致点的名字比较容易被自己写的其它监控脚本找到,如果非要起个none或tmpfs之类的名字的话...反正系统默认挂载的tmpfs都比较喜欢用这两个名字,好坏自己琢磨吧.

成功以后自己用df 看一下就知道了,写监控脚本时可以用"df -t tmpfs|grep ^my_tmpfs"来找到这一行.

2,调整

应用中如果感觉不合适,随时可以用mount命令调整

mount $DIR_TMP -o remount,size=1024m,nr_inodes=100k

nr_inodes为最大节点数,如果你的$DIR_TMP使用df命令查看明明有空间,却无法创建新文件(例如touch一个新文件),可能是文件节点用到上限了,可以用"df -i"命令来查看,如果是有空间但节点达到上限,就需要用nr_inodes来调整了.

其它可以调整的参数:
mode,uid,gid,
        uid和gid就不多说了,不知道的回家补基础,mode也不多说了,取值是3个八进制数字,表示许可权限,不知道这个的也回家...
其它参数,参见mount命令的man page之OPTIONS一节中"-o"参数的说明.

3,卸载

umount $DIR_TMP

4,其它

mount 命令的man page中对tmpfs提及不多,详细一些的文档,请参阅内核文档Documentation/filesystems/tmpfs.txt(内核源代码目录内)
I needed to autoload some modules on some CentOS boxen and had a really hard time finding the most modern way to load them. After having them in /etc/rc.d/rc.local i found that i could also put them into /etc/rc.modules which then helped me find the following lines in /etc/rc.sysinit:

# Load other user-defined modules
for file in /etc/sysconfig/modules/*.modules ; do
[ -x $file ] && $file
done
# Load modules (for backward compatibility with VARs)
if [ -f /etc/rc.modules ]; then
/etc/rc.modules
fi

The cleanest way therefore seems to be like so:

echo "modprobe some_module" > /etc/sysconfig/modules/something.modules
chmod +x /etc/sysconfig/modules/something.modules

This kind of files could even be installed from a RPM without needing any special pre-install/uninstall handling.
This probably also applies to various Flavor of Redhat and Fedora. Personally i prefer gentoos nice modules.autoload file.

SSH2下面配置基于key的ssh登录

[不指定 2010/05/06 11:19 | by ipaddr ]
与openssh有些不一样,如下:
User configuration of SSH2 becomes smarter than that of SSH1. Now public keys are stored in separate files and one can have multiple host-specific identifications (i.e., private keys). Read the ssh manual page for details.  Here I describe most basic usage of SSH2. When you want to login to a remote host (Remote) from a local computer (Local) using SSH2, you do:
   
        1. Create private & public keys of Local, by executing
           ssh-keygen (ssh-keygen2) on Local.

            Local> ssh-keygen
            Generating 1024-bit dsa key pair
            9 o.oOo..oOo.o
            Key generated.
            1024-bit dsa, created by ymmt@Local Wed Sep 23 07:11:02 1998
            Passphrase :
            Again :
            Private key saved to /home/ymmt/.ssh2/id_dsa_1024_a
            Public key saved to /home/ymmt/.ssh2/id_dsa_1024_a.pub

        ssh-keygen will ask you a passphrase for new key. Enter a
  sequence of any ordinal character (white spaces are OK) of proper
  length (20 characters or so). ssh-keygen creates a ".ssh2"
        directory in your home directory, and stores a new
        authentication key in two separate files. One is your private
        key and thus it must NOT be opened to anyone but you. In above
        example, it is id_dsa_1024_a. The other (id_dsa_1024_a.pub) is
        a public key that is safe to be opened and to be distributed
        to other computers. 
       
        2. Create an "identification" file in your ".ssh2" directory on Local.

            Local> cd ~/.ssh2
            Local> echo "IdKey id_dsa_1024_a" > identification

        This will create a file "identification" in your ".ssh2" directory, which has one line that denotes which file contains your identification. An identification corresponds a passphrase (see above). You can create multiple identifications by executing ssh-keygen again, but rarely you should.
       
        3. Do the same thing (1, and optionally 2) on Remote.

        This is needed just to setup ".ssh2" directory on Remote. Passphrase may be different.
       
        4. Copy your public key of Local (id_dsa_1024_a.pub) to ".ssh2"
        directory of Remote under the name, say, "Local.pub".

        ".ssh2" on Remote now contains:

            Remote>ls -F ~/.ssh2
            Local.pub
            authorization
            hostkeys/
            id_dsa_1024_a
            id_dsa_1024_a.pub
            identification
            random_seed
       
        5. Create an "authorization" file in your ".ssh2" directory on Remote. Add the following one line to "authorization",
           
   
            Key Local.pub
                
        which directs SSH server to see Local.pub when authorizing your login. If you want to login to Remote from other hosts, create authorization keys on the hosts (step 1 and 2) and repeat step 4 and 5 on Remote.
       
        6. Now you can login to Remote from Local using SSH2!
       
Try to login:

    Local>ssh Remote
            Passphrase for key "/home/ymmt/.ssh2/id_dsa1024_a" with
            comment "1024-bit dsa, created by ymmt@Local Mon Sep 21
            17:53:01 1998":
       
        Enter your passphrase on Local, good luck!

bash变量赋值及字符串的操作

[不指定 2010/04/30 18:58 | by ipaddr ]
Bash中的变量

1.用户定义的变量
用户定义的变量有字母数字及下划线组成,并且变量名的第一个字符不能为数字.
与其它UNIX名字一样,变量名是大小写敏感的.
对于变量,用户可按如下方式赋值:
name = value
在引用变量时,需在前面加$符号,用户也可以在变量间进行相互赋值,如:
(前面的$是命令提示符)

$ JOHN = john
$ NAME = $JOHN
$ echo Hello $NAME
Hello john

也可以用变量和其他字符组成新的字,这时可能需要把变量用{}括起,如:

$ SAT = Satur
$ echo Today is ${SAT}day
Today is Saturday

对于未赋值的变量,Bash以空值对待,用户也可以用unset命令清除给变量
赋的值.

Bash中还可以使用数组变量,其赋值有两种:

(1) name[index] = value
(2) name = (value1 ... valuen) 此时下标从0开始

数组下标的范围没有任何限制,同时也不必使用连续的分量.

Bash中关于变量的内建命令有:

(1) declare和typeset.两者具有一样的功能.其选项有:
[-/+]a 设置/撤消变量的数组属性
[-/+]i 设置/撤消变量的整数属性
[-/+]r 设置/撤消变量的只读属性
[-/+]x 设置/撤消变量的输出属性
-p var 显示变量属性
(2) export和local.
export把变量输出到环境中,用法为:
export name
export name = value

这里需要简单介绍一下export的作用:当Bash shell执行一个
程序时,将首先为该程序建立一个新的执行环境,称为子shell,
在Bash Shell中变量都是局部的,即它们只是在创建它们的子
Shell中是有意义的,使用export后,变量被设置为全局变量,这
时可以被其它子Shell所识别

local标记变量为局部的(如只能被函数内部使用),用法为:
local name
local name = value
(3) readonly.
指定变量为只读,执行后,改变量不能被再次赋值,用法为:
readonly name

2.位置变量或Shell参数
Bash Shell在解释用户命令时,将把命令行的第一个子作为命令,而其它字作为
参数通过位置变量传递给程序.$1,...,$9分别代表第一,...,九个参数.其中1-9
是真正的参数名,"$"符只是用来标识变量的替换.
位置变量$0指命令对应的可执行名.
其它的还有:
$# 送给命令的参数个数
$@ 所有的参数,每个用双括号括起
$* 所有的参数,用双括号括起
3.与Shell有关的变量
(1) Shell自身设置的一些常用变量:
LINENO 正在执行的命令在脚本中的行号
PWD 用户当前目录的全名
OLDPWD 最近一次执行cd之前,用户当前目录的全名
PPID 父进程ID
$ 当前进程ID
RANDOM 随机数(范围0-32767)
SECONDS Bash Shell的运行时间,单位是秒
REPLY select和read命令使用,以后会讲到
OPTARG
ORTIND 这两个变量由getopt命令设置
UID 当前用户的User ID
_ 上一条命令使用的最后一个参数
(2) 影响Shell行为的一些常用环境变量:
PATH 命令搜索路径,以冒号为分隔符.注意与DOS下不同的是,
当前目录不在系统路径里
HOME 用户home目录的路径名,是cd命令的默认参数
COLUMNS 定义了命令编辑模式下可使用命令行的长度
EDITOR 默认的行编辑器
VISUAL 默认的可视编辑器
FCEDIT 命令fc使用的编辑器
HISTFILE 命令历史文件
HISTSIZE 命令历史文件中最多可包含的命令条数
HISTFILESIZE 命令历史文件中包含的最大行数
IFS 定义SHELL使用的分隔符
LOGNAME 用户登录名
MAIL 指向一个需要SHELL监视其修改时间的文件.当该文件修改后,
SHELL将发消息You hava mail给用户
MAILCHECK SHELL检查MAIL文件的周期,单位是秒
MAILPATH 功能与MAIL类似.但可以用一组文件,以冒号分隔,每个文件后
可跟一个问号和一条发向用户的消息
SHELL SHELL的路径名
TERM 终端类型
TMOUT SHELL自动退出的时间,单位为秒,若设为0则禁止SHELL自动退出
PROMPT_COMMAND 指定在主命令提示符前应执行的命令
PS1 主命令提示符
PS2 二级命令提示符,命令执行过程中要求输入数据时用
PS3 select的命令提示符
PS4 调试命令提示符
MANPATH 寻找手册页的路径,以冒号分隔
LD_LIBRARY_PATH 寻找库的路径,以冒号分隔

bash变量赋值

例子:经常在
configure脚本中,会出现以下类似的语句,都表示什么意思呢?

if test -n "${ZSH_VERSION+set}"; then

ac_env_build_alias_set=${build_alias+set}

test "${ac_configure_args0+set}" != set

答案及扩展:

变量赋值方式

str 没有赋值

str 为空字符串

str 为非空字符串

备注

var=${str-expr}var=exprvar=$strvar进行设置
var=${str+expr}var=$strvar=exprvar进行设置,varstr要不都取值,要不都不取值。虽然取值不同
var=${str=expr}str=expr
var=expr
str 不变
var=$str
varstr进行设置,

var str保持一致

var=${str?expr}expr 输出至 stderrvar=strvar进行设置
var=${str:-expr}var=exprvar=$str
var=${str:+expr}var=var=expr
var=${str:=expr}str=expr
var=expr
str 不变
var=$str

var=${str:?expr}expr 输出至 stderr

Bash字符串的操作

(一)字符串的替换
(1)
${变量1/查找字符/替换字符}
(说明一下,这个操作中除了第一个参数是变量外其它两个都是字符;还有一点就是这个操作并不是把“变量1”中的字符替换了,详见例子)
例:
str1=abcABCabc123ABC
echo ${str1/bcA/aaa}#这里的abc和aaa都是字符串,而str1是变量,并且这个操作过后str1里的字符串长度不会减少,只是产生了一个 新的字串。
(2)
${变量1/#查找字符/替换字符}
(说明一下,这个操作上和面的是一样的,只不过是从左边开始匹配,并且必须从左边第一个字符开始)
例:
echo ${str1/#bcA/aaa}#这个例子中并不会把bcA换成aaa因为b不是左边第一个开头字符
echo ${str1/#abc/aaa}#这样才行
(3)
${变量1/%查找字符/替换字符}
(与(2)相反,是结尾最后一个字符要匹配才行)
例:
echo ${str1/%3ABC/aaa}#abcABCabc12aaa
(3)
${变量1//查找字符/替换字符}
全部替换
(二)取子串
(1)${变量1:位置}
(说明一下,默认是从左边开始,如果“位置”为负数,则是从右边的第“位置”个字符开始,并且第一个位置为0;从“位置”开始取子串到最后)
例:
str1=abcABCabc123ABC
echo ${str1:(-3)}#会输出ABC
(2)${变量1:开始位置:结束位置}
(3)如果“变量1”为“*”或“@”,“位置”所表示的是第几个参数。
(三)字符串移动
(1)${字串#匹配字串}
(说明一下,这个是从左边第一个开始匹配,剥去最短“匹配字串”)
例:
str1=abcABCabc123
echo ${str1#a*c}#输出ABCabc123
(2)${字串##匹配字串}
(说明一下,这个是从左边第一个开始匹配,剥去最长“匹配字串”)
str1=abcABCabc123
echo ${str1#a*c}#输出123
echo ${str1#b*c}#输出abcABCabc123,因为没有从第一个开始匹配
(3)${字串%匹配字串}
(4)${字串%%匹配字串}
(说明一下,这与上面的(1)(2)是正好相反的,是从最后一个开始匹配的)
(四)字符串长度
${#字串}
例:
str=abcdefg
echo ${#str}#输出7

I've always been used to the Redhat/Fedora way of setting up aliases in /etc/sysconfig/network-scripts-ifcfg-: but SuSe/Novell Linux is slightly different. I see a lot of hackish examples/bad advice on the internet on how to set it up on SuSe/Novell Linux so I figured I'd make a note of it here.

To do it "right" under SuSe, you modify the main configuration file for your ethernet adapter.

For example, 'ifcfg-eth-id-de:ad:co:ed:ba:be' where the de:ad:co:ed:ba:be is replaced by a real MAC address.

As an example, you want the main IP of the system to be statically set to 192.168.100.1, and the other IPs to be 192.168.100.100, 192.168.100.101, and 192.168.100.102

Your original configuration will probably look something like this:

BOOTPROTO='static'
BROADCAST='192.168.100.255'
IPADDR='192.168.100.1'
MTU=1500
NAME='My awesome no-name PCI \"bus-mastering\" NE-2000 clone $1.99 CPU-cycle-hogging wondercard'
NETMASK='255.255.255.0'
NETWORK='192.168.100.0'
REMOTE_IPADDR=''
STARTMODE='onboot'
USERCONTROL='no'
_nm_name='bus-pci-0000:01:04.0'

You will want to change it to look like this:

BOOTPROTO='static'
BROADCAST='192.168.100.255'
IPADDR='192.168.100.1'
MTU=1500
NAME='My awesome no-name PCI \"bus-mastering\" NE-2000 clone $1.99 wondercard'
NETMASK='255.255.252.0'
NETWORK='192.168.100.0'
REMOTE_IPADDR=''
STARTMODE='onboot'
USERCONTROL='no'
_nm_name='bus-pci-0000:01:04.0'
IPADDR1='192.168.100.100'
NETMASK1='255.255.255.0'
LABEL1='0'

IPADDR2='192.168.100.101'
NETMASK2='255.255.255.0'
LABEL2='1'
IPADDR3='192.168.100.102'
NETMASK3='255.255.255.0'
LABEL3='2'

Save that and restart networking with '/etc/init.d/network restart' and you are good to go with:
eth0 set to 192.168.100.1
eth0:0 set to 192.168.100.100
eth0:1 set to 192.168.100.101
eth0:2 set to 192.168.100.102

The 'LABELx' settings are just setting the alias label you see after the 'eth0:'
You can get away with leaving out the 'LABELx' statements. One side effect is that you won't see the aliases under 'ifconfig'.

I know you can do this with 'yast' and other utilities but this seems more direct and easier to do on a high latency SSH console.

鱼漂(www.eit.name)提醒:
1. 只需在原来的ifcfg-ethx配置文件中,增加类似配置:
IPADDR_N=
NETMASK_N=
LABEL_N=

2.  "man ifcfg"的Multiple addresses章节有详细的解释。

VI常用配置

[不指定 2009/12/30 22:21 | by ipaddr ]

1. 显示所有设置
:set all

2. 打开状态栏
:set ru|noru
3. 帮助
:help
:help 03
:help xxx

4. 显示行号
:set number|nu|nonumber|nonu

5. 语法高亮
:syntax on|enable

6. 自动缩进
:set ai|noai
:set sw=4 (自缩进4个空格)
:set expandtab|et (将Tab转为n个空格)
:set tabstop|ts=4 (设置tab位为4个空格)
:retab (将原有tab换成空格)

7. 是否区分大小写匹配
:set ic|noic

8. 括号匹配显示
:set showmatch|noshowmatch

9. 执行系统命令
:!date

10. 编辑多个文件
vi file1 file2 file3
:n 编辑下一个文件
:rew 编辑第一个文件

11. 搜索结果高亮
set hlsearch
(鱼漂整理,转载请注明)

12. 快速跳转
Shift + G =>最后一行
Shift + M =>页中
Shift + H =>页首
Shift + L =>页末
1G =>第一行
[[ 开头
]]结尾
[[^ 开头第一个字符
]]$ 结尾最后一个字符

13. 设置编码
:set encoding=utf-8
:set termencoding=utf-8
:set fileencoding=utf-8

14. 色彩选择
:set bg=dark|light
:colo|colorscheme desert

Mysql动态修改参数

[不指定 2009/12/25 10:51 | by ipaddr ]
   mysql数据库也像ORACLE数据库一样,可以动态的修改参数,可以修改会话级变量只对当前会话产生影响;也可以修改全局变量,对所有新连接的会话都产生影响。

修改会话级变量

用show variables 命令查看当前参数的值,like 'pattern'用于模式匹配,查找指定的参数

mysql> show variables like '%sort_buffer_size%';
+---------------------------+------------+
| Variable_name             | Value      |
+---------------------------+------------+
| sort_buffer_size          | 6291448    |
+---------------------------+------------+
1 rows in set (0.00 sec)

用set SESSION命令设置会话级变量的新值

mysql> set SESSION sort_buffer_size=7000000;
Query OK, 0 rows affected (0.00 sec)

--修改会话级变量对当前会话来说立刻生效
mysql> show variables like '%sort_buffer_size%';       
+---------------------------+------------+
| Variable_name             | Value      |
+---------------------------+------------+
| sort_buffer_size          | 7000000    |
+---------------------------+------------+
1 rows in set (0.00 sec)

mysql> exit
Bye
退出重新连接后,此参数恢复原值
[root@devdbc_stb root]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 40 to server version: 5.0.37-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show variables like '%sort_buffer_size%';       
+---------------------------+------------+
| Variable_name             | Value      |
+---------------------------+------------+
| sort_buffer_size          | 6291448    |
+---------------------------+------------+
1 rows in set (0.00 sec)

修改全局变量
[root@devdbc_stb root]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 40 to server version: 5.0.37-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show variables like '%sort_buffer_size%';       
+---------------------------+------------+
| Variable_name             | Value      |
+---------------------------+------------+
| sort_buffer_size          | 6291448    |
+---------------------------+------------+
1 rows in set (0.00 sec)

用set GLOBAL 命令设置全局变量

mysql> set GLOBAL sort_buffer_size = 7000000;
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like '%sort_buffer_size%';        
+---------------------------+------------+
| Variable_name             | Value      |
+---------------------------+------------+
| sort_buffer_size          | 6291448    |
+---------------------------+------------+
1 rows in set (0.00 sec)
当前此参数的值并不发生变化,先退出,然后重新连进去
mysql> exit
Bye
[root@devdbc_stb root]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 41 to server version: 5.0.37-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show variables like '%sort_buffer_size%';
+---------------------------+------------+
| Variable_name             | Value      |
+---------------------------+------------+
| sort_buffer_size          | 7000000    |
+---------------------------+------------+
1 rows in set (0.00 sec)
新的参数值生效

This document details the steps required to make an Ubuntu or Debian machine an LDAP client for authentication purposes.
此文档描述如何将Ubuntu或Debian Linux加入到Ldap认证登录。

So you've got an LDAP server floating around and you'd like to have your Ubuntu or Debian client authenticate against it. It's assumed here that you already have an LDAP server and you or your admin can provide the answers to some of the questions asked upon configuration. Firstly, you'll need to open up your favourite package manager and install libpam-ldap and libnss-ldap:  
$ apt-get install libpam-ldap libnss-ldap

This command will bring down all the required libraries to enable you to have your machine authenticating against the LDAP server of your dreams. Once the packages start being unpacked you'll be hit up for a few questions:

  • IP address / hostname of the LDAP server. ie: ldap.my.domain  
  • The search base of your LDAP domain. ie: dc=my,dc=domain  
  • You'll be asked the version of LDAP server you're connecting to, "Version 3" ought to be safe in most cases.  
  • A screen titled "Configuring LIBNSS-LDAP will appear with only the "OK" option. Select it :)  
  • On the next screen you'll be asked if you want to make root the DB admin. The best answer is "yes".  
  • Now you'll be asked whether the DB requires logging in, say "No"  
  • You'll be asked for the root login account for LDAP. It is often something like: cn=manager,dc=my,dc=domain  
  • Then you'll need to enter the LDAP password for the aforementioned LDAP account

That will see all the packages installed and the base configurations satisfied. If your LDAP server is already populated with content then at this point you should be able to run commands such as "getent passwd <username>" and if that username is unique to LDAP and you get a response then you answered all the questions correctly. Now you need to customise PAM to make it use LDAP for authentication.You'll need to run the following command:

$ sudo vi /etc/pam.d/sudo

Once deep in the bowells of the sudo file, you need to add one line above the existing line, something like this:

auth    sufficient      pam_ldap.so 
auth    required        pam_unix.so

(Note: From Ubuntu 5.10 (Breezy) and Debian 3.1 (Sarge) you no longer need to edit /etc/pam.d/sudo.) This process now gets repeated for four more files, so I'll show the vi command and then the changes required:

$ sudo vi /etc/pam.d/common-account

account sufficient      pam_ldap.so
account required        pam_unix.so

$ sudo vi /etc/pam.d/common-auth

auth    sufficient      pam_ldap.so
auth    required        pam_unix.so nullok_secure

$ sudo vi /etc/pam.d/common-password

password        sufficient      pam_ldap.so
password     required   pam_unix.so nullok obscure min=4 max=8 md5

$ sudo vi /etc/pam.d/common-session

session   sufficient      pam_ldap.so
session   required        pam_unix.so

Last but not least we need to edit nsswitch.conf:

$ sudo vi /etc/nsswitch.conf

and once you're in that file, run this command:

:%s/compat/ldap files/g

Tada! If you've entered in all your local configuration information correctly, you'll have a living breathing LDAP authentication client. Enjoy :)

鱼漂已测试过ubuntu9.10,可正确配置ldap认证,需要注意的是:
1. 不再需要手动修改pam.d下面的文件, 安装libpam-ldap时会根据你的回答自动配置pam.d下的文件。
2. 更新后的/etc/pam.d/sudo 可能会导致sudo时要求输入多次密码,在线更新程序也会失败,解决办法是将/etc/pam.d/sudo中的pam_ldap.so, pam_unix.so行注释。
3. ldap中的用户如果需要使用sudo, 可以将用户加到admin组,默认情况下,所有admin组的用户都可以sudo. 或者修改/etc/sudoers,允许ldap用户对应的组可以sudo
4. ldap中,一个组设置多个成员,需要在对应的组中添加memberUid属性,此属性可以有多个值,对应的是用户名,而不是用户id。
分页: 2/12 第一页 上页 1 2 3 4 5 6 7 8 9 10 下页 最后页 [ 显示模式: 摘要 | 列表 ]