當 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 開發者的必備技能吧。css
screen -x stack
注意:若是啓動失敗,能夠嘗試在執行下面的指令以後在從新嘗試啓動:web
script /dev/null
能夠看見 Terminal 最下方有一串白色的字符串,其中的每個數字對應一個子 screen 也就是一個 Openstack services 。
咱們能夠經過快捷鍵+數字的組合來切換到對應的子 screen 。’ * ‘ 所在的處的位置表示當前的 screen 是該 Service 的 screen。EXAMPLE:shell
14$(L) c-api 15-$(L) c-sch 16$(L) c-vol*
CTRL+a + number :切換到數字 number 對應的子 screen 中(number == 0 ⇒ shell)
windows
CTRL + a + ’ ⇒ 輸入number:當 number > 10 時,可使用這種方法來切換,固然 number < 10 時,也可使用。 推薦*api
CTRL + a + n :切換到下一個 screenruby
CTRL + a + p:切換到前一個 screenmarkdown
CTRL + a + a:返回上一個 screen session
CRTL + a + 稍等一秒 + shift + ‘:顯示全部的 screen 的列表工具
CTRL + [:開始滾動模式 ,而後可使用上下左右鍵滾屏ui
CTRL + ]:退出滾動模式
CTRL + a + H :保存 screen 到日誌文件,再按一次中止保存
CTRL + a + ?:獲取幫助信息
退出:
screen -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
CTRL + c:終止一個 screen ,Stop the services
進入但願 Restart 的 Openstack Services 的 screen 中,而後輸入 CTRL + c 結束這個進程,輸入 ↑並從新執行上一條指令。
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.
screen 有一個很是不方便的地方就是,有些電腦不能經過 CTRL + [|] 來實現屏幕的滾動,這根本沒法很好的觀察 Log ,因此建議將啓動指令 Copy 另一個 Terminal 執行。
注意:下列的指令的/opt/stack/
參數因各人的安裝路徑不一樣而異。
restart glance:
/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"
/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"
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"
/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"
/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"
/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"
/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"
/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"
/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"
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:
/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"
/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"
/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"