consul kv导出和导入(备份)


 

导出

consul kv export -http-addr=ip:8500  -token="xxxx-xxxx-xxxx-xxxx-xxxxxx" > consul-kv.json

 

导入
consul kv import -http-addr=ip:8500  -token="xxxx-xxxx-xxxx-xxxx-xxxxxx" @/tmp/consul-kv.json

cat consul-kv.json | consul kv import  -http-addr=ip:9500 -token="xxxx-xxxx-xxxx-xxxx-xxxxxx" -

 

============未整理

/root/consul1.2.4 kv get -keys -http-addr=http://192.168.55.122:9500 -token="918c2471-504e-4104-8435-8547d08231e7"
/root/consul1.2.4 kv get -keys -separator -http-addr=http://192.168.55.122:9500 -token="918c2471-504e-4104-8435-8547d08231e7"


curl -s http://192.168.55.122:9500/v1/kv/jm?token="918c2471-504e-4104-8435-8547d08231e7"

 

curl -s http://192.168.55.122:9500/v1/kv/jm/db1/?token="918c2471-504e-4104-8435-8547d08231e7"
curl -s http://192.168.55.122:9500/v1/kv/test01/conf/a?token="918c2471-504e-4104-8435-8547d08231e7"

=====================
curl -s http://192.168.55.122:9500/v1/kv?/recurse?token="918c2471-504e-4104-8435-8547d08231e7"

curl -s http://192.168.55.122:9500/v1/kv/test01/conf/a?token="918c2471-504e-4104-8435-8547d08231e7"

 

rm -rf test.log
rm -rf aa
/root/consul1.2.4 get -keys -separator -http-addr=http://192.168.20.70:8500 | grep ':'| awk -F':' '{print $1}' >> aa
for i in `cat aa`
do
curl -s http://192.168.20.70:8500/v1/kv/$i | tr ',' '\n' | egrep -w 'Key|Value' | xargs -n2 >> test.log
done

=========================

/root/consul1.2.4 kv get -recurse -http-addr=http://192.168.55.122:9500 -token="918c2471-504e-4104-8435-8547d08231e7" > new.log
/root/consul1.2.4 kv get -recurse -http-addr=http://192.168.55.122:8500 -token="918c2471-504e-4104-8435-8547d08231e7" > old.log
new_md5=$(md5sum new.log | awk '{print $1}')
old_md5=$(md5sum old.log | awk '{print $1}')

if [[ $new_md5 == $old_md5 ]];then
echo "New and old consul configuration consistent"
else
echo "New and old consul configuration inconsistent"
fi


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM