存档

‘Linux’ 分类的存档

Linux打开telnet-server功能

2010年2月28日 baalchina 没有评论

默认linux是关闭telnet-server功能的,我们来安装它。

安装:

[root@disk shell]# yum install telnet-server

telnet-server通过xinetd来控制的,编辑打开:

[root@disk shell]# vi /etc/xinetd.d/telnet

将disable修改为no。

重启一下xinetd:

[root@disk shell]# service xinetd restart
Stopping xinetd: [FAILED]
Starting xinetd: [  OK  ]
[root@disk shell]#

 

另外还要记得修改防火墙。并通过ntsysv将telnet加成服务。

 

写完上面的我发现以前已经写过类似的了...http://www.baalchina.net/2008/08/linux%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%ae%89%e8%a3%85telnet-server/

分类: Linux 标签: ,

“这样使用RHEL合法吗”?(zt)

2010年1月28日 baalchina 没有评论

某位网友在 Chinaunix.net 的 Linux 系统管理论坛中提出问题“这样使用 RHEL 合法吗?”:
“1. 从网络下载RHEL的ISO文件安装。
2. 不购买RHEL任何服务。
3. 移除系统中redhat注册商标(保留版本号...)。
4. 从ftp.redhat.com官方的srpm编译后升级/下载新版RHEL的ISO文件升级。
5. 使用当前系统自动维护其他子服务器。”

该网友询问了 Red Hat 官方,得到一些价目表和授权文件,但答复“Red Hat 官方不提供任何法律指导”,意思也就是“到底合不合法,不妨猜猜看?” 本着疑义相与析的精神,各位网友就此展开了热烈的讨论,Red Hat 员工和业余法律爱好者们甚至进行了针锋相对的辩论。

去年我正好研究过这个问题,现在把旧文找出来整理重贴。

RHEL 的版权由 GPL 软件版权和 Red Hat 自有版权两部分组成,而由于 GPL 许可证具有传染性,故所有基于 GPL 开发的软件都要符合 GPL 条款,因此 Red Hat 自有版权部分在 RHEL 中只占很少的部分,只需删除所有 Red Hat Network Code 即可完全自由使用RHEL。这在 RHEL Subscriptions Renewal FAQs 里说得很清楚:

6. If I don't renew, can I continue to use the software?

Yes, under the General Public License (GP), you may use the software and maintain your own custom version of Linux. However, you will not have access to:

* Technical support from Red Hat.

* Security or software updates via Red Hat Network. You will have to find updates from alternative resources that provide reliable, secure downloads.

* Support from certified hardware suppliers or software vendors like Oracle for applications running on an expired Red Hat Enterprise Linux subscription.

* Coverage from the Red Hat Open Source Assurance program, featuring an Intellectual Property Warranty for Red Hat Enterprise Linux customers. Red Hat designed the program to protect customers using open source solutions.

Please note that when your subscription expires you will still be bound by the terms and conditions of the End User License Agreement and will have to remove all copies of Red Hat Network Code.

Red Hat 的营利模式是 Subscription Business Model,即通过向用户出售技术服务,获取相应年费营利,这在 Red Hat Store 网页上说得也很清楚:

其 Subscription 内容主要包括 phone support、web support 和 unlimited incidents。如果你的技术能力足以自我 Support,又何必购买如此昂贵的 Support 呢?

这样使用 RHEL 完全合法。其实 Oracle 所谓的 Unbreakable Enterprise Linux 就是把 RHEL 改头换面,再低价出售 Compatiable Subscription(鄙视),详见: http://en.wikipedia.org/wiki/Oracle_Enterprise_Linux

当 然,Red Hat 为 Linux 的发展付出了巨大的努力,他们提供的 Red Hat Enterprise Linux 系列较之同类产品,无论在功能还是性能方面都有极大的提升(相对于 Fedora 9 和 Ubuntu Server 的测试结果可以看出)。我们应该如何回馈 Red Hat,促使其继续保持对开源软件的巨大热情,进一步推动 RHEL 又好又快发展,这是大家都需要考虑的问题(欢迎购买 Red Hat 相关产品、服务,参加 RHCE/RHCA 认证培训和考试)。

