知识共享许可协议
本作品采用知识共享署名-非商业性使用-禁止演绎 3.0 未本地化版本许可协议进行许可。

Openstack Nova-Network flatdhcp 变更 CIDR

网络情况
  • 旧网络

    +--------------------------------------+-------+-------------+
    | ID                                   | Label | CIDR        |
    +--------------------------------------+-------+-------------+
    | 6ec2fb7e-6043-44a9-8d35-6594e93e01ee | vmnet | 10.0.0.0/29 |
    +--------------------------------------+-------+-------------+
    
    network_id = 3
    
  • 新网络

    +--------------------------------------+-------+-------------+
    | ID                                   | Label | CIDR        |
    +--------------------------------------+-------+-------------+
    | 6ec2fb7e-6043-44a9-8d35-6594e93e01ee | vmnet | 10.0.0.0/24 |
    +--------------------------------------+-------+-------------+
    
    network_id = 3
    
备份nova数据库
mysqldump -uroot -p123123 nova > ~/nova.dump
更新networks表
UPDATE networks set cidr='10.0.0.0/24',netmask='255.255.255.0',gateway='10.0.0.1',broadcast='10.0.0.255',dhcp_start='10.0.0.2' where id=3
更新fixed_ips表
for i in {0..255}
do
    mysql -uroot -p123123 nova -e "INSERT INTO fixed_ips (created_at, deleted, address, network_id, allocated,leased,reserved) values (now(),0,'10.0.0.$i',3,0,0,0)"
done

update fixed_ips set created_at=now(), deleted=0, allocated=0, leased=0, reserved=1 where address='10.0.0.0';
update fixed_ips set created_at=now(), deleted=0, allocated=0, leased=0, reserved=1 where address='10.0.0.1';
update fixed_ips set created_at=now(), deleted=0, allocated=0, leased=0, reserved=1 where address='10.0.0.3';
update fixed_ips set created_at=now(), deleted=0, allocated=0, leased=0, reserved=1 where address='10.0.0.254';
update fixed_ips set created_at=now(), deleted=0, allocated=0, leased=0, reserved=1 where address='10.0.0.255';
重启相关服务
ip addr delete 10.0.0.3/29 dev br1
pkill dnsmasq
service openstack-nova-compute restart
service openstack-nova-network restart