daemonize 企业后台运作prometheus
使用 daemonize 将进程放入后台使用,daemonize Unix 系统后台守护进程管理
优点:更加正规,后台运行更稳定
编译安装:
git clone git://github.com/bmc/daemonize.git && cd daemonize
sh configure && make && make install
daemonize -v
指定运行启动脚本:
-c 指定运行路径
daemonize -c /usr/local/prometheus /usr/local/prometheus/up.sh
Ps -elf | grep prometheus | grep -v gluster 查看进程是否启动
prometheus/up.sh 内容如下:
/usr/local/prometheus/prometheus --config.file="prometheus.yml" --web.listen-address="0.0.0.0:9090" --web.read-timeout=5m --web.max-connections=10 --storage.tsdb.retention=15d --storage.tsdb.path="/usr/local/prometheus/data" --query.max-concurrency=20 --query.timeout=2m
启动优化参数:
-
–config.file=“prometheus.yml” 指定配置文件
-
–web.read-timeout=5m 请求链接的最大等待时间,防止太多的空闲链接占用资源
-
–web.max-connections=512 针对prometheus,获取数据源的时候,建立的网络链接数,做一个最大数字的限制,防止链接数过多造成资源过大的消耗
-
–storage.tsdb.retention=15d 重要参数,prometheus 开始采集监控数据后,会存在内存和硬盘中;对于保存期限的设置。时间过长,硬盘和内存都吃不消;时间太短,要查历史数据就没了。企业15天最为合适。
-
–storage.tsdb.path="/usr/local/prometheus/data" 存储数据路径,不要随便定义
-
–query.max-concurrency=20 用户查询最大并发数
-
–query.timeout=2m 慢查询强制终止
启动之后别忘了开防火墙端口:
firewall-cmd --add-port=9090/tcp
firewall-cmd --add-port=9100/tcp
访问:http://192.168.168.11:9090