最后,向各位担心法律问题的朋友,奉上许可证检查脚本: CheckLicense.sh

#!/bin/bash
# Author: hutuworm (http://hutuworm.blogspot.com)
# RELEASED UNDER GPLv2.

for PACKAGE in `rpm -qa`
do
NOTICE=`rpm -qi $PACKAGE | grep License | grep -iE 'red ?hat'`
if [ ! "$NOTICE" = "" ]
then
echo $PACKAGE ":" $NOTICE ;
fi
done

在装有 RHEL 的服务器上执行:

# sh CheckLicense.sh

redhat-logos-1.1.14.3-1 : Size : 993129 License: Copyright ?1999-2002 Red Hat, Inc. All rights reserved.

anaconda-images-9.1-3.RHEL : Size : 5363878 License: Copyright ?2003 Red Hat, Inc. All rights reserved.

anaconda-product-3-1AS : Size : 75111 License: Copyright 2003 Red Hat, Inc. All rights reserved.

那么只需要把 redhat-logos-1.1.14.3-1、anaconda-images-9.1-3.RHEL、anaconda-product-3-1AS 这三个 rpm 包用 rpm -e 命令从系统中移除,即可高枕无忧。

转载自:http://www.cnbeta.com/articles/65199.htm

分类: Linux 标签: ,

最简squid配置教程

2010年1月5日 baalchina 没有评论

for 刘老大。:lol

首先ssh上去,

vi /etc/hosts

添加你要解析的地址,比如

1.1.1.1 hosts.example.com

其中

  1. 1.1.1.1是真实Web服务器的IP地址
  2. hosts.example是服务器的域名

接下来编辑

vi /usr/local/squid/etc/squid.conf

对应添加这两行:

cache_peer_domain example hosts.example.com

cache_peer hosts.example.com parent 80 0 originserver no-query name=example 

注意颜色对应。

然后重新配置squid即可。

/usr/local/squid/sbin/squid -k reconfigure

测试通过就ok了。

分类: Linux, Squid, 服务器管理 标签:

Windows下使用IIS下建立内网Ubuntu镜像

2009年12月28日 baalchina 没有评论

学校里搞一个Ubuntu镜像,可惜有空间的服务器都是Windows的,懒得再搞一个Linux服务器,于是就在Windows下作吧。

需要环境

  1. Windows服务器(废话),启用IIS或者FTP。我用的是IIS。
  2. 300G左右的存储(我是同步了所有的文件,包括源码,各个版本,以及各个硬件支持,目前大小是296G,398504个文件)
  3. Linux下镜像采用rsync,那么Windows下就是cwRsync啦。

配置cwRsync

安装,不多说,然后新建一个批处理,代码如下

rsync -vzrtopg --progress  --delete rsync://ubuntu.srt.cn/ubuntu/ /cygdrive/L/mirror/ubuntu/

可以看出,我是从ubuntu.srt.cn/ubuntu同步到本地的l盘的mirror下的ubuntu目录。

完整的国内镜像可以看https://launchpad.net/ubuntu/+archivemirrors,几个地方,USETC的教育网速度不错,srt和lupa的电信速度不错。但是USETC到一定时间就会自动断开,lupa的同步会死掉,最后我是用srt完成的。其实也有很多源比如搜狐网易都有,但是不支持rsync协议。

另外要记得把这个批处理放到计划任务里面去。

配置IIS

这个就很简单了,把l盘的这个目录放出去就行。我开了目录浏览。另外IIS里面需要加一个MIME类型,否则ubuntu的.deb文件会报404,具体看这里:IIS MIME类型设置

客户端配置

以Ubuntu 9.10为例,修改/etc/apt/source.list文件(backup first!)

