環境准備
- centos 7
- 新數據盤100G
- 官方prometheus docker鏡像
- 一份准備好的prometheus.yml配置文件
官方的prometheus docker安裝的介紹頁面https://prometheus.io/docs/prometheus/latest/installation/
yum install lvm2 -y #新硬盤初始化,並且設置為lvm的格式,不做詳細描述 #請參考https://www.cnblogs.com/faberbeta/p/linux-shell015.html #安裝docker ,不做詳細介紹 #請參考https://www.cnblogs.com/faberbeta/p/12853704.html mkdir /prometheus/ mount /dev/mapper/lvmgroup-prometheus /prometheus/ cd /prometheus/ mkdir data
#記得修改文件夾的屬性或者擁有者為nobody,不然映射后,docker起不來 chmod 777 data wget -O prometheus.yml http://download.zhufunin.com/prometheus.yml docker run -d \
--restart=always \
--name prometheus \ -p 9090:9090 \ -v /prometheus/etc/:/etc/prometheus/ \ -v /prometheus/data/:/prometheus \ prom/prometheus
踩過的坑
一開始掛載單文件如 -v /prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
但是發現,宿主機中修改,容器中不改變,參考docker掛載單文件問題