Devstack — screen 調試工具的使用

來源:互聯網
上載者:User
目錄

目錄 為什麼要使用 screen 工具 啟動 screen screen 的切換常用 退出和重新串連 screen Restart Openstack Services screen 指令選項總覽 Openstack 重啟指令 glance-api glance-registry nova-api nova-conduter nova-crt nova-network nova-scheduter nova-novnc nova-cauth nova-cpu c-api c-sch c-vol

為什麼要使用 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

退出: CRTL + a + ’ ⇒ 輸入 0 ,然後再輸入screen -d CRTL + a + d

重新串連:

#查看目前使用者啟動的 screenfanguiju@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.#上一條指令的Outputfanguiju@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"

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.