deb http://linux.nau.edu.cn/ubuntu/ karmic main restricted universe multiverse
deb http://linux.nau.edu.cn/ubuntu/ karmic-security main restricted universe multiverse
deb http://linux.nau.edu.cn/ubuntu/ karmic-updates main restricted universe multiverse
deb http://linux.nau.edu.cn/ubuntu/ karmic-proposed main restricted universe multiverse
deb http://linux.nau.edu.cn/ubuntu/ karmic-backports main restricted universe multiverse
deb-src http://linux.nau.edu.cn/ubuntu/ karmic main restricted universe multiverse
deb-src http://linux.nau.edu.cn/ubuntu/ karmic-security main restricted universe multiverse
deb-src http://linux.nau.edu.cn/ubuntu/ karmic-updates main restricted universe multiverse
deb-src http://linux.nau.edu.cn/ubuntu/ karmic-proposed main restricted universe multiverse
deb-src http://linux.nau.edu.cn/ubuntu/ karmic-backports main restricted universe multiverse

 

然后刷新列表,就可以用新力得了。

sudo apt-get update

 

参照Ubuntu中文Wiki的文章

 

Tips:

  1. Ubuntu的官方镜像列表:https://launchpad.net/ubuntu/+archivemirrors
分类: Linux, Windows 标签: , ,

/etc/fstab修改错误无法进入系统的解决方案

2009年12月6日 baalchina 没有评论

改vsftp的配额,结果改错了...无法进入系统,提示read-only...

解决方法

用centos光盘启动,按f5,进入rescue模式。

输入:

chroot /mnt/sysimages

现在就可以修改/etc/fstab了。

分类: Linux, 服务器管理 标签: ,

vsftpd的安装与配置(不全,待补充,20091205)

2009年12月5日 baalchina 1 条评论

对于linux下的ftp,一直一种恐惧心理...哈。

 

首先我们下载安装之

很简单。

[root@php ~]#wget ftp://vsftpd.beasts.org/users/cevans/vsftpd-2.2.2.tar.gz[root@php ~]#tar xvzf vsftpd-2.2.2.tar.gz
[root@php ~]#cd vsftpd-2.2.2
[root@php ~]#make
[root@php ~]#useradd nobody
[root@php ~]#mkdir /usr/share/empty/
[root@php ~]#make install
[root@php ~]#cp vsftpd.conf /etc/
[root@php ~]#/usr/local/sbin/vsftpd &

可以看到,安装的时候是不需要configure的。

配置用户账号

这里用到了一个db_load的工具,默认是没有的,先安装之:

[root@php ~]#yum install db4-utils

然后我们新建一个密码文件,比如user.txt,格式如下:

username
password

接下来把他变成vsftpd的数据库格式,并加权限:

[root@php ~]# db_load -T -t hash -f /root/vsftpd/logins.txt /etc/vsftpd_login.db
[root@php ~]# chmod 600 /etc/vsftpd_login.db

新建一个/etc/pam.d/vsftpd.vu文件,内容如下:

auth required /lib/security/pam_userdb.so db=/etc/vsftpd_login
account required /lib/security/pam_userdb.so db=/etc/vsftpd_login

给ftp新建一个用户:

[root@php ~]# useradd -d /home/vsftpd -s /sbin/nologin vsftpd

启动之

[root@php ~]# /usr/local/sbin/vsftpd &
[1] 9761

9761是自动弹出的告诉你pid的。

 

 

Troubleshooting

启动ok,但是ftp连接报错

[右] 正在连接到 210.28.92.18 -> IP=210.28.92.18 PORT=21
[右] 已连接到 210.28.92.18
[右] 500 OOPS: vsftpd: both local and anonymous access disabled!

将local_enable=YES即可。

root可以登录,但是设置的帐号却不能

这个需要注意是否安装了pam。前面我们看到账户使用了pam认证,那么必须有pam的支持。

[root@php ~]#yum install pam-devel

然后再重新编译、安装vsftpd。用ldd命令可以看到vsftpd是否加载了pam:

[root@php vsftpd-2.2.2]# ldd /usr/local/sbin/vsftpd
        linux-gate.so.1 =>  (0x00195000)
        libpam.so.0 => /lib/libpam.so.0 (0x006a7000)
        libdl.so.2 => /lib/libdl.so.2 (0x0035c000)
        libnsl.so.1 => /lib/libnsl.so.1 (0x0068e000)
        libresolv.so.2 => /lib/libresolv.so.2 (0x00744000)
        libutil.so.1 => /lib/libutil.so.1 (0x0067c000)
        libcap.so.1 => /lib/libcap.so.1 (0x00688000)
        libc.so.6 => /lib/libc.so.6 (0x00215000)
        libaudit.so.0 => /lib/libaudit.so.0 (0x0037b000)
        /lib/ld-linux.so.2 (0x001f2000)

然后重启vsftpd就ok乐。还算有点扰人的。参考:http://www.oschina.net/docs/article/10383

分类: FTP, Linux, 服务器管理 标签: , ,

升级Apache+PHP

2009年10月9日 baalchina 2 条评论

招生的时候检测报告说俺们的web server有漏洞,于是决定把Apache+PHP升级一下。

首先看一下版本:

[root@www1 ~]# /usr/local/apache2/bin/apachectl -v
Server version: Apache/2.2.4 (Unix)
Server built:   Aug  7 2008 14:07:37

 

php的版本可以写个phpinfo看到。装的是4.4.4。

 

[root@www1 ~]# /usr/local/php/bin/php -i |grep configure
Configure Command =>  './configure' '--prefix=/usr/local/php' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-zlib-dir' '--with-bz2' '--with-tiff-dir' '--with-gd=/usr/local/gd2' '--with-freetype-dir' '--with-jpeg-dir' '--with-png-dir' '--with-ttf' '--enable-mbstring' '--with-mysql=/usr/local/mysql' '--with-config-file-path=/etc' '--disable-ipv6' '--enable-static'

 

 

更多内容参照:http://www.baalchina.net/2009/08/php-mysql-apache-configure/

注意:

  • ZO也要装
  • 根据跑的cms程序,php升级的时候尤其是4~5切记不可太随意。不过php4在07年就停止支持了…
  • 备份好conf文件,虽然一般不会有问题…

        先搞php

      wget http://cn2.php.net/get/php-5.2.11.tar.gz/from/cn.php.net/mirror
      tar xvzf php-5.2.11.tar.gz
      cd php-5.2.11
      './configure' '--prefix=/usr/local/php' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-zlib-dir' '--with-bz2' '--with-tiff-dir' '--with-gd=/usr/local/gd2' '--with-freetype-dir' '--with-jpeg-dir' '--with-png-dir' '--with-ttf' '--enable-mbstring' '--with-mysql=/usr/local/mysql' '--with-config-file-path=/etc' '--disable-ipv6' '--enable-static'
      make;make install

    然后搞ZO

     

    没啥好说的…bs Zend,居然要注册才给地址

    http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz

    另外暂时不支持php5.3.0。

     

    然后搞Apache:

     

    [root@www1 ~]# ./configure "--prefix=/usr/local/apache2" "--enable-module=so" "--enable-deflate=shared" "--enable-expires=shared" "--enable-rewrite=" "--enable-static-support" "--enable-static-htpasswd" "--enable-static-htdigest" "--enable-static-rotatelogs" "--enable-static-logresolve" "--enable-static-htdbm" "--enable-static-ab" "--enable-static-checkgid" "--enable-ssl" "--disable-userdir" "--with-ssl=/usr/local/openssl" "--with-apr=/usr/local/apr" "--with-apr-util=/usr/local/apr-util/bin"
    [root@www1 ~]# make;make install
    [root@www1 ~]# /usr/local/apache2/bin/apachectl stop
    [root@www1 ~]# /usr/local/apache2/bin/apachectl start
    [root@www1 ~]# /usr/local/apache2/bin/apachectl -v

     

    打完收工。

    分类: Apache, Linux, PHP 标签: , ,

    mysql备份之mysqldump

    2009年8月23日 baalchina 没有评论

    mysqldump其实就是把mysql数据库dump成sql文件。速度相当快(当然,没有直接copy快..哈哈),兼容性好。sql语句嘛,通吃的。

    最简单的dump:

    /usr/local/mysql/bin/mysqldump --uroot --ppassword discuz cdb_members > /data/backup/members.sql

    rsync --vzrtopg –progress  --delete rsync://ubuntu.srt.cn/ubuntu/ /cygdrive/L/mirror/ubuntu/

     

    就是把discuz库的cdb_members表dump成members.sql文件。

    mysqldump还有很多参数,常用的:

    • --opt,等同与添加--add-drop-table --add-locks --create-options --disable-keys --extended-insert --lock-tables --quick --set-charset这一堆参数
    • --lock-tables,锁表。dump的时候把这个表锁起来,保证的完整性。
    • --lock-all-tables,锁有的表,保证的完整性。

     

    参考:

    http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html

    分类: Linux, Mysql 标签: , ,

    mysql的常用操作命令

    2009年8月20日 baalchina 没有评论

    检测并修复数据库

    修复特定库(database)

    /usr/local/mysql/bin/mysqlcheck -o -r database –uroot –ppassword

     

    修复所有库

    /usr/local/mysql/bin/mysqlcheck -A -o -r -uroot –ppassword

     

    如果只修复特定表:

    /usr/local/mysql/bin/mysqlcheck -c -r discuz cdb_ai -uroot –ppassword

     

     

    备份数据库,mysqldump

    参考:mysqldump的使用

    分类: Linux, Mysql 标签: ,

    Linux集群的安装与配置(Part II,配置)

    2009年8月13日 baalchina 没有评论

    Heartbeat的配置文件主要是3个,也就是前面我们cp到/etc/ha.d下面的ha.cfharesources以及authkeys,作用可以理解为系统配置,资源配置,以及认证的设置。一个个搞定。

     

    ha.cf

    配置比较简单,保证能跑起来

    #logfile
    debugfile /var/log/ha-debug
    logfile /var/log/ha-log
    logfacility     local0

    #time setting
    keepalive 2
    deadtime 30
    warntime 10
    initdead 120

    #network setting
    udpport 694
    bcast eth1
    ucast eth1 192.168.100.2

    #node setting
    auto_failback on
    node    linux-ha-a
    node    linux-ha-b

    我这边跑的是双网卡。其中eth1作为心跳线,配置了192.168.100.1/2两个地址。

    haresources

    最简配制的话其实就是一条:

     

    #this is resource config
    linux-ha-a 210.28.92.233 httpd::start

    三段:

    主机名,集群的ip,需要启动的服务::传递给这个服务的参数。

    文件介绍上说两台设备的haresources要完全一样,你可别真的完全一样把主机名也一样了…哈。

     

     

    authkeys

    这个支持3种认证方式,sha1>md5>crc。其中前两种需要指定密钥。crc只做校验用,没认证的效果。这个文件需要保证600权限。

    因为是测试就简单点了,用MD5,验证码用linux-ha的md5值(17bc50a13f1dd31c14f2a3f321e017dc)。实际上直接输入一个字符串就可以了,没必要输入md5的值。

     

    注意这个类似于eigrp的认证,是支持多个key-chain的。

    auth 1
    #1 crc
    #2 sha1 HI!
    1 md5 17bc50a13f1dd31c14f2a3f321e017dc

    注意auth 1必须对应下面的1 md5 key

     

    检测效果/MAC切换机制

    全部配置完成之后可以打开虚拟ip地址,网页可以打开,然后再关掉server-a的接口,然后再刷新,看看可否看到页面?

    我做的时候没自动切换,结果跑到交换机上#clea ip arp 才有效…郁闷…注意这个MAC地址:

    MAC:

    210.xx.yy.231   0          0050.56af.15fd arpa   VL922
    210.xx.yy.232   0          0050.56af.3842 arpa   VL922
    210.xx.yy.233   0          0050.56af.3842 arpa   VL922

    这时候232这台设备生效。233为虚拟MAC。

    可以看到的是,ha并没有诸如HSRP/VRRP那样的虚拟MAC机制。而是直接用的设备的MAC。

    你ssh到233,其实就是连接到232。

    待解决

    如果跑的是http,那么就要考虑共享存储的问题。静态的还好,如果是动态的呢?

    如果是数据库,同样要考虑存储。不过mysql本身的cluster应该可以解决--据说是不用共享存储的。

    分类: Cluster, Linux 标签: , ,