fluent-plugin-sql
fluent-plugin-sql copied to clipboard
Could not load 'active_record/connection_adapters/mysql2_adapter'.
Dockerfile:
FROM fluent/fluentd:v1.4-1
# Use root account to use apk
USER root
# below RUN includes plugin as examples elasticsearch is not required
# you may customize including plugins as you wish
RUN apk add --no-cache --update --virtual .build-deps sudo build-base ruby-dev mysql-dev \
&& sudo gem install fluent-plugin-elasticsearch fluent-plugin-sql \
&& fluent-gem install mysql2 --no-document \
&& sudo gem sources --clear-all \
&& apk del .build-deps \
&& rm -rf /home/fluent/.gem/ruby/2.5.0/cache/*.gem
USER fluent
error:
Could not load 'active_record/connection_adapters/mysql2_adapter'. Make sure that the adapter in config/database.yml is valid. If you use an adapter other than 'mysql', 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem to the Gemfile.
mysql2 version is mysql2-0.5.2
I have a similar issue, but with the pg adapter.
EDIT Actually, my issue was that I removed libpq-dev
(I am using a docker setup).
Sorry, I missed this issue.
&& sudo gem install fluent-plugin-elasticsearch fluent-plugin-sql
&& fluent-gem install mysql2 --no-document \
How about sudo gem install fluent-plugin-elasticsearch fluent-plugin-sql mysql2
?
@repeatedly I'm getting a different error now:
Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord)
@repeatedly I've tried your suggestion as well, with the same result.
And my Dockerfile
:
FROM fluent/fluentd:v1.4-debian-onbuild-1
USER root
RUN BUILD_DEPS="sudo make gcc g++ libc-dev ruby-dev" \
&& apt-get update \
&& apt-get install -y --no-install-recommends $BUILD_DEPS \
&& apt-get install -y libpq-dev \
&& sudo gem install fluent-plugin-sql pg --no-document \
&& sudo gem sources --clear-all \
&& SUDO_FORCE_REMOVE=yes \
apt-get purge -y --auto-remove \
-o APT::AutoRemove::RecommendsImportant=false \
$BUILD_DEPS \
&& rm -rf /var/lib/apt/lists/* \
/home/fluent/.gem/ruby/2.3.0/cache/*.gem
USER fluent
UPDATE:
The following Dockerfile
works for me now:
FROM fluent/fluentd:v1.4-debian-onbuild-1
USER root
RUN BUILD_DEPS="sudo make gcc g++ libc-dev ruby-dev" \
&& apt-get update \
&& apt-get install -y --no-install-recommends $BUILD_DEPS \
&& apt-get install -y libpq-dev \
&& sudo gem install fluent-plugin-sql pg \
&& fluent-gem install pg -v 0.21.0 --no-document \
&& sudo gem sources --clear-all \
&& SUDO_FORCE_REMOVE=yes \
apt-get purge -y --auto-remove \
-o APT::AutoRemove::RecommendsImportant=false \
$BUILD_DEPS \
&& rm -rf /var/lib/apt/lists/* \
/home/fluent/.gem/ruby/2.3.0/cache/*.gem
USER fluent
Note that you need the fluent.conf
file and plugins
folder to be at the same level as your dockerfile.