zoukankan      html  css  js  c++  java
  • 故障排除及系统优化

    1.一台主机上的不同服务功能,就是通过端口区分,然后让外部人员访问。

    远程连接服务ssh 22

    2.客户端和服务端之间通信,就是可能使用不同协议。

    不同服务提供了不同的端口,对应了不同的功能,通信方式可能不同,这就需要一个标准,即协议。


    远程连接服务:

    查看进程和监听情况:

    [root@oldboy data1]# ps -ef|grep ssh
    root       1608      1  0 16:46 ?        00:00:00 /usr/sbin/sshd
    root       3497   1608  0 18:11 ?        00:00:00 sshd: root@pts/0 
    root       3598   3501  0 18:34 pts/0    00:00:00 grep ssh                     LISTEN      1608/sshd 
    [root@oldboy data1]# netstat -lntup|grep ssh
    tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1608/sshd           
    tcp        0      0 :::22                       :::*                        LISTEN      1608/sshd  

    排除故障:

    进入Windows 的 cmd    ping不通可能是网卡,防火墙有问题
    C:Usersasus>ping 192.168.182.129
    
    正在 Ping 192.168.182.129 具有 32 字节的数据:
    来自 192.168.182.129 的回复: 字节=32 时间<1ms TTL=64
    来自 192.168.182.129 的回复: 字节=32 时间<1ms TTL=64
    来自 192.168.182.129 的回复: 字节=32 时间<1ms TTL=64
    
    192.168.182.129 的 Ping 统计信息:
        数据包: 已发送 = 3,已接收 = 3,丢失 = 0 (0% 丢失),
    往返行程的估计时间(以毫秒为单位):
        最短 = 0ms,最长 = 0ms,平均 = 0ms

    服务是否是好的,从那个机器连接就从那个机器操作。

    telnet 192.168.182.129 22(服务器地址ip和端口port)

    服务不通原因:

    1.windows telnet客户端未打开

    打开方法:在设置里面找到telnet 勾选telnet客户端


    ping不通解决办法:

     1.服务端防火墙阻挡

    [root@oldboy /]# /etc/init.d/iptables stop
    iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
    iptables: Flushing firewall rules:                         [  OK  ]
    iptables: Unloading modules:                               [  OK  ]

     2.端口是否开启(以22端口为例)

    [root@oldboy /]# netstat -lntup+|grep 22
    tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1608/sshd           
    tcp        0      0 :::22                       :::*                        LISTEN      1608/sshd  
    [root@oldboy /]# netstat -lntup|grep sshd
    tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1608/sshd           
    tcp        0      0 :::22                       :::*                        LISTEN      1608/sshd  

    ssh重启方法:

    [root@oldboy /]# /etc/init.d/sshd restart
    Stopping sshd:                                             [  OK  ]
    Starting sshd:                                             [  OK  ]

    客户端ssh工具:securcrt,xshell,putty

    服务端ssh服务,进程名sshd,openssh,openssl


    通过客户端CRT上传下载文件(不可传目录):

    1.rz(上传),sz(下载)命令安装方法

      第一种:安装系统时包括rz,sz命令包组  dlal-up networking support

      第二种:安装系统后通过执行yum install lrzsz -y 或者 yum groupinstall“dlal -up networking support” -y命令来安装。


    linux用户:

    普通用户:老百姓

    虚拟用户:系统的傀儡,固定存在,满足Linux里面服务进程以及程序属主的要求而存在。

    进程以及程序都必须属于用户。

    root用户:权限较高,高级用户

    说明:

    • 普通用户切到root需要密码,而root切到普通不用。(快捷键切换ctrl+d)
    • $是普通用户提示符,#是root用户提示符。

     添加用户,密码:

    [root@oldboy /]# useradd liu            //添加用户liu
    [root@oldboy /]# tail -1 /etc/passwd      //查看用户
    liu:x:500:500::/home/liu:/bin/bash      
    [root@oldboy /]# passwd liu        //为用户设置/修改密码123456(不加用户名,代表当前用户)
    Changing password for user liu.
    New password: 
    BAD PASSWORD: it is too simplistic/systematic
    BAD PASSWORD: is too simple
    Retype new password: 
    passwd: all authentication tokens updated successfully.

    切换到用户,查看:(su    和   su - 的区别)

    [root@oldboy /]# su - liu        //切换用户为liu
    [liu@oldboy ~]$ whoami          //查看当前用户
    liu
    [liu@oldboy ~]$ 
     
     

     
     

    uname     打印系统信息  -m 32or64  -r 内核版本  -a 所有  -n 显示主机名  

    hostname  显示和设置主机名  默认是显示主机名,设置主机名可以hostname 名字(临时生效)


    Linux命令提示符由PS1环境变量控制。(临时生效)
    [root@oldboy ~]# set |grep PS1
    PS1='[u@h W]$ '
    [root@oldboy ~]# PS1='[u@h w	]$'
    [root@oldboy ~20:28:37]#
    [root@oldboy ~20:28:38]#
    [root@oldboy ~20:28:38]#
    [root@oldboy ~20:28:39]#
     

     
     关闭seLinux:
    [root@oldboy ~]# sed -i  's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
    [root@oldboy ~]# cat /etc/selinux/config                                        
    # This file controls the state of SELinux on the system.
    # SELINUX= can take one of these three values:
    #     enforcing - SELinux security policy is enforced.    //开启
    #     permissive - SELinux prints warnings instead of enforcing.
    #     disabled - No SELinux policy is loaded.          //关闭
    SELINUX=disabled  //已改配置,但是要生效必须重启Linux,而企业Linux一般不随便重启,所以需要下面的setenforce
    # SELINUXTYPE= can take one of these two values:
    #     targeted - Targeted processes are protected,
    #     mls - Multi Level Security protection.
    SELINUXTYPE=targeted
     

     
    查看和设置selinux状态:
    [root@oldboy ~]# getenforce
    Enforcing
    [root@oldboy ~]# setenforce          //重启前后都生效了
    usage:  setenforce [ Enforcing | Permissive | 1 | 0 ]
    [root@oldboy ~]# setenforce 0
    [root@oldboy ~]# getenforce
    Permissive
    [root@oldboy ~]# 
     

     
     运行级别:7个级别以及对应作用  (企业面试考)
     
    [root@oldboy ~]# cat /etc/inittab
    # inittab is only used by upstart for the default runlevel.
    #
    # ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
    #
    # System initialization is started by /etc/init/rcS.conf
    #
    # Individual runlevels are started by /etc/init/rc.conf
    #
    # Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf
    #
    # Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,
    # with configuration in /etc/sysconfig/init.
    #
    # For information on how to write upstart event handlers, or how
    # upstart works, see init(5), init(8), and initctl(8).
    #
    # Default runlevel. The runlevels used are:
    #   0 - halt (Do NOT set initdefault to this)  //关机
    #   1 - Single user mode              //单用户状态
    #   2 - Multiuser, without NFS (The same as 3, if you do not have networking)  //无NFS的多用户模式
    #   3 - Full multiuser mode            //完整的多用户模式
    #   4 - unused                    //保留,无使用
    #   5 - X11                      //桌面
    #   6 - reboot (Do NOT set initdefault to this)   //重启
    # 
    id:3:initdefault:
     
     查看当前系统运行级别:
    [root@oldboy ~]# runlevel
    N 3
     
     切换运行级别    init 
      重启和关机实例:
    [root@oldboy ~]# init 0
    [root@oldboy ~]# init 6
     
     

     
    关机:
      shutdown
      halt
      init 0 
      shutdown -h now
    重启:
      reboot 
      init 6
      reboot -r now
     
     

     
     关闭iptables防火墙:
    [root@oldboy ~]# /etc/init.d/iptables stop    //临时关闭
    iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
    iptables: Flushing firewall rules:                         [  OK  ]
    iptables: Unloading modules:                               [  OK  ]
    [root@oldboy ~]# /etc/init.d/iptables status    //查看状态
    iptables: Firewall is not running.
    [root@oldboy ~]# chkconfig iptables off    //开机也不启动
     
     

     
    更改字体:(客户端也要改)
    [root@oldboy ~]# cat /etc/sysconfig/i18n
    LANG="en_US.UTF-8"
    SYSFONT="latarcyrheb-sun16"
    [root@oldboy ~]# echo 'LANG='zh_CN.UTF-8'' >/etc/sysconfig/i18n
    [root@oldboy ~]# cat /etc/sysconfig/i18n                       
    LANG=zh_CN.UTF-8
    [root@oldboy ~]# echo $LANG            //未生效
    en_US.UTF-8
    [root@oldboy ~]# . /etc/sysconfig/i18n      //使他生效
    [root@oldboy ~]# cat /etc/sysconfig/i18n
    LANG=zh_CN.UTF-8
    [root@oldboy ~]# echo $LANG             
    zh_CN.UTF-8
     
     

     
     设置账号超时:
    [root@oldboy ~]# export TMOUT=10
    [root@oldboy ~]# 
    [root@oldboy ~]# timed out waiting for input: auto-logout   //10s提示超时

     
     histroy
      查看历史纪录
     history -c  
      清除历史纪录
     
    history -d [命令行号]
      清除指定某条命令
    ![命令号]
      执行指定某条命令
     
     
    设置纪录历史纪录个数
      临时生效:
      export  HISTFILESIZE=5   命令行命令对应文件的记录数
      export   HISTSIZE=5     命令历史记录数量
      export  TMOUT=10     连接的超时时间控变量
      
      永久生效:
      echo ''export    TMOUT=300"    >/etc/profile
      echo ''export    HISTFILESIZE=5 " >/etc/profile
      echo ''export    HISTSIZE=5 "  >/etc/profile
      source /etc/profile
     

     
     

     
    面试题:
     
    1.Linux如何优化?

    2.ssh服务连接不上,如何排查?

    3.32位和64位系统区别?

    4.linux的7种运行级别,以及对应作用?

    5.Linux系统从开机岛登陆前的启动流程?

  • 相关阅读:
    LabVIEW(数据库连接)
    单片机之静态局部变量static
    LabVIEW(数据库自动编号)
    为什么大电容滤低频,小电容滤高频 ?(转载)
    电容、频率的一点小关系(项目有关)
    深入理解计算机系统 第三部分程序间的交互和通信
    深入理解计算机系统chapter9
    深入理解计算机系统chapter8
    深入理解计算机系统chapter7
    深入理解计算机系统chapter6
  • 原文地址:https://www.cnblogs.com/liuyuanq/p/9646965.html
Copyright © 2011-2022 走看看