存档

文章标签 ‘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 标签: ,

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, 服务器管理 标签: , ,

MySQL的安装

2009年11月21日 baalchina 没有评论

Mysql的安装还是比较简单的。

 

首先去下载源码包,注意选择Source。

 

一路编译,安装。

参考:

 

http://dev.mysql.com/doc/refman/5.1/zh/installing.html#quick-install

shell> groupadd mysql

shell> useradd -g mysql mysql

shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -

shell> cd mysql-VERSION

shell> ./configure --prefix=/usr/local/mysql

shell> make

shell> make install

shell> cp support-files/my-medium.cnf /etc/my.cnf

shell> cd /usr/local/mysql

shell> bin/mysql_install_db --user=mysql

shell> chown -R root  .

shell> chown -R mysql var

shell> chgrp -R mysql .

shell> bin/mysqld_safe --user=mysql &

我编译用的是这个参数:

./configure --prefix=/usr/local/mysql --with-comment=Source --with-server-suffix=-Nau_MySQL --with-mysqld-user=mysql --without-debug --with-big-tables --with-charset=gbk --with-collation=gbk_chinese_ci --with-extra-charsets=all --with-pthread --enable-static --enable-thread-safe-client --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --without-isam --without-innodb --without-ndb-debug

安装好之后,记得给MySQL设置一个密码

mysqladmin uroot -password123456

 

或者

shell> mysql -u root

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');

 

http://dev.mysql.com/doc/refman/5.1/zh/installing.html#default-privileges

分类: 未分类 标签: ,

Linux(RHEL)下使用IBM Ds400阵列柜

2009年11月13日 baalchina 没有评论

服务器是RHEL AS3,内核版本2.4。卡是Qlogic的2430,阵列是ds400。

首先当然是做好访问权限设置了。启动之前Ctrl+Q设置。这个很简单。

 

安装驱动的命令如下:

wget www.nau.edu.cn/qla2x00-v7.07.06-1-dist.tgz
tar xvzf qla2x00-v7.07.06-1-dist.tgz
cd qlogic/
sh -x drvrinstall
./libinstall
make all SMP=1
make all install
modprobe -v qla2300
fdisk –l

至此,顺利的话fdisk -l已经可以看到sdb,也就是阵列了。

我们还要让它自动加载。

vi /etc/modules.conf

增加两行:

alias scsi_hostadapter2 qla2300_conf
alias scsi_hostadapter3 qla2300

 

然后做一个镜像,并cp到/boot/

mkinitrd -f ql2340.img 2.4.21-27.ELsmp
cp ql2340.img /boot/

编辑grub.conf,添加这个镜像。

vi /etc/grub.conf

添加:

initrd /initrd-2.4.18-14.img

 

需要注意的是,生成镜像的时候要对应smp或者非smp生成。然后镜像要放到指定的启动选项下。

 

然后重启,fdisk -l,如果看到sdb,大功告成。

 

Tips:

  1. 注意mkinitrd -f ql2340.img 2.4.21-27.ELsmp,和mkinitrd -f ql2340.img 2.4.21-27.EL不是同一个命令哦。
  2. 没加载驱动之前,ds400的光纤卡灯是错误灯状态。

升级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 标签: ,