• 命令小结


    1、查看系统是否有指定的账号

    getent passwd 账号名称

    [root@b ~]# getent passwd nobody

    2、查询软件包中的执行命令

    rpm -q --scripts  软件包名

    [root@b ~]# rpm -q --scripts nginx

     3、查看yum安装历史记录

    yum history

    [root@b ~]# yum history
    Loaded plugins: fastestmirror
    ID | Command line | Date and time | Action(s) | Altered
    -------------------------------------------------------------------------------
    25 | install -y screen | 2019-06-22 04:41 | Install | 1
    24 | install -y vsftpd | 2019-06-21 01:36 | Install | 1
    23 | remove -y httpd | 2019-06-21 01:34 | Erase | 1 EE
    22 | install -y httpd | 2019-06-21 00:31 | Install | 3
    21 | install -y expect | 2019-06-07 22:49 | Install | 2
    20 | install -y libpng-devel | 2019-06-05 04:10 | Install | 1
    19 | install -y libwebp libjp | 2019-06-05 04:09 | I, U | 3
    18 | install -y curl-devel | 2019-06-05 04:05 | Install | 1
    17 | update curl | 2019-06-05 04:03 | I, U | 10
    16 | install -y libxml2-devel | 2019-06-05 04:00 | Install | 2
    15 | install -y epel-release | 2019-05-29 12:18 | Install | 1

    4、查看系统当前cpu核心数量 lscpu

    [root@b ~]# lscpu
    Architecture: x86_64
    CPU op-mode(s): 32-bit, 64-bit
    Byte Order: Little Endian
    CPU(s): 4
    On-line CPU(s) list: 0-3
    Thread(s) per core: 1

    5、查看nginx的work进程是运行在哪个cpu上的

    [root@b ~]# ps axo pid,cmd,psr  | grep nginx

    13008 nginx: master process nginx   2
    13009 nginx: worker process       3
    13010 nginx: worker process       0
    13130 grep --color=auto nginx       2

    6、监控nginx的work进程与cpu的关系

    [root@b ~]# watch -n0.5 'ps axo pid,cmd,psr | grep nginx'

    #每隔0.5秒扫描一次'ps axo pid,cmd,psr | grep nginx'程序的执行结果

    [root@b ~]# ab -c 1000 -n2000 http://192.168.0.104/

    #使用ab命令进行并发访问测试

    再看watch命令,可以发现work进程与cpu的对应关系发生变化

    编辑/etc/nginx/nginx.conf,设置work与cpu的绑定关系

    worker_cpu_affinity 0010 0100; (假设cpu为4核cpu)

    cpu mask 0001    0号cpu

          0010    1号cpu

          0100    2号cpu

          1000    3号cpu

     7、nginx指定work进程的优先级,[-20,20]

    编辑/etc/nginx/nginx.conf,

    添加worker_priority  number

    worker_priority 10;

    [root@b ~]# ps -axo pid,cmd,nice | grep nginx
    13008 nginx: master process nginx   0
    16192 nginx: worker process    10
    16193 nginx: worker process    10
    16220 grep --color=auto nginx    0

    #查看进程的优先级为10

    8、测试nginx虚拟主机

    [root@b ~]# curl 192.168.0.104

    9、ngx_http_core_module

    server_name name ……;

    虚拟主机的主机名称后可跟多个由空白字符分隔的字符串

    支持*通配任意长度的任意字符

    server_name *.magedu.com www.magedu.*

    支持~起始的字符做正则表达式模式匹配,性能原因慎用

    server_name   ~^wwwd+.magedu.com$

    说明:d表示[0-9],~表示匹配正则模式

    匹配优先级机制从高到低:

    (1)首先是字符串精确匹配 如:www.magedu.com

    (2)左侧*通配符 如:*.magedu.com

     (3)右侧*通配符 如 www.magedu.*

    (4)正则表达式 如  ~^.*.magedu.com$

    (5)default_server

    10、ngx_http_core_module

    = 对URL做精确匹配

      location = /  {

        ……

    }

    ^~    对URL的最左边部分做匹配检查,不区分字符大小写

    ~    对URL做正则表达式模式匹配,区分字符大小写

    ~*    对URL做正则表达式模式匹配,不区分字符大小写

    不带符合  匹配起始此URL的所有的URL

    匹配优先级从高到低: =,^~,~/~*,不带符号

  • 相关阅读:
    JAVA框架 Spring 事务
    JAVA框架 Spring 调用jdbcsuport简化开发
    JAVA框架 Spring JDBC模板
    JAVA框架 Spring AOP注解
    JAVA框架 Spring AOP--切入点表达式和通知类型
    JAVA框架 Spring AOP底层原理
    JAVA框架 Spring junit整合单元测试
    JAVA框架 Spring 注解注入
    JAVA框架 Spring 引入多个配置文件
    django序列化
  • 原文地址:https://www.cnblogs.com/xiaofeng666/p/11073499.html
Copyright © 2020-2023  润新知