使用apt install openvswitch-switch之后的ovsdb数据库连接

出现的问题如下:

root@b0f1e1ed539b:/# ovs-vsctl show
2021-11-01T12:36:01Z|00001|reconnect|WARN|unix:/var/run/openvswitch/db.sock: connection attempt failed (No such file or directory)
ovs-vsctl: unix:/var/run/openvswitch/db.sock: database connection failed (No such file or directory)

第一行的意思是没有找到运行的openvswitch套接字,去/var/run目录下查看。

root@b0f1e1ed539b:/# cd /var/run/
root@b0f1e1ed539b:/var/run# ls
cipc_app_x0  cipc_x1  lock          mul_appmulcli    mul_appmull2sw  network          shm       utmp
cipc_app_x1  cipc_x2  motd.dynamic  mul_appmulfab    mul_appmultr    resolvconf       sshd
cipc_x0      cipc_x3  mul.pid       mul_appmulhello  mul_appnbapi    sendsigs.omit.d  sshd.pid

发现并没有这个文件夹,所以使用mkdir创建一个。

root@b0f1e1ed539b:/var/run# mkdir openvswitch
root@b0f1e1ed539b:/var/run# ls
cipc_app_x0  cipc_x1  lock          mul_appmulcli    mul_appmull2sw  network      sendsigs.omit.d  sshd.pid
cipc_app_x1  cipc_x2  motd.dynamic  mul_appmulfab    mul_appmultr    openvswitch  shm              utmp
cipc_x0      cipc_x3  mul.pid       mul_appmulhello  mul_appnbapi    resolvconf   sshd

再去/etc/openvswitch文件夹下面查看有没有conf.db文件,如果没有说明ovs的数据库配置文件还没有创建,所以需要创建。

root@b0f1e1ed539b:/var/run# cd /etc/openvswitch/
root@b0f1e1ed539b:/etc/openvswitch# ls
root@b0f1e1ed539b:/etc/openvswitch# 

创建conf.db需要vswitch.ovsschema文件,这个文件一般在openvwitch下面,创建也如下:

root@b0f1e1ed539b:/etc/openvswitch# whereis openvswitch       
openvswitch: /etc/openvswitch /usr/share/openvswitch
root@b0f1e1ed539b:/etc/openvswitch# cd /usr/share/openvswitch/
root@b0f1e1ed539b:/usr/share/openvswitch# ls
bugtool-plugins  scripts  switch  vswitch.ovsschema
root@b0f1e1ed539b:/usr/share/openvswitch# ovsdb-tool create /etc/openvswitch/conf.db vswitch.ovsschema
root@b0f1e1ed539b:/usr/share/openvswitch# cd /etc/openvswitch/
root@b0f1e1ed539b:/etc/openvswitch# ls
conf.db

然后再执行下面的连接命令即可

ovsdb-server --remote=punix:/var/run/openvswitch/db.sock --remote=db:Open_vSwitch,Open_vSwitch,manager_options --private-key=db:Open_vSwitch,SSL,private_key --certificate=db:Open_vSwitch,SSL,certificate --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert --pidfile --detach
ovs-vsctl --no-wait init
ovs-vswitchd --pidfile --detach

上一篇:tshark -e 后可以接的特征数据名


下一篇:libpcap使用