InfluxDB的安装

  推荐使用离线安装包安装,因为在线安装踩了坑,可能是最新版的yum仓库的包有问题,亦或是因为包和系统不兼容。个人的分析如下
  失败经过如下:

# 安装yum源
cat <<EOF | sudo tee /etc/yum.repos.d/influxdb.repo
[influxdb]
name = InfluxDB Repository - RHEL \$releasever
baseurl = https://repos.influxdata.com/rhel/\$releasever/\$basearch/stable
enabled = 1
gpgcheck = 1
gpgkey = https://repos.influxdata.com/influxdb.key
EOF

# 安装influxdb
sudo yum install influxdb

安装很顺利,但是当执行启动命令时

systemctl start influxdb

却失败了,我们查看错误信息如下:

[root@VM-0-7-centos /]$  service influxdb status
Redirecting to /bin/systemctl status influxdb.service
● influxdb.service - InfluxDB is an open-source, distributed, time series database
   Loaded: loaded (/usr/lib/systemd/system/influxdb.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2021-07-29 16:00:50 CST; 3s ago
     Docs: https://docs.influxdata.com/influxdb/
  Process: 795127 ExecStart=/usr/lib/influxdb/scripts/influxd-systemd-start.sh (code=exited, status=203/EXEC)

Jul 29 16:00:49 VM-0-7-centos systemd[1]: influxdb.service: Control process exited, code=exited status=203
Jul 29 16:00:49 VM-0-7-centos systemd[1]: influxdb.service: Failed with result 'exit-code'.
Jul 29 16:00:49 VM-0-7-centos systemd[1]: Failed to start InfluxDB is an open-source, distributed, time series database.
Jul 29 16:00:50 VM-0-7-centos systemd[1]: influxdb.service: Service RestartSec=100ms expired, scheduling restart.
Jul 29 16:00:50 VM-0-7-centos systemd[1]: influxdb.service: Scheduled restart job, restart counter is at 5.
Jul 29 16:00:50 VM-0-7-centos systemd[1]: Stopped InfluxDB is an open-source, distributed, time series database.
Jul 29 16:00:50 VM-0-7-centos systemd[1]: influxdb.service: Start request repeated too quickly.
Jul 29 16:00:50 VM-0-7-centos systemd[1]: influxdb.service: Failed with result 'exit-code'.
Jul 29 16:00:50 VM-0-7-centos systemd[1]: Failed to start InfluxDB is an open-source, distributed, time series database.

有一个错误信息非常刺眼:influxdb.service: Start request repeated too quickly.
通常情况下用户在搜索此错误的解决方案的时候,有些答案会告诉你是系统的设置的问题,可以对系统的ceph进行设置,蛋是此处不是这个原因,然后找到了另一个答案,因为权限的问题,这个时候我怀疑是因为并没有对influxdb安装之后的一些目录进行赋权限,然后查看了一些influx相关的文件

[root@VM-0-7-centos /]$  rpm -ql influxdb
/etc/influxdb/influxdb.conf
/etc/logrotate.d/influxdb
/usr/bin/influx
/usr/bin/influx_inspect
/usr/bin/influx_stress
/usr/bin/influxd
/usr/lib/influxdb/scripts/influxd-systemd-start.sh
/usr/lib/influxdb/scripts/influxdb.service
/usr/lib/influxdb/scripts/init.sh
/usr/share/man/man1/influx.1.gz
/usr/share/man/man1/influx_inspect.1.gz
/usr/share/man/man1/influx_stress.1.gz
/usr/share/man/man1/influxd-backup.1.gz
/usr/share/man/man1/influxd-config.1.gz
/usr/share/man/man1/influxd-restore.1.gz
/usr/share/man/man1/influxd-run.1.gz
/usr/share/man/man1/influxd-version.1.gz
/usr/share/man/man1/influxd.1.gz
/var/lib/influxdb
/var/log/influxdb

  然后按照网上说的要去给 /var/lib/influxdb进行赋权限的时候发现,influxdb目录下本该有三个目录data、meta、wal 却不见了,猜测是因为yum远安装时有部分文件没有安装,或者部分程序没有执行,导致程序不能正常启动,保险起见 , 卸载重装,这次采用离线安装的模式。

如何卸载influxdb

[root@VM-0-7-centos influxdb]$  rpm -e influxdb
Removed /etc/systemd/system/influxd.service.
Removed /etc/systemd/system/multi-user.target.wants/influxdb.service.

# 保险起见 yum也remove一下
[root@VM-0-7-centos influxdb]$  yum remove influxdb
Repository epel is listed more than once in the configuration
No match for argument: influxdb
No packages marked for removal.
Dependencies resolved.
Nothing to do.
Complete!

  以上,是通过yum源安装失败后,又卸载的过程。



离线安装InfluxDB

#下载rpm
wget https://dl.influxdata.com/influxdb/releases/influxdb-1.8.2.x86_64.rpm
#安装
yum localinstall influxdb-1.8.2.x86_64.rpm

# 启动服务 及 查看状态
root@VM-0-7-centos www]$  systemctl start influxdb

[root@VM-0-7-centos www]$  systemctl status influxdb
● influxdb.service - InfluxDB is an open-source, distributed, time series database
   Loaded: loaded (/usr/lib/systemd/system/influxdb.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2021-07-29 17:01:48 CST; 8s ago
     Docs: https://docs.influxdata.com/influxdb/
 Main PID: 811204 (influxd)
    Tasks: 7 (limit: 11507)
   Memory: 6.7M
   CGroup: /system.slice/influxdb.service
           └─811204 /usr/bin/influxd -config /etc/influxdb/influxdb.conf

[root@VM-0-7-centos www]$  influx -version
InfluxDB shell version: 1.8.2


查看/var/lib/influxdb目录,会发现,该目录下有初始化的一些列信息,可见在之前的yum源安装时,程序安装有缺陷,使用离线安装更为稳妥些。

[root@VM-0-7-centos www]$  tree /var/lib/influxdb/
/var/lib/influxdb/
├── data
│   └── _internal
│       ├── monitor
│       │   └── 1
│       │       └── fields.idx
│       └── _series
│           ├── 00
│           │   └── 0000
│           ├── 01
│           │   └── 0000
│           ├── 02
│           │   └── 0000
│           ├── 03
│           │   └── 0000
│           ├── 04
│           │   └── 0000
│           ├── 05
│           │   └── 0000
│           ├── 06
│           │   └── 0000
│           └── 07
│               └── 0000
├── meta
│   └── meta.db
└── wal
    └── _internal
        └── monitor
            └── 1
                └── _00001.wal

18 directories, 11 files

你可能感兴趣的:(InfluxDB)