1. Docker 安裝
root@localhost ~]# curl -sSL https://get.daocloud.io/docker | sh
遇到問題:
Docker Docker 安裝后 報 Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
剛在新的 Centos 上安裝 Docker-CE,后運行docker run hello-world報錯Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
1 解決辦法 2 $ systemctl daemon-reload 3 $ sudo service docker restart 4 $ sudo service docker status (should see active (running)) 5 $ sudo docker run hello-world
2. InfluxDB 安裝
- 安裝環境:
CentOS7
- 在docker官方鏡像中找到influxdb(https://hub.docker.com/_/influxdb),根據安裝提示安裝, 安裝步驟
[root@localhost ~]# docker run -d -p 8086:8086 --name=influxdb influxdb

- 安裝完成后,通過api查詢服務是否安裝成功並啟動:
curl -G http://localhost:8086/query --data-urlencode "q=show databases"
- 打開8086防火牆端口,不然之后grafana在配置數據源的時候會訪問不到influxdb:
systemctl start firewalld.service --啟動防火牆 firewall-cmd --zone=public --add-port=8086/tcp --permanent systemctl restart firewalld.service --啟動防火牆
訪問地址:
http://localhost:8086 (localhost 換成機器ip)

3. 客戶端(win10) 安裝telegraf
3.1 下載和解壓縮(以管理員身份),執行下述命令
wget https://dl.influxdata.com/influxdb/releases/influxdb2-2.0.7-windows-amd64.zip -UseBasicParsing -OutFile influxdb2-2.0.7-windows-amd64.zip
Expand-Archive .\influxdb2-2.0.7-windows-amd64.zip -DestinationPath 'C:\Program Files\InfluxData\influxdb2\'
如果wget 報openssl的錯,則使用curl 下載命令, 然后將那個zip 下載后解壓到 C:\Program Files\InfluxData\telegraf
curl -O -L https://dl.influxdata.com/influxdb/releases/influxdb2-2.0.7-windows-amd64.zip -UseBasicParsing -OutFile influxdb2-2.0.7-windows-amd64.zip
3.2 設置環境變量
在本地Telegraf 的安裝目錄新建conf目錄,然后去influxdb上下載配置文件 win_system.conf 到conf目錄
再設置環境變量如下:
INFLUX_TOKEN= XXXXX (申請的token) INFLUX_CONFIG_PATH=C:\Program Files\InfluxData\telegraf\telegraf-1.19.0\conf\win_sytem.conf
3.3 安裝telegraf 為service
cmd 到該目錄,執行下面的命令,安裝和啟動service
cd C:\Program Files\InfluxData\telegraf\telegraf-1.19.0 telegraf.exe --config C:\Program Files\InfluxData\telegraf\telegraf-1.19.0\cnf\xdt_monitor_sytem.conf --service install --service-name=my-telegraf --service-display-name="My Telegraf" ###注意,此處要加入config參數,設置本地完整路徑,否則會查找默認的telegraf.conf ,不支持自定義的conf ###在win10 環境上, INFLUX_CONFIG_PATH 不生效 ### --config 設置遠端獲取conf時,token 權限低無法獲取
3.4 啟動telegraf
sc start my-telegraf
4. Mac 安裝telegraf
4.1 安裝telegraf
cd /usr/local/opt brew install telegraf
4.2 配置telegraf
mkdir /usr/local/opt/telegraf/conf
#下載附件的配置文件,放到conf目錄
vi ~/.bash_profile
# 添加如下內容
export PATH=/usr/local/opt/telegraf/bin:$PATH export INFLUX_TOKEN= XXXX(申請的token) export TELEGRAF_CONFIG_PATH=/usr/local/opt/telegraf/conf/mac_sytem.conf
#執行下面的命令,使之生效
source ~/.bash_profile
4.3 啟動telegraf
nohup telegraf &
5. Linux (CentOS7) 安裝telegraf
此處先略過
6. 查看監控DashBoard
InfluxDB2.0 在線安裝template
此處有很多監控不同主體的template 可以供在線安裝。回頭再研究
參考資料:
https://os.51cto.com/art/202103/650372.htm 安裝說明
https://docs.influxdata.com/influxdb/v2.0/install/ 官方文檔