redisデータベースの複製

rdbファイルの複製ではなく、db10 → db18とかに複製する方法。

[code]source_host=localhost
source_port=xxxx
source_db=10
target_host=localhost
target_port=xxxx
target_db=18
redis-cli -p $source_port -n $source_db keys \* | while read key; do echo "Copying $key"; \
redis-cli –raw -h $source_host -p $source_port -n $source_db DUMP "$key" | \
head -c -1|redis-cli -x -h $target_host -p $target_port -n $target_db RESTORE "$key" 0; done
[/code]

openstackで固定IPアドレスを振る

openstackのネットワークを管理するneutronについて
色んなサイトで「仮想ホストにDHCPでIPアドレスを割り当て、floatingIPを振って外部に公開する~」みたいな情報は見たけど、
実運用だとサーバーに固定でIPアドレスを振りたい。

10.0.0.1 ・・・ 仮想L3ゲートウェイ
10.0.0.2 ・・・ 仮想DHCP、DNS
10.0.0.3 ・・・ 仮想WEBサーバ(1)
10.0.0.4 ・・・ 仮想DBサーバ(1)
10.0.0.5 ・・・ 仮想DBサーバ(2)
10.0.0.6 ・・・ 仮想WEBサーバ(2)
とか、気持ち的に嫌なので。

仮想サーバーの/etc/sysconfig/network-scripts/ifcfg-eht0とかに直接IPアドレスを書いても、
neutronでネットワークポート(それにIPアドレスが紐づく)を管理してる為、残念ながらこのやり方では認識されない。

数時間調べて、コマンド的には以下で変更出来た。
[bash]
#DHCPで割り当てられたネットワークポートの削除
#仮想サブネット上でDHCPが無い場合は、この手順は不要
nova interface-detach 仮想ホスト名 Port ID

#ポートを作る
neutron port-create ネットワーク名 –fixed-ip ip_address=xxx.xxx.xxx.xxx

#作ったポートを、仮想ホストに割り当てる
nova interface-attach –port-id ポートID 仮想ホスト名
[/bash]

ただ、この状態だと対象の仮想サーバーに、新規にネットワークインターフェースが追加されることになるので、
/etc/udev/rules.d/70-persistent-net.rulesを修正する必要がある。