zoukankan      html  css  js  c++  java
  • Devstack — screen 调试工具的使用

    目录

    为什么要使用 screen 工具 ?

    当 Devstack 编译安装完 OpenStack 后,我们是不能通过 init 脚本或者 service 指令来与各个 Openstack Services 进行交互的。
    也就是说我们无法像使用 RDO 安装那样可以通过 systemctl restart openstack-nova-api.serice 来重启 nova-api 服务。
    因为 Devstack 的设计初衷是便于 Openstack developers 开发和调试 Openstack 代码,所以 Devstack 只能通过 screen 来启动服务,而且每一个 Openstack Services 都是一个子 screen 。Devstack 部署的 Openstack 相信大家都会遇见一个问题,当物理机重启后 Services 怎么重启,其实只需要执行 ./rejoin-stack.sh就好了,其原理跟启动 screen 是一样的,将没有启动的 Services 启动,已经启动的不会被覆盖,启动完成后自动进入 screen 。在 screen 中我们不仅仅可以启动 Services ,我们还能够非常清晰简便的切换查看各个 Services 的 Log 。本篇主要介绍了 screen 的使用,应该是多有 Openstack 开发者的必备技能吧。

    启动 screen

    screen -x stack

    这里写图片描述

    注意:如果启动失败,可以尝试在执行下面的指令之后在重新尝试启动:

    script /dev/null

    可以看见 Terminal 最下方有一串白色的字符串,其中的每一个数字对应一个子 screen 也就是一个 Openstack services 。
    我们可以通过快捷键+数字的组合来切换到对应的子 screen 。’ * ‘ 所在的处的位置表示当前的 screen 是该 Service 的 screen。EXAMPLE:

    14$(L) c-api  15-$(L) c-sch   16$(L) c-vol*

    screen 的切换(常用)

    • CTRL+a + number :切换到数字 number 对应的子 screen 中(number == 0 ⇒ shell)
      这里写图片描述

    • CTRL + a + ’ ⇒ 输入number:当 number > 10 时,可以使用这种方法来切换,当然 number < 10 时,也可以使用。 推荐*

    • CTRL + a + n :切换到下一个 screen

    • CTRL + a + p:切换到前一个 screen

    • CTRL + a + a:返回上一个 screen

    • CRTL + a + 稍等一秒 + shift + ‘:显示所有的 screen 的列表

    • CTRL + [:开始滚动模式 ,然后可以使用上下左右键滚屏

    • CTRL + ]:退出滚动模式

    • CTRL + a + H :保存 screen 到日志文件,再按一次停止保存

    • CTRL + a + ?:获取帮助信息

    退出和重新连接 screen

    • 退出

      1. CRTL + a + ’ ⇒ 输入 0 ,然后再输入screen -d
      2. CRTL + a + d
    • 重新连接

    #查看当前用户启动的 screen
    fanguiju@jmilkfan:~$ screen -ls   
    There is a screen on:
        20569.stack (08/02/16 11:36:47) (Detached)
    1 Socket in /var/run/screen/S-fanguiju.
    
    #上一条指令的Output
    fanguiju@jmilkfan:~$ screen -r 20569  

    Restart Openstack Services

    • CTRL + c:终止一个 screen ,Stop the services

    • 进入希望 Restart 的 Openstack Services 的 screen 中,然后输入 CTRL + c 结束这个进程,输入 ↑并重新执行上一条指令。
      这里写图片描述

    screen 指令选项总览

    fanguiju@fanguiju:~/devstack$ screen --help 
    Use: screen [-opts] [cmd [args]]
     or: screen -r [host.tty]
    
    Options:
    -4            Resolve hostnames only to IPv4 addresses.
    -6            Resolve hostnames only to IPv6 addresses.
    -a            Force all capabilities into each window's termcap.
    -A -[r|R]     Adapt all windows to the new display width & height.
    -c file       Read configuration file instead of '.screenrc'.
    -d (-r)       Detach the elsewhere running screen (and reattach here).
    -dmS name     Start as daemon: Screen session in detached mode.
    -D (-r)       Detach and logout remote (and reattach here).
    -D -RR        Do whatever is needed to get a screen session.
    -e xy         Change command characters.
    -f            Flow control on, -fn = off, -fa = auto.
    -h lines      Set the size of the scrollback history buffer.
    -i            Interrupt output sooner when flow control is on.
    -l            Login mode on (update /var/run/utmp), -ln = off.
    -ls [match]   or -list. Do nothing, just list our SockDir [on possible matches].
    -L            Turn on output logging.
    -m            ignore $STY variable, do create a new screen session.
    -O            Choose optimal output rather than exact vt100 emulation.
    -p window     Preselect the named window if it exists.
    -q            Quiet startup. Exits with non-zero return code if unsuccessful.
    -r [session]  Reattach to a detached screen process.
    -R            Reattach if possible, otherwise start a new session.
    -s shell      Shell to execute rather than $SHELL.
    -S sockname   Name this session <pid>.sockname instead of <pid>.<tty>.<host>.
    -t title      Set title. (window's name).
    -T term       Use term as $TERM for windows, rather than "screen".
    -U            Tell screen to use UTF-8 encoding.
    -v            Print "Screen version 4.01.00devel (GNU) 2-May-06".
    -wipe [match] Do nothing, just clean up SockDir [on possible matches].
    -x            Attach to a not detached screen. (Multi display mode).
    -X            Execute <cmd> as a screen command in the specified session.
    

    Openstack 重启指令

    screen 有一个非常不方便的地方就是,有些电脑不能通过 CTRL + [|] 来实现屏幕的滚动,这根本无法很好的观察 Log ,所以建议将启动指令 Copy 另外一个 Terminal 执行。
    注意:下列的指令的/opt/stack/参数因各人的安装路径不同而异。
    restart glance:

    glance-api

    /usr/local/bin/glance-api --config-file=/etc/glance/glance-api.conf & echo $! >/opt/stack/status/stack/g-api.pid; fg || echo "g-api failed to start" | tee "/opt/stack/status/stack/g-api.failure"

    glance-registry

    /usr/local/bin/glance-registry --config-file=/etc/glance/glance-registry.conf & echo $! >/opt/stack/status/stack/g-reg.pid; fg || echo "g-reg failed to start" | tee "/opt/stack/status/stack/g-reg.failure"

    nova-api

    sudo /usr/local/bin/nova-api & echo $! >/opt/stack/status/stack/n-api.pid; fg || echo "n-api failed to start" | tee "/opt/stack/status/stack/n-api.failure"

    nova-conduter

    /usr/local/bin/nova-conductor --config-file /etc/nova/nova.conf & echo $! >/opt/stack/status/stack/n-cond.pid; fg || echo "n-cond failed to start" | tee "/opt/stack/status/stack/n-cond.failure"

    nova-crt

    /usr/local/bin/nova-cert --config-file /etc/nova/nova.conf & echo $! >/opt/stack/status/stack/n-crt.pid; fg || echo "n-crt failed to start" | tee "/opt/stack/status/stack/n-crt.failure"

    nova-network

    /usr/local/bin/nova-network --config-file /etc/nova/nova.conf & echo $! >/opt/stack/status/stack/n-net.pid; fg || echo "n-net failed to start" | tee "/opt/stack/status/stack/n-net.failure"

    nova-scheduter

    /usr/local/bin/nova-scheduler --config-file /etc/nova/nova.conf & echo $! >/opt/stack/status/stack/n-sch.pid; fg || echo "n-sch failed to start" | tee "/opt/stack/status/stack/n-sch.failure"

    nova-novnc

    /usr/local/bin/nova-novncproxy --config-file /etc/nova/nova.conf --web /opt/stack/noVNC & echo $! >/opt/stack/status/stack/n-novnc.pid; fg || echo "n-novnc failed to start" | tee "/opt/stack/status/stack/n-novnc.failure"

    nova-cauth

    /usr/local/bin/nova-consoleauth --config-file /etc/nova/nova.conf & echo $! >/opt/stack/status/stack/n-cauth.pid; fg || echo "n-cauth failed to start" | tee "/opt/stack/status/stack/n-cauth.failure"

    nova-cpu

    sg libvirtd '/usr/local/bin/nova-compute --config-file /etc/nova/nova.conf' & echo $! >/opt/stack/status/stack/n-cpu.pid; fg || echo "n-cpu failed to start" | tee "/opt/stack/status/stack/n-cpu.failure"

    restart cinder:

    c-api

    /usr/local/bin/cinder-api --config-file /etc/cinder/cinder.conf & echo $! >/opt/stack/status/stack/c-api.pid; fg || echo "c-api failed to start" | tee "/opt/stack/status/stack/c-api.failure"

    c-sch

    /usr/local/bin/cinder-scheduler --config-file /etc/cinder/cinder.conf & echo $! >/opt/stack/status/stack/c-sch.pid; fg || echo "c-sch failed to start" | tee "/opt/stack/status/stack/c-sch.failure"

    c-vol

    /usr/local/bin/cinder-volume --config-file /etc/cinder/cinder.conf & echo $! >/opt/stack/status/stack/c-vol.pid; fg || echo "c-vol failed to start" | tee "/opt/stack/status/stack/c-vol.failure"
  • 相关阅读:
    ie下如果已经有缓存,load方法的效果就无法执行.的解决方法
    css公共样式
    pageX、pageY全兼容
    js滚动加载插件
    getComputedStyle()与currentStyle
    excel15个技巧
    XMLHttpRequest函数
    继承模式
    cookie函数
    jQuery添加删除元素
  • 原文地址:https://www.cnblogs.com/jmilkfan-fanguiju/p/7532331.html
Copyright © 2011-2022 走看看