ovs-sandbox 启动

145 阅读5分钟

我这边使用的是 kube-ovn 的镜像,ovs 是已经安装过的,所以可以直接使用 ovs-sandbox 启动

启动过程如下:



root@b3c62bb5c244:/usr/bin# bash -x ovs-sandbox  -i
+ set -e
+ gdb_vswitchd=false
+ gdb_ovsdb=false
+ gdb_vswitchd_ex=false
+ gdb_ovsdb_ex=false
+ builddir=
+ srcdir=
+ schema=
+ installed=false
+ built=false
+ dummy=override
+ for option in "$@"
+ test -n ''
+ case $option in
+ optarg=yes
+ case $dashdash$option in
+ installed=:
+ shift
+ :
+ false
+ :
+ :
+ false
+ case $schema in
+ for schema in /usr/local/share/openvswitch/vswitch.ovsschema /usr/share/openvswitch/vswitch.ovsschema none
+ test -r /usr/local/share/openvswitch/vswitch.ovsschema
+ for schema in /usr/local/share/openvswitch/vswitch.ovsschema /usr/share/openvswitch/vswitch.ovsschema none
+ test -r /usr/share/openvswitch/vswitch.ovsschema
+ break
+ test '!' -r /usr/share/openvswitch/vswitch.ovsschema
+ rm -rf sandbox
+ mkdir sandbox
++ cd sandbox
++ pwd
+ sandbox=/usr/bin/sandbox
+ OVS_RUNDIR=/usr/bin/sandbox
+ export OVS_RUNDIR
+ OVS_LOGDIR=/usr/bin/sandbox
+ export OVS_LOGDIR
+ OVS_DBDIR=/usr/bin/sandbox
+ export OVS_DBDIR
+ OVS_SYSCONFDIR=/usr/bin/sandbox
+ export OVS_SYSCONFDIR
+ false
+ trap 'kill `cat "$sandbox"/*.pid`' 0 1 2 3 13 14 15
+ touch /usr/bin/sandbox/.conf.db.~lock~
+ run ovsdb-tool create conf.db /usr/share/openvswitch/vswitch.ovsschema
+ echo ovsdb-tool create conf.db /usr/share/openvswitch/vswitch.ovsschema
ovsdb-tool create conf.db /usr/share/openvswitch/vswitch.ovsschema
+ cd /usr/bin/sandbox
+ ovsdb-tool create conf.db /usr/share/openvswitch/vswitch.ovsschema
+ ovsdb_server_args=
+ rungdb false false ovsdb-server --detach --no-chdir --pidfile -vconsole:off --log-file -vsyslog:off --remote=punix:/usr/bin/sandbox/db.sock --remote=db:Open_vSwitch,Open_vSwitch,manager_options
+ under_gdb=false
+ gdb_run=false
+ shift
+ shift
+ false
+ run ovsdb-server --detach --no-chdir --pidfile -vconsole:off --log-file -vsyslog:off --remote=punix:/usr/bin/sandbox/db.sock --remote=db:Open_vSwitch,Open_vSwitch,manager_options
+ echo ovsdb-server --detach --no-chdir --pidfile -vconsole:off --log-file -vsyslog:off --remote=punix:/usr/bin/sandbox/db.sock --remote=db:Open_vSwitch,Open_vSwitch,manager_options
ovsdb-server --detach --no-chdir --pidfile -vconsole:off --log-file -vsyslog:off --remote=punix:/usr/bin/sandbox/db.sock --remote=db:Open_vSwitch,Open_vSwitch,manager_options
+ cd /usr/bin/sandbox
+ ovsdb-server --detach --no-chdir --pidfile -vconsole:off --log-file -vsyslog:off --remote=punix:/usr/bin/sandbox/db.sock --remote=db:Open_vSwitch,Open_vSwitch,manager_options
+ sleep 0.1
+ test '!' -e /usr/bin/sandbox/db.sock
+ run ovs-vsctl --no-wait -- init
+ echo ovs-vsctl --no-wait -- init
ovs-vsctl --no-wait -- init
+ cd /usr/bin/sandbox
+ ovs-vsctl --no-wait -- init
+ rungdb false false ovs-vswitchd --detach --no-chdir --pidfile -vconsole:off --log-file -vsyslog:off --enable-dummy=override -vvconn -vnetdev_dummy
+ under_gdb=false
+ gdb_run=false
+ shift
+ shift
+ false
+ run ovs-vswitchd --detach --no-chdir --pidfile -vconsole:off --log-file -vsyslog:off --enable-dummy=override -vvconn -vnetdev_dummy
+ echo ovs-vswitchd --detach --no-chdir --pidfile -vconsole:off --log-file -vsyslog:off --enable-dummy=override -vvconn -vnetdev_dummy
ovs-vswitchd --detach --no-chdir --pidfile -vconsole:off --log-file -vsyslog:off --enable-dummy=override -vvconn -vnetdev_dummy
+ cd /usr/bin/sandbox
+ ovs-vswitchd --detach --no-chdir --pidfile -vconsole:off --log-file -vsyslog:off --enable-dummy=override -vvconn -vnetdev_dummy
+ cat



----------------------------------------------------------------------
You are running in a dummy Open vSwitch environment.  You can use
ovs-vsctl, ovs-ofctl, ovs-appctl, and other tools to work with the
dummy switch.

Log files, pidfiles, and the configuration database are in the
"sandbox" subdirectory.

Exit the shell to kill the running daemons.
+ status=0
+ /bin/bash
root@b3c62bb5c244:/usr/bin# ps -a
    PID TTY          TIME CMD
     80 pts/1    00:00:00 bash
     94 pts/1    00:00:00 bash
     97 pts/1    00:00:00 ps
root@b3c62bb5c244:/usr/bin# ps -aux # 刚启动的时候看不到,过一会儿就可以了
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  0.0  0.0    220     0 ?        Ss   04:26   0:00 /usr/bin/dumb-init -- sleep infinity
root           7  0.0  0.0   2268  1024 pts/0    Ss+  04:26   0:00 sleep infinity
root          51  0.0  0.0   4296  3584 pts/1    Ss   05:48   0:00 bash
root          80  0.0  0.0   4032  2944 pts/1    S    05:48   0:00 bash -x ovs-sandbox -i
root          87  0.0  0.0  11324  7152 ?        Ss   05:48   0:00 ovsdb-server --detach --no-chdir --pidfile -vconsole:off --log-file -vsyslog:off --remote=punix:/usr/bin/sandbox/db.sock --remote=db:Open_vSwitch,Open_vSwitch,manager_options
root          91  0.0  0.0  15268  5116 ?        Ss   05:48   0:00 ovs-vswitchd --detach --no-chdir --pidfile -vconsole:off --log-file -vsyslog:off --enable-dummy=override -vvconn -vnetdev_dummy
root          94  0.0  0.0   4296  3584 pts/1    S    05:48   0:00 /bin/bash
root          98  0.0  0.0   7628  3584 pts/1    R+   05:50   0:00 ps -aux
root@b3c62bb5c244:/usr/bin# ls -l /usr/bin/sandbox/db.sock
srwxr-x--- 1 root root 0 Nov  7 05:48 /usr/bin/sandbox/db.sock
root@b3c62bb5c244:/usr/bin# /usr/bin/ovs-vsctl --db=unix:/usr/bin/sandbox/db.sock show
502368ff-022e-4583-b85f-ab20bbb43a96

ctrl + D 就会自动退出


exit
+ cat
----------------------------------------------------------------------



+ exit 0
++ cat /usr/bin/sandbox/ovs-vswitchd.pid /usr/bin/sandbox/ovsdb-server.pid
+ kill 91 87
root@b3c62bb5c244:/usr/bin#
root@b3c62bb5c244:/usr/bin#
root@b3c62bb5c244:/usr/bin#
root@b3c62bb5c244:/usr/bin#
root@b3c62bb5c244:/usr/bin# ps -aux
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  0.0  0.0    220     0 ?        Ss   04:26   0:00 /usr/bin/dumb-init -- sleep infinity
root           7  0.0  0.0   2268  1024 pts/0    Ss+  04:26   0:00 sleep infinity
root          51  0.0  0.0   4296  3584 pts/1    Ss   05:48   0:00 bash
root         106  0.0  0.0   7628  3584 pts/1    R+   06:13   0:00 ps -aux


在 tmp 目录下启动比较方便调试


root@b3c62bb5c244:/tmp# ps -aux
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  0.0  0.0    220     0 ?        Ss   04:26   0:00 /usr/bin/dumb-init -- sleep infinity
root           7  0.0  0.0   2268  1024 pts/0    Ss+  04:26   0:00 sleep infinity
root         263  0.0  0.0   4296  3584 pts/1    Ss   06:19   0:00 bash
root         274  0.0  0.0   4032  2944 pts/1    S    06:19   0:00 bash -x ovs-sandbox -i
root         281  0.0  0.0  11324  7148 ?        Ss   06:19   0:00 ovsdb-server --detach --no-chdir --pidfile -vconsole:off --log-file -vsyslog:off --remote=punix:/tmp/sandbox/db.sock --remote=db:Open_vSwitch,Open_vSwitch,manager_options
root         285  0.0  0.0  15268  5112 ?        Ss   06:19   0:00 ovs-vswitchd --detach --no-chdir --pidfile -vconsole:off --log-file -vsyslog:off --enable-dummy=override -vvconn -vnetdev_dummy
root         288  0.0  0.0   4296  3584 pts/1    S    06:19   0:00 /bin/bash
root         291  0.0  0.0   7628  3584 pts/1    R+   06:19   0:00 ps -aux
root@b3c62bb5c244:/tmp#
root@b3c62bb5c244:/tmp#
root@b3c62bb5c244:/tmp#
root@b3c62bb5c244:/tmp# /usr/bin/ovs-vsctl --db=unix:/tmp/sandbox/db.sock show
8b7111db-3c5f-489c-815b-10da688e4f5f