• CentOS(RHEL) 操作备忘


    1.安装中文语言包及切换

    yum groupinstall chinese-support

    vi /etc/sysconfig/i18n change en_US to zh_CN

    2.用户自动登录

    vi /etc/gdm/custom.conf

    [daemon]
    
    AutomaticLogin=root
    AutomaticLoginEnable=true
    TimedLoginEnable=true
    TimedLogin=root
    TimedLoginDelay=1

    3.RHEL 更改yum更新源为centos

    1、删除redhat原有的yum源
    
    # rpm -aq | grep yum|xargs rpm -e --nodeps
    2、下载新的yum安装包 
    
      这里我们使用CentOS的yum源
    
    #wget http://mirror.centos.org/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
    
    #wget http://mirror.centos.org/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
    
    # wget http://mirror.centos.org/centos/6/os/x86_64/Packages/yum-3.2.29-40.el6.centos.noarch.rpm
    
    #wget http://mirror.centos.org/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm
    
    3、安装yum软件包
    
    [root@localhost 桌面]# rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm 
    warning: python-iniparse-0.3.1-2.1.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
    Preparing...                ########################################### [100%]
        package python-iniparse-0.3.1-2.1.el6.noarch is already installed
    [root@localhost 桌面]# rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm 
    warning: yum-metadata-parser-1.1.2-16.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
    Preparing...                ########################################### [100%]
       1:yum-metadata-parser    ########################################### [100%]
    [root@localhost 桌面]# rpm -ivh yum-3.2.29-40.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm 
    warning: yum-3.2.29-40.el6.centos.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
    Preparing...                ########################################### [100%]
       1:yum-plugin-fastestmirro########################################### [ 50%]
       2:yum                    ########################################### [100%]
    [root@localhost 桌面]# yum update
    Loaded plugins: fastestmirror
    Setting up Update Process
    No Packages marked for Update
    
    
      注意:最后两个安装包要放在一起同时安装,否则会提示相互依赖,安装失败。

     4. CENTOS 6.4 安装后出现virt-who启动失败,提示没有rhsm.connection.

    安装python-rhsm包和python-simplejson包

    python-rhsm 可以在http://rpm.pbone.net/index.php3/stat/4/idpl/19915375/dir/scientific_linux_5/com/python-rhsm-1.0.10-1.el5.x86_64.rpm.html 下载编译安装

    python-simplejson可以用yum安装。
    本地下载python-rhsm
    http://files.cnblogs.com/biangbiang/python-rhsm-1.0.10.zip

    5.为centos增加rpmforce源地址

    RPMForce 包含一些其它的有用工具包,如我喜欢用的多窗口终端 terminator:

    wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
    
    rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
    
    rpm -K rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
    
    rpm -i rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm 
    
    yum install terminator

     6. fdisk 查看分区时遇到“Partition 1 does not end on cylinder boundary”警告

    Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *           1          26      204800   83  Linux
    Partition 1 does not end on cylinder boundary.
    /dev/sda2              26         287     2097152   83  Linux
    Partition 2 does not end on cylinder boundary.
    /dev/sda3             287        9726    75822111+  8e  Linux LVM
    This was a bit disconcerting at first, but after a few minutes of thinking it dawned on me that modern systems use LBA (Logical Block Addressing) instead of CHS (Cylinder/Head/Sector) to address disk drives. If we view the partition table using sectors instead of cylinders:
    刚开始很让人困惑,但是几分钟之后,我意识到现代操作系统使用LBA而不是CHS来记录硬盘分区.如果用扇区代替柱面,我们将看到:
    sfdisk -uS -l /dev/sda
    复制代码
    Disk /dev/sda: 9726 cylinders, 255 heads, 63 sectors/track
    Units = sectors of 512 bytes, counting from 0
    
       Device Boot    Start       End   #sectors  Id  System
    /dev/sda1   *        63    409662     409600  83  Linux
    /dev/sda2        409663   4603966    4194304  83  Linux
    /dev/sda3       4603967 156248189  151644223  8e  Linux LVM
    /dev/sda4             0         -          0   0  Empty
    We can see that we end at a specific sector number, and start the next partition at that number plus one. I must say that I have grown quite fond of sfdisk and parted, and they sure make digging through DOS and GPT labels super easy.
    我们可以看到,扇区是结束在一个特定的扇区,并且下一个分区的起始扇区在前一个的后面+1扇区.

     7. 扩展root分区。

    fdisk -l
    fdisk /dev/sda
    ... 增加物理硬盘并分区,假设新增的分区为/dev/sda3
    
    pvs
    pvcreate /dev/sda3
    vgs
    vgextend VolGroup /dev/sda3
    lvs
     lvextend /dev/VolGroup/lv_root /dev/sda3
    
     resize2fs /dev/VolGroup/lv_root

    df -h

     8.  Too many authentication failures for root :

    #临时办法
    ssh -o PubkeyAuthentication=no root@67.23.163.74

    #根本原因是使用ssh key互信的机器数超过了限制
    vi /etc/ssh/sshd_config
    MaxAuthTries 20 (默认是6)
    还有其它更安全的办法,参考:
    http://www.lamolabs.org/blog/6259/one-liner-working-around-the-ssh-error-message-too-many-authentication-failures-for-root/

     9. 常用命令

    删除0字节文件
    find -type f -size 0 -exec rm -rf {} ;
    
    查看进程,按内存从大到小排列
    ps -e   -o "%C   : %p : %z : %a"|sort -k5 -nr
    
    按cpu利用率从大到小排列
    ps -e   -o "%C   : %p : %z : %a"|sort   -nr
    
    查看http的并发请求数及其TCP连接状态:
    netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
    
    如何杀掉mysql进程:
    ps aux |grep mysql |grep -v grep  |awk'{print $2}' |xargs kill -9
    
    显示运行3级别开启的服务:
    ls /etc/rc3.d/S* |cut -c 15-
    
    取IP地址:
    ifconfig eth0 |grep "inet addr:" |awk '{print $2}'|cut -c 6-   或者
    ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print$1}'
    
    内存的大小:
    free -m |grep "Mem" | awk '{print $2}'
    
    统计一下服务器下面所有的jpg的文件的大小
    find / -name *.jpg -exec wc -c {} ;|awk '{print $1}'|awk '{a+=$1}END{print a}'
    
    统计代码行数:
    find nova/ -name "*.py" | xargs wc -l
    
    占用空间最多的文件或目录:
    # du -cks * | sort -rn | head -n 10
    
    进程总数
    ps aux | wc -l
    
    打开文件数目
    lsof | wc -l
    
    清除僵死进程。
    ps -eal | awk '{ if ($2 == "Z") {print $4}}' | kill -9
    
    匹配中文字符的正则表达式: [u4e00-u9fa5]
    匹配空白行的正则表达式:
    s*
    匹配首尾空白字符的正则表达式:^s*|s*$
    匹配Email地址的正则表达式:w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*
    匹配网址URL的正则表达式:[a-zA-z]+://[^s]*
    匹配ip地址:d+.d+.d+.d+
    
    重复执行命令:
    watch -n 1 -d 'netstat -nat | grep 9696 -c'
    watch -n 1 -d "mysql -uroot -pGalax8800 -e 'show processlist;' | grep quantum | wc -l"

     9.NFS mount chown 不管,按指定用户mount

    mount -t nfs -o vers=3  10.10.10.10:/nfshome /localhome
  • 相关阅读:
    Oracle spatial、openlayers、geoserver开发地理信息系统总结
    解决Geoserver请求跨域的几种思路,第二种思路用过
    OpenLayers中的球面墨卡托投影
    墨卡托投影、地理坐标系、地面分辨率、地图比例尺
    jQuery Easing 动画效果扩展
    jQuery实现鼠标移上弹出提示框,移出消失
    验证码生成组件--JCaptcha的使用
    jquery validate 验证
    Oracle查询错误分析:ORA-01791:不是SELECTed表达式
    启动tomcat报host-manager does not exist or is not a readable directory异常
  • 原文地址:https://www.cnblogs.com/biangbiang/p/3163804.html
Copyright © 2020-2023  润新知