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 开发者的必备技能吧。web

启动 screen

screen -x stack

这里写图片描述

注意:若是启动失败,能够尝试在执行下面的指令以后在从新尝试启动:shell

script /dev/null

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

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

screen 的切换(经常使用)

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

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

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

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

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

  • CRTL + a + 稍等一秒 + shift + ‘:显示全部的 screen 的列表ui

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

  • 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"
相关文章
相关标签/搜索