• 「2013123」CentOS 5.5 x86_64 Installation and Configuration (for Univ. Labs)


    近来在学校某机房做了一些 Linux 服务器的工作,选用的操作系统是 CentOS 5.5 x86_64 版本,期间随手做了一些记录,便于回溯和参考(类似下图):

    image

    这里再对这些笔记,做一个梳理和总结,以及修正一些 note taking 过程中由于了解不够全面而产生的纰漏。记在这里,类似「development note」或者「reference guide」(方便其他人下一次的类似工作)。为了方便索引,直接用英文做为 items 的小标题。

    1. Installation of the Operating System.

    比较简单,图形化界面的安装方式,不罗嗦了。期间会遇到一些概念,尤其是在 partition 设置时,比如 RAID、LVM 等等,不要吝惜 Google 一下的时间,绝对值。(整体觉得磁盘 IO 这一块水很深,以后有机会再详细了解……)

    个人的建议是,不是特别必须,则不要使用 RAID(redundant array of independent disks)。RAID 似乎极其不灵活,这次服务器上四块 1T 的硬盘,其中三块被 RAID 0 了(安装的是 CentOS 5.5 i386 版本),另一个盘上的 Windows 系统又动不得,以至于不得不毁了原来的 i386 系统。

    虽说按照 wikipedia 的解释(附带个人的理解……),RAID 0 可以提升多块磁盘的 block 读写性能,也可以将多块物理硬盘(physical disks)合并成一个更大的逻辑磁盘(logical disk),但考虑到我们的场景并不需要多快的读写性能,对冗余备份(更高的 RAID level 可做到)也没要求,单块物理硬盘的容量(1T)也已经足够大,所以无需使用 RAID。

    LVM 则是个好东西,Logic Volumn Management,思路如下,即在物理磁盘上抽象一个 layer,做为逻辑磁盘(Logical Volumn);而逻辑磁盘的索引单位,则是物理磁盘上的 PE(Physical Extent)块。这比单纯的物理磁盘增加了灵活度,尤其是需要动态扩容时。

    image

    2. Modify .bashrc file.

    bashrc 和 bash_profile 文件的区别,参考《An Explanation of .bashrc and .bash_profile》。简单来讲,编辑 .bash_profile 更直截了当,但是一般做为图形化界面登陆的用户,编辑 .bashrc 即可。

    比如修改环境变量($PATH):

    export PATH="/sbin/:$PATH"

    关于 bash 这一块,有不少 introduction 可看,很早之前读过,但是基本忘记了,这里记录两个链接,也算是挖个坑,以后再来填…… 《A brief introduction to the bash shell》《BASH Programming Intro》

    3. Change file permission, chmod chown sudoers.

    chmod Quick Reference,以及更方便的数字表示法。chown 参考此链接。其基本使用如下:

    chmod u+x ./file
    chmod 755 ./file # "755" "rwx", each for file owner, group users, others.
    
    chown owner:group ./file

    sudoers 是为了某个用户能够使用 sudo,需要修改的文件是 /etc/sudoers,参考 wikipedia 可知:

    Unlike the su command, users typically supply their own password to sudo rather than the root password. After authentication, and if the /etc/sudoers configuration file permits the user access, then the system will invoke the requested command.

    对 /etc/sudoers 所做的修改如下:

    # ========================
    ## Allow root to run any commands anywhere 
    root ALL=(ALL) ALL
    
    # jtuki added.
    dzsyzx ALL=(ALL) ALL

    4. Not just sudo, understand root & how to become *real* root, and the *exact* full name of su command.

    这篇文章《How to become root》很好的阐述了 Redhat Linux Enterprise 及其 opensource derivatives 版本的 root 理念,简单来讲,为了获得 root 操作权限,以及使用 root 的环境变量,应该使用「su -」而不是「su」命令。

    关于 su 命令的全称问题,很早之前用 Ubuntu 时,一直以为 sudo 是 super user can do anything 的意思,现在才知道 su 全称是「substitute user」……

    5. Management of users: useradd, userdel, and the userful newusers batch command.

    添加用户参考《Ultimate guide to create linux users》,删除用户可以使用「userdel -r user_login_name」,可直接「man userdel」查找「-r」的含义,Linux 里估计除了源代码,就没什么比「man command_name」更有信息量了……

    还有一个非常有用的 newusers 命令,可以按照设定值,批量增加用户。由于 newusers 使用的 user info 文件是明文存储 passwd 信息,因此最好将 user info 文件权限设定好(参见上述 chmod 和 chown)。

    chmod 0600 /root/student-clients-users.txt
    newusers /root/student-clients-users.txt

    上面例子里的 student-clients-users.txt 文件,类似如下:

    user01:your-password:1001:1000:student user01:/home/user01:/bin/bash
    user02:your-password:1002:1000:student user02:/home/user02:/bin/bash
    user03:your-password:1003:1000:student user03:/home/user03:/bin/bash
    user04:your-password:1004:1000:student user04:/home/user04:/bin/bash
    user05:your-password:1005:1000:student user05:/home/user05:/bin/bash
    user06:your-password:1006:1000:student user06:/home/user06:/bin/bash

    除了密码采取明文存储,其他同 /etc/passwd 文件一致。参考此链接得知 /etc/passwd 文件格式,如下:

    image

    此外,需要注意的是,上述 student-clients-users.txt 应该采用 Unix/Linux 格式的换行符(而不是 Windows 换行符),而且最好采用 ANSI 编码(而不是 utf-8 编码)。

    6. Multi-language support? locale may be helpful.

    locale 可以修改默认的编码方式,参考此链接。我做的修改如下:

    $ sudo gedit /etc/sysconfig/i18n
    # ==================    
    # LANG="zh_CN.UTF-8"
    LANG="en_GB.UTF-8"
    ==========================
    [dzsyzx@dzsyzx ~]$ locale
    LANG=en_GB.UTF-8
    LC_CTYPE="en_GB.UTF-8"

    7. Use expect to extend your control over Linux system.

    expect 绝对是个神器,很早之前用过,不过当时是在 Windows 系统下,使用 Tcl 语言(expect 最初也是作为 Tcl 的一个扩展存在的,后来才有了 Python 的 pexpect 等等),当时还能配合正则表达式,熟练处理各种自动化操作…… 可现在基本全忘了……

    原本这次准备使用 expect 来处理批量增加用户(采用交互式自动化的方式,设定 password 啥的),但是后来发现了 newusers 这个命令,就没采用 expect 的方案。同样挖个坑吧,以后有机会再来填。pexpectoriginal expect《Expect 教程中文版》

    8. Use tar command to compress and uncompress files. Also, the unrar component. :-)

    常见的 tar 命令如下:

    sudo tar -xf ~/firefox-18.0.tar.bz2 -C /usr/share/firefox/
    sudo tar -cf ./directory.tar.gz directory

    这个链接讲述了如何添加 unrar 支持,以及很有用的 repoforge 链接

    image

    9. Want to find out which ports the programs are listening? netstat is the right choice.

    除了查找哪些端口正在被监听之外,netstat 号称是 Linux 平台上 network troubleshooting 的首选工具。了解不深,tutorial 在此。这次用到的命令如下:

    # -n: numeric, -t: tcp, -u: udp, -p: program, -l: listening.
    $ su -
    $ netstat -ntpul |less

    得到的结果类似如下(截图一部分):

    image

    10. Video card driver.

    对于我们的服务器而言,需要下载单独的显卡驱动(GT220),搜索「NVIDIA-Linux-x86_64-310.19.run」即可,或者是在 nViDIA 的官方站点上,下载上述驱动。安装过程需要首先关闭 X window system,如下:

    sudo init 3 # close X window system
    sudo ./NVIDIA-Linux-x86_64-310.19.run
    sudo init 5 # restore X window system

    11. Update installed programs or check for available programs in rpm package form? Use yum.

    这方面没太多研究,一般就是用「yum info pkg」和「yum install pkg」,其他 options 目前也没研究…… 挖坑待填,《CentOS 下常用的 yum 和 rpm 参数》

    12. XDMCP or VNC for remotely access.

    这次对 XDMCP 和 VNC 两个 remote control tool,都做了一些粗浅的了解。两者机制和应用场景有较大差别,在下一篇博客里再单独介绍。届时在评论列表里附上链接。:-)

    P.S.

    附张图,是 CentOS 在安装开始后的 donation 提示。与 Scientific Linux 这种有机构支撑的 Redhat Enterprise Linux opensource derivative 不同,CentOS 是纯粹由社区支撑,坚持下来不容易!……

    image8

  • 相关阅读:
    Java中用JXL导出Excel代码详解
    oracle之FUNCTION拙见
    oracle 存储过程详细介绍(创建,删除存储过程,参数传递等)1
    Crontab使用方式
    Git使用技巧(3)-- 远程操作
    Git使用技巧(2)-- 基本操作
    Git使用技巧(1)-- 配置【持续更新】
    Vim使用技巧(1) -- 普通模式技巧 【持续更新】
    sublime使用技巧(4)-- 其他技巧【持续更新】
    sublime使用技巧(3)-- 常用快捷键【持续更新】
  • 原文地址:https://www.cnblogs.com/jtuki/p/2874702.html
Copyright © 2020-2023  润新知