Rootop 服务器运维与web架构

2012-02-18
发表者 Venus
暂无评论

configure: error: the –with-apr parameter is incorrect

checking for working mkdir -p… yes
/root/httpd-2.2.22/httpd-2.2.22/srclib/apr-util/configure: line 2806: /root/httpd-2.2.22/httpd-2.2.22/srclib/apr-util/build/get-version.sh: Permission denied
/root/httpd-2.2.22/httpd-2.2.22/srclib/apr-util/configure: line 2807: /root/httpd-2.2.22/httpd-2.2.22/srclib/apr-util/build/get-version.sh: Permission denied
/root/httpd-2.2.22/httpd-2.2.22/srclib/apr-util/configure: line 2809: /root/httpd-2.2.22/httpd-2.2.22/srclib/apr-util/build/get-version.sh: Permission denied
APR-util Version:
checking for chosen layout… apr-util
checking for gcc… gcc
checking for C compiler default output file name… a.out
checking whether the C compiler works… yes
checking whether we are cross compiling… no
checking for suffix of executables…
checking for suffix of object files… o
checking whether we are using the GNU C compiler… yes
checking whether gcc accepts -g… yes
checking for gcc option to accept ISO C89… none needed
Applying apr-util hints file rules for i686-pc-linux-gnu
checking for APR… configure: error: the –with-apr parameter is incorrect. It must specify an install prefix, a build directory, or an apr-config file.
configure failed for srclib/apr-util
[root@localhost httpd-2.2.22]#

我这里报错的原因是没有权限,最后直接给整个安装包加-R并设为777权限,重新./configure没问题了。

2012-02-17
发表者 Venus
暂无评论

linux ntp时间同步的两种方法

服务端IP 192.168.1.101      客户端IP 192.168.1.88

1、首先配置ntpd服务器:

vi /etc/ntp.conf

 配置文件中有restrict default语句

 #restrict default nomodify notrap noquery     #  默认允许所有可连接客户端ntpdate到本机   

restrict default ignore          #  默认所有客户端禁止ntpdate到本机

 #与上级服务端连续性同步时间,prefer表示优先,如无可不设置

#server 上级ntp服务器IP或者域名 [prefer] 

server 210.72.145.44 perfer

 #当之前设置了restrict default ignore的情况下,可以设置哪些客户可以ntpdate到本机

restrict 192.168.1.88 mask 255.255.255.255 nomodify notrap

#其余为可选设置,以默认值即可

开启ntpd服务

service ntpd start && chkconfig –level 345 ntpd on 

2、客户端配置:

此时有2种办法使客户端与服务器同步,一种是用ntpdate + crontab,另一种是客户端也开启ntpd服务

 ntpdate + crontab

#使用ntpdate同步一次时间,查看是否有正确回显

ntpdate 192.168.1.101

 #如为以下报错,一般是因为服务端才开启,需要等5分钟左右就好了

[root@test ~]# ntpdate 192.168.1.101
 5 Nov 05:25:51 ntpdate[3892]: no server suitable for synchronization found

#如显示以下信息表示成功

[root@test ~]# ntpdate 192.168.1.101
 7 Nov 22:34:59 ntpdate[4546]: step time server 192.168.1.101 offset 2.946644 sec

#这样就可以将ntpdate命令放入crontab中,定期执行

crontab -e

添加一条,如

* 2 * * * * ntpdate 192.168.1.101    #每天2点执行

保存即可

如有开启iptables,配置允许ntpd服务的udp协议端口123被访问。 

第二种同步方法

#使用ntpdate同步一次时间,查看是否有正确回显

ntpdate 192.168.1.101

#设置ntpd服务

vi /etc/ntp.conf

方法同上,但注意将设置的上级ntp server 设置为服务器的地址。

server 192.168.1.101 prefer

#设置开启服务后自动同步上级ntp server时间

vi /etc/ntp/step-tickers   加入一条

192.168.1.101

重启ntpd服务。

[root@test ~]# service ntpd restart
关闭 ntpd:                                                [确定]
ntpd: 同步时间服务器:                                     [确定]
同步硬件时钟到系统时钟                                     [确定]
启动 ntpd:                                                [确定]
You have new mail in /var/spool/mail/root
[root@localhost ~]#

2012-02-16
发表者 Venus
暂无评论

sudoers 让普通用户以root权限且不需要root密码执行某些命令

sudo 是linux下常用的允许普通用户使用超级用户权限的工具,允许系统管理员让普通用户执行一些或者全部的root命令,如halt,reboot,su等等。这样不仅减少了root用户的登陆和管理时间,同样也提高了安全性。Sudo不是对shell的一个代替,它是面向每个命令的。它的特性主要有这样几点:

  § sudo能够限制用户只在某台主机上运行某些命令。

  § sudo提供了丰富的日志,详细地记录了每个用户干了什么。它能够将日志传到中心主机或者日志服务器。

  § sudo使用时间戳文件来执行类似的“检票”系统。当用户调用sudo并且输入它的密码时,用户获得了一张存活期为5分钟的票(这个值可以在编译的时候改变)。

  § sudo的配置文件是sudoers文件,它允许系统管理员集中的管理用户的使用权限和使用的主机。它所存放的位置默认是在/etc/sudoers 。

sudo的使用

       权限:在 /etc/sudoers 中有出现的使用者

  使用方式:sudo -V

  sudo -h

  sudo -l

  sudo -v

  sudo -k

  sudo -s

  sudo -H

  sudo [ -b ] [ -p prompt ] [ -u username/#uid] -s

  用法:sudo command

  说明:以系统管理者的身份执行指令,也就是说,经由 sudo 所执行的指令就好像是 root 亲自执行

  参数:

  -V 显示版本编号

  -h 会显示版本编号及指令的使用方式说明

  -l 显示出自己(执行 sudo 的使用者)的权限

  -v 因为 sudo 在第一次执行时或是在 N 分钟内没有执行(N 预设为五)会问密码,这个参数是重新做一次确认,如果超过 N 分钟,也会问密码

  -k 将会强迫使用者在下一次执行 sudo 时问密码(不论有没有超过 N 分钟)

  -b 将要执行的指令放在背景执行

  -p prompt 可以更改问密码的提示语,其中 %u 会代换为使用者的帐号名称, %h 会显示主机名称

  -u username/#uid 不加此参数,代表要以 root 的身份执行指令,而加了此参数,可以以 username 的身份执行指令(#uid 为该 username 的使用者号码)

  -s 执行环境变数中的 SHELL 所指定的 shell ,或是 /etc/passwd 里所指定的 shell

  -H 将环境变数中的 HOME (家目录)指定为要变更身份的使用者家目录(如不加 -u 参数就是系统管理者 root )

  command 要以系统管理者身份(或以 -u 更改为其他人)执行的指令

  范例:

  sudo -l 列出目前的权限

  sudo -V 列出 sudo 的版本资讯

  指令名称:sudoers(在fc5下显示不能找到此命令,但用man可以查到其用法。)

  用来显示可以使用sudo的用户

sudoers的配置

sudoers 是sudo的主要配置文件,linux下通常在/etc目录下,如果是solaris,缺省不装sudo的,编译安装后通常在安装目录的etc目录下,不过不管sudoers文件在哪儿,sudo都提供了一个编辑该文件的命令:visudo来对该文件进行修改。强烈推荐使用该命令修改 sudoers,因为它会帮你校验文件配置是否正确,如果不正确,在保存退出时就会提示你哪段配置出错。
sudoers的缺省配置:
#############################################################
# sudoers file.
#
# This file MUST be edited with the ‘visudo’ command as root.
#
# See the sudoers man page for the details on how to write a sudoers file.
#
# Host alias specification
# User alias specification
# Cmnd alias specification
# Defaults specification
# User privilege specification
root    ALL=(ALL) ALL
# Uncomment to allow people in group wheel to run all commands
# %wheel        ALL=(ALL)       ALL
# Same thing without a password
# %wheel        ALL=(ALL)       NOPASSWD: ALL
# Samples
# %users  ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
# %users  localhost=/sbin/shutdown -h now
##################################################################
1. 最简单的配置,让普通用户support具有root的所有权限
执行visudo之后,可以看见缺省只有一条配置:
root    ALL=(ALL) ALL
那么你就在下边再加一条配置:
support ALL=(ALL) ALL
这样,普通用户support就能够执行root权限的所有命令
以support用户登录之后,执行:
sudo /sbin/service httpd restart

然后输入support用户自己的密码,即可用root权限执行。

//我们会发现,如果再执行一次命令,就不需要密码了,这就是之前的时间戳的功能。在一定时间内无需输入密码就可以操作。
2. 让普通用户support只能在某几台服务器上,执行root能执行的某些命令:
首先需要配置一些Alias,这样在配置权限时,会方便一些。Alias主要分成4种
Host_Alias
Cmnd_Alias
User_Alias
Runas_Alias
1) 配置Host_Alias:就是主机的列表
Host_Alias      HOST_FLAG = hostname1, hostname2, hostname3
2) 配置Cmnd_Alias:就是允许执行的命令的列表,命令前加上!表示不能执行此命令.

命令一定要使用绝对路径,避免其他目录的同名命令被执行,造成安全隐患 ,因此使用的时候也是使用绝对路径!
Cmnd_Alias      COMMAND_FLAG = command1, command2, command3 ,!command4
3) 配置User_Alias:就是具有sudo权限的用户的列表
User_Alias USER_FLAG = user1, user2, user3
4) 配置Runas_Alias:就是用户以什么身份执行(例如root,或者oracle)的列表
Runas_Alias RUNAS_FLAG = operator1, operator2, operator3
5) 配置权限
配置权限的格式如下:
USER_FLAG HOST_FLAG=(RUNAS_FLAG) COMMAND_FLAG
如果不需要密码验证的话,则按照这样的格式来配置
USER_FLAG HOST_FLAG=(RUNAS_FLAG) NOPASSWD: COMMAND_FLAG
配置示例:
############################################################################
# sudoers file.
#
# This file MUST be edited with the ‘visudo’ command as root.
#
# See the sudoers man page for the details on how to write a sudoers file.
#
# Host alias specification
Host_Alias      EPG = 192.168.1.1, 192.168.1.2
# User alias specification
# Cmnd alias specification
Cmnd_Alias      SQUID = /opt/vtbin/squid_refresh, !/sbin/service, /bin/rm

Cmnd_Alias      ADMPW = /usr/bin/passwd [A-Za-z]*, !/usr/bin/passwd, !/usr/bin/passwd root
# Defaults specification
# User privilege specification
root    ALL=(ALL) ALL
support EPG=(ALL) NOPASSWD: SQUID
support EPG=(ALL) NOPASSWD: ADMPW
# Uncomment to allow people in group wheel to run all commands
# %wheel        ALL=(ALL)       ALL
# Same thing without a password
# %wheel        ALL=(ALL)       NOPASSWD: ALL
# Samples
# %users  ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
# %users  localhost=/sbin/shutdown -h now
###############################################################

2012-02-10
发表者 Venus
暂无评论

同一张URL图片IE不能显示图片火狐能显示

      服务器中的一张图片,用火狐浏览器可以打开,但是用IE就显示为叉号,用普通修改软件重新保存了下图片,没问题了。感觉像是图片的问题,具体说不出来,最终确定是图片模式的问题:

IE不支持印刷格式CMYK四色模式的JPEG图片,RGB是三原色。

用photoshop打开可以看到是cmyk颜色,选择rgb颜色保存即可。

2012-02-10
发表者 Venus
暂无评论

ORA-12505: TNS:listener does not currently know of SID given in connect descriptor (DBD ERROR: OCIServerAttach)

web管理oracle时,登陆报错:

ORA-12505: TNS: 监听程序当前无法识别连接描述符中所给出的 SID (DBD ERROR: OCIServerAttach)

我出错的原因是数据库没有启动,启动即可。

[oracle@rhel55 ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on 星期二 2月 7 10:05:12 2012

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

SQL> startup
ORACLE 例程已经启动。

Total System Global Area  849530880 bytes
Fixed Size                  1339824 bytes
Variable Size             528485968 bytes
Database Buffers          314572800 bytes
Redo Buffers                5132288 bytes
数据库装载完毕。
数据库已经打开。
SQL> conn /as sysdba
已连接。

刷新进入登陆界面。