脚本安装influxdb

参考

influxdb.sh

#!/bin/bash
## version 2.0
## author:wuzw
 
# 创建rpm存放目录,进入此目录,下载rpm
if [ ! -d /usr/local/rpm ]; then
    sudo mkdir -p /usr/local/rpm
    sudo chown -R teld:teld /usr/local/rpm
        echo  "<<<<<<<<<<<<<<<<<<<<Directoty /usr/local/rpm created success.>>>>>>>>>>>>>>>>>>>>"
    cd /usr/local/rpm
    wget https://dl.influxdata.com/influxdb/releases/influxdb-1.8.3.x86_64.rpm
        echo  "<<<<<<<<<<<<<<<<<<<<Rpm download success.>>>>>>>>>>>>>>>>>>>>"
else
    echo "<<<<<<<<<<<<<<<<<<<<Directoty /usr/local/rpm already exist.>>>>>>>>>>>>>>>>>>>>"
    sudo chown -R teld:teld /usr/local/rpm
    cd /usr/local/rpm
    wget https://dl.influxdata.com/influxdb/releases/influxdb-1.8.3.x86_64.rpm
        echo  "<<<<<<<<<<<<<<<<<<<<Rpm download success.>>>>>>>>>>>>>>>>>>>>"
fi
sleep 2
 
 
# 创建influxdb需要的目录
if [ ! -d /mnt/data/influxdb ]; then
    sudo mkdir -p /mnt/data/influxdb/
    sudo chown -R teld:teld /mnt/data/influxdb
    sudo mkdir /mnt/data/influxdb/meta
    sudo mkdir /mnt/data/influxdb/wal
    sudo mkdir /mnt/data/influxdb/data
        echo  "<<<<<<<<<<<<<<<<<<<<Directoty meta,wal,data created success.>>>>>>>>>>>>>>>>>>>>"
    cd /usr/local/rpm
else
    echo "<<<<<<<<<<<<<<<<<<<<Directoty already exist.>>>>>>>>>>>>>>>>>>>>"
    sudo chown -R teld:teld /mnt/data/influxdb
    cd /usr/local/rpm
fi
sleep 2
 
# 赋予rpm 执行权限
sudo chmod +x influxdb-1.8.3.x86_64.rpm
echo "<<<<<<<<<<<<<<<<<<<<Giving execute privilege success>>>>>>>>>>>>>>>>>>>>"
 
# 安装
sudo yum localinstall -y influxdb-1.8.3.x86_64.rpm
echo "<<<<<<<<<<<<<<<<<<<<Yum installed success.>>>>>>>>>>>>>>>>>>>>"
sleep 2
 
# 更改配置文件
sudo sed -i '12c \  reporting-disabled = true' /etc/influxdb/influxdb.conf
echo "<<<<<<<<<<<<<<<<<<<<Set configuration success.>>>>>>>>>>>>>>>>>>>>"
sleep 2
sudo sed -i '26c \  dir = "/mnt/data/influxdb/meta"' /etc/influxdb/influxdb.conf
echo "<<<<<<<<<<<<<<<<<<<<Set configuration success.>>>>>>>>>>>>>>>>>>>>"
sleep 2
 
sudo sed -i '45c \  dir = "/mnt/data/influxdb/data"' /etc/influxdb/influxdb.conf
echo "<<<<<<<<<<<<<<<<<<<<Set configuration success.>>>>>>>>>>>>>>>>>>>>"
sleep 2
 
sudo sed -i '48c \  wal-dir = "/mnt/data/influxdb/wal"' /etc/influxdb/influxdb.conf
echo "<<<<<<<<<<<<<<<<<<<<Set configuration success.>>>>>>>>>>>>>>>>>>>>"
sleep 2
 
sudo sed -i '60c index-version = "tsi1"' /etc/influxdb/influxdb.conf
echo "<<<<<<<<<<<<<<<<<<<<Set configuration success.>>>>>>>>>>>>>>>>>>>>"
sleep 2
echo "<<<<<<<<<<<<<<<<<<<<All configuration set success.>>>>>>>>>>>>>>>>>>>>"
echo "<<<<<<<<<<<<<<<<<<<<Starting influxdb.>>>>>>>>>>>>>>>>>>>>"
 
# 启动influxdb
sudo systemctl start influxdb
# 检查启动状态
echo "<<<<<<<<<<<<<<<<<<<<Here's influxdb's state.>>>>>>>>>>>>>>>>>>>>"
sudo systemctl status influxdb |grep Active| awk '{print $3}' | cut -d "(" -f2 |cut -d ")" -f1
sleep 2
 
# 添加influxdb到启动项
echo "<<<<<<<<<<<<<<<<<<<<Adding influxdb to startup...>>>>>>>>>>>>>>>>>>>>"
sudo systemctl enable influxdb.service
echo "<<<<<<<<<<<<<<<<<<<<Added success.>>>>>>>>>>>>>>>>>>>>"
echo "<<<<<<<<<<<<<<<<<<<<All things done, please check the follow description about status.>>>>>>>>>>>>>>>>>>>>"
sudo systemctl restart influxdb
sudo systemctl status influxdb |grep Active| awk '{print $3}' | cut -d "(" -f2 |cut -d ")" -f1

脚本参考,实际环境具体更改

上一篇:使用influxdb支持的稳定协议连接prometheus弃用remote_storage协议


下一篇:InfluxDB支持collectd数据收集的配置