0

请在下面找到操作系统详细信息

VERSION="2017.03"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2017.03"
PRETTY_NAME="Amazon Linux AMI 2017.03"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2017.03:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"

我参考了以下参考并尝试了,但它不起作用

  1. https://github.com/Blizzard/node-rdkafka/issues/263
  2. https://github.com/ibm-messaging/event-streams-samples/blob/master/kafka-nodejs-console-sample/Dockerfile
  3. https://github.com/Blizzard/node-rdkafka/blob/master/examples/docker-alpine.md

我跑了下面的命令

yum install gcc-c++ python-devel.x86_64 cyrus-sasl-devel.x86_64 ca-certificates

npm install node-rdkafka-- 在输出下方查找

 >npm install node-rdkafka
(node:4869) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.

> node-rdkafka@2.7.4 install /www/lrs/node_modules/node-rdkafka
> node-gyp rebuild

gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/6.11.2"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/www/lrs/node_modules/node-rdkafka/.node-gyp"
make: Entering directory `/www/lrs/node_modules/node-rdkafka/build'
  ACTION deps_librdkafka_gyp_librdkafka_target_configure deps/librdkafka/config.h
checking for OS or distribution... ok (amzn)
checking for C compiler from CC env... failed
checking for gcc (by command)... ok
checking for C++ compiler from CXX env... failed
checking for C++ compiler (g++)... ok
checking executable ld... ok
checking executable nm... ok
checking executable objdump... ok
checking executable strip... ok
checking for pkgconfig (by command)... ok
checking for install (by command)... ok
checking for PIC (by compile)... ok
checking for GNU-compatible linker options... ok
checking for GNU linker-script ld flag... ok
checking for __atomic_32 (by compile)... ok
checking for __atomic_64 (by compile)... ok
checking for socket (by compile)... ok
parsing version '0x010202ff'... ok (1.2.2)
checking for librt (by pkg-config)... failed
checking for librt (by compile)... ok
checking for libpthread (by pkg-config)... failed
checking for libpthread (by compile)... ok
checking for c11threads (by pkg-config)... failed
checking for c11threads (by compile)... failed (disable)
checking for libdl (by pkg-config)... failed
checking for libdl (by compile)... ok
checking for zlib (by pkg-config)... ok
checking for libcrypto (by pkg-config)... ok
checking for libssl (by pkg-config)... ok
checking for libsasl2 (by pkg-config)... failed
checking for libsasl2 (by compile)... ok
checking for libzstd (by pkg-config)... failed
checking for libzstd (by compile)... failed (disable)
checking for libm (by pkg-config)... failed
checking for libm (by compile)... ok
checking for liblz4 (by pkg-config)... failed
checking for liblz4 (by compile)... failed (disable)
checking for rapidjson (by compile)... failed (disable)
checking for crc32chw (by compile)... ok
checking for regex (by compile)... ok
checking for strndup (by compile)... ok
checking for strlcpy (by compile)... failed (disable)
checking for strerror_r (by compile)... ok
checking for pthread_setname_gnu (by compile)... ok
checking for nm (by env NM)... ok (cached)
checking for python (by command)... ok
checking for getrusage (by compile)... ok
Generated Makefile.config
Generated config.h

Configuration summary:
  prefix                   /www/lrs/node_modules/node-rdkafka/build/deps
  MKL_DISTRO               amzn
  SOLIB_EXT                .so
  ARCH                     x86_64
  CPU                      generic
  GEN_PKG_CONFIG           y
  ENABLE_ZSTD              y
  ENABLE_SSL               y
  ENABLE_GSSAPI            y
  ENABLE_DEVEL             n
  ENABLE_VALGRIND          n
  ENABLE_REFCNT_DEBUG      n
  ENABLE_SHAREDPTR_DEBUG   n
  ENABLE_LZ4_EXT           y
  ENABLE_C11THREADS        y
  libdir                   /www/lrs/node_modules/node-rdkafka/build/deps
  MKL_APP_NAME             librdkafka
  MKL_APP_DESC_ONELINE     The Apache Kafka C/C++ library
  LDFLAGS                  -L/www/lrs/node_modules/node-rdkafka/build/deps
  CC                       gcc
  CXX                      g++
  LD                       ld
  NM                       nm
  OBJDUMP                  objdump
  STRIP                    strip
  CPPFLAGS                 -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align
  PKG_CONFIG               pkg-config
  INSTALL                  install
  LIB_LDFLAGS              -shared -Wl,-soname,$(LIBFILENAME)
  LDFLAG_LINKERSCRIPT      -Wl,--version-script=
  RDKAFKA_VERSION_STR      1.2.2
  MKL_APP_VERSION          1.2.2
  LIBS                     -lm -lsasl2 -lssl -lcrypto   -lcrypto   -lz   -ldl -lpthread -lrt
  CFLAGS                        
  CXXFLAGS                 -Wno-non-virtual-dtor
  SYMDUMPER                $(NM) -D
  exec_prefix              /www/lrs/node_modules/node-rdkafka/build/deps
  bindir                   /www/lrs/node_modules/node-rdkafka/build/deps/bin
  sbindir                  /www/lrs/node_modules/node-rdkafka/build/deps/sbin
  libexecdir               /www/lrs/node_modules/node-rdkafka/build/deps/libexec
  datadir                  /www/lrs/node_modules/node-rdkafka/build/deps/share
  sysconfdir               /www/lrs/node_modules/node-rdkafka/build/deps/etc
  sharedstatedir           /www/lrs/node_modules/node-rdkafka/build/deps/com
  localstatedir            /www/lrs/node_modules/node-rdkafka/build/deps/var
  runstatedir              /www/lrs/node_modules/node-rdkafka/build/deps/var/run
  includedir               /www/lrs/node_modules/node-rdkafka/build/deps/include
  infodir                  /www/lrs/node_modules/node-rdkafka/build/deps/info
  mandir                   /www/lrs/node_modules/node-rdkafka/build/deps/man
  BUILT_WITH               GCC GXX PKGCONFIG INSTALL GNULD LDS LIBDL PLUGINS ZLIB SSL SASL_CYRUS HDRHISTOGRAM SNAPPY SOCKEM SASL_SCRAM SASL_OAUTHBEARER CRC32C_HW
Generated config.cache

Now type 'make' to build
  TOUCH deps_librdkafka_gyp_librdkafka_target_build_dependencies.intermediate
  ACTION deps_librdkafka_gyp_librdkafka_target_build_dependencies deps_librdkafka_gyp_librdkafka_target_build_dependencies.intermediate
make[1]: Entering directory `/www/lrs/node_modules/node-rdkafka/deps/librdkafka'
make[2]: Entering directory `/www/lrs/node_modules/node-rdkafka/deps/librdkafka/src'
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka.c -o rdkafka.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_broker.c -o rdkafka_broker.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_msg.c -o rdkafka_msg.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_topic.c -o rdkafka_topic.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_conf.c -o rdkafka_conf.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_timer.c -o rdkafka_timer.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_offset.c -o rdkafka_offset.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_transport.c -o rdkafka_transport.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_buf.c -o rdkafka_buf.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_queue.c -o rdkafka_queue.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_op.c -o rdkafka_op.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_request.c -o rdkafka_request.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_cgrp.c -o rdkafka_cgrp.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_pattern.c -o rdkafka_pattern.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_partition.c -o rdkafka_partition.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_subscription.c -o rdkafka_subscription.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_assignor.c -o rdkafka_assignor.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_range_assignor.c -o rdkafka_range_assignor.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_roundrobin_assignor.c -o rdkafka_roundrobin_assignor.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_feature.c -o rdkafka_feature.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdcrc32.c -o rdcrc32.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c crc32c.c -o crc32c.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdmurmur2.c -o rdmurmur2.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdaddr.c -o rdaddr.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdrand.c -o rdrand.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdlist.c -o rdlist.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c tinycthread.c -o tinycthread.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c tinycthread_extra.c -o tinycthread_extra.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdlog.c -o rdlog.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdstring.c -o rdstring.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_event.c -o rdkafka_event.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_metadata.c -o rdkafka_metadata.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdregex.c -o rdregex.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdports.c -o rdports.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_metadata_cache.c -o rdkafka_metadata_cache.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdavl.c -o rdavl.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_sasl.c -o rdkafka_sasl.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_sasl_plain.c -o rdkafka_sasl_plain.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_interceptor.c -o rdkafka_interceptor.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_msgset_writer.c -o rdkafka_msgset_writer.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_msgset_reader.c -o rdkafka_msgset_reader.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_header.c -o rdkafka_header.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_admin.c -o rdkafka_admin.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_aux.c -o rdkafka_aux.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_background.c -o rdkafka_background.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_idempotence.c -o rdkafka_idempotence.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_cert.c -o rdkafka_cert.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdvarint.c -o rdvarint.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdbuf.c -o rdbuf.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdunittest.c -o rdunittest.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_sasl_cyrus.c -o rdkafka_sasl_cyrus.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_sasl_scram.c -o rdkafka_sasl_scram.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_sasl_oauthbearer.c -o rdkafka_sasl_oauthbearer.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c snappy.c -o snappy.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdgz.c -o rdgz.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdhdrhistogram.c -o rdhdrhistogram.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_ssl.c -o rdkafka_ssl.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_lz4.c -o rdkafka_lz4.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -O3 -c xxhash.c -o xxhash.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -O3 -c lz4.c -o lz4.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -O3 -c lz4frame.c -o lz4frame.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -O3 -c lz4hc.c -o lz4hc.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rddl.c -o rddl.o
gcc -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align  -c rdkafka_plugin.c -o rdkafka_plugin.o
Generating linker script librdkafka.lds from rdkafka.h
Creating shared library librdkafka.so.1
gcc -L/www/lrs/node_modules/node-rdkafka/build/deps -shared -Wl,-soname,librdkafka.so.1 -Wl,--version-script=librdkafka.lds rdkafka.o rdkafka_broker.o rdkafka_msg.o rdkafka_topic.o rdkafka_conf.o rdkafka_timer.o rdkafka_offset.o rdkafka_transport.o rdkafka_buf.o rdkafka_queue.o rdkafka_op.o rdkafka_request.o rdkafka_cgrp.o rdkafka_pattern.o rdkafka_partition.o rdkafka_subscription.o rdkafka_assignor.o rdkafka_range_assignor.o rdkafka_roundrobin_assignor.o rdkafka_feature.o rdcrc32.o crc32c.o rdmurmur2.o rdaddr.o rdrand.o rdlist.o tinycthread.o tinycthread_extra.o rdlog.o rdstring.o rdkafka_event.o rdkafka_metadata.o rdregex.o rdports.o rdkafka_metadata_cache.o rdavl.o rdkafka_sasl.o rdkafka_sasl_plain.o rdkafka_interceptor.o rdkafka_msgset_writer.o rdkafka_msgset_reader.o rdkafka_header.o rdkafka_admin.o rdkafka_aux.o rdkafka_background.o rdkafka_idempotence.o rdkafka_cert.o rdvarint.o rdbuf.o rdunittest.o rdkafka_sasl_cyrus.o rdkafka_sasl_scram.o rdkafka_sasl_oauthbearer.o snappy.o rdgz.o rdhdrhistogram.o rdkafka_ssl.o rdkafka_lz4.o xxhash.o lz4.o lz4frame.o lz4hc.o rddl.o rdkafka_plugin.o -o librdkafka.so.1 -lm -lsasl2 -lssl -lcrypto   -lcrypto   -lz   -ldl -lpthread -lrt
Creating static library librdkafka.a
ar rcs librdkafka.a rdkafka.o rdkafka_broker.o rdkafka_msg.o rdkafka_topic.o rdkafka_conf.o rdkafka_timer.o rdkafka_offset.o rdkafka_transport.o rdkafka_buf.o rdkafka_queue.o rdkafka_op.o rdkafka_request.o rdkafka_cgrp.o rdkafka_pattern.o rdkafka_partition.o rdkafka_subscription.o rdkafka_assignor.o rdkafka_range_assignor.o rdkafka_roundrobin_assignor.o rdkafka_feature.o rdcrc32.o crc32c.o rdmurmur2.o rdaddr.o rdrand.o rdlist.o tinycthread.o tinycthread_extra.o rdlog.o rdstring.o rdkafka_event.o rdkafka_metadata.o rdregex.o rdports.o rdkafka_metadata_cache.o rdavl.o rdkafka_sasl.o rdkafka_sasl_plain.o rdkafka_interceptor.o rdkafka_msgset_writer.o rdkafka_msgset_reader.o rdkafka_header.o rdkafka_admin.o rdkafka_aux.o rdkafka_background.o rdkafka_idempotence.o rdkafka_cert.o rdvarint.o rdbuf.o rdunittest.o rdkafka_sasl_cyrus.o rdkafka_sasl_scram.o rdkafka_sasl_oauthbearer.o snappy.o rdgz.o rdhdrhistogram.o rdkafka_ssl.o rdkafka_lz4.o xxhash.o lz4.o lz4frame.o lz4hc.o rddl.o rdkafka_plugin.o
Creating librdkafka.so symlink
rm -f "librdkafka.so" && ln -s "librdkafka.so.1" "librdkafka.so"
Generating pkg-config file rdkafka.pc
Generating pkg-config file rdkafka-static.pc
Checking librdkafka integrity
librdkafka.so.1                OK
librdkafka.a                   OK
Symbol visibility              OK
make[2]: Leaving directory `/www/lrs/node_modules/node-rdkafka/deps/librdkafka/src'
make[2]: Entering directory `/www/lrs/node_modules/node-rdkafka/deps/librdkafka/src-cpp'
g++ -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -c RdKafka.cpp -o RdKafka.o
g++ -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -c ConfImpl.cpp -o ConfImpl.o
g++ -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -c HandleImpl.cpp -o HandleImpl.o
g++ -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -c ConsumerImpl.cpp -o ConsumerImpl.o
g++ -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -c ProducerImpl.cpp -o ProducerImpl.o
g++ -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -c KafkaConsumerImpl.cpp -o KafkaConsumerImpl.o
g++ -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -c TopicImpl.cpp -o TopicImpl.o
g++ -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -c TopicPartitionImpl.cpp -o TopicPartitionImpl.o
g++ -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -c MessageImpl.cpp -o MessageImpl.o
g++ -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -c HeadersImpl.cpp -o HeadersImpl.o
g++ -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -c QueueImpl.cpp -o QueueImpl.o
g++ -MD -MP -g -O2 -fPIC -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -Wcast-align -Wno-non-virtual-dtor -c MetadataImpl.cpp -o MetadataImpl.o
Creating shared library librdkafka++.so.1
gcc -L/www/lrs/node_modules/node-rdkafka/build/deps -shared -Wl,-soname,librdkafka++.so.1 RdKafka.o ConfImpl.o HandleImpl.o ConsumerImpl.o ProducerImpl.o KafkaConsumerImpl.o TopicImpl.o TopicPartitionImpl.o MessageImpl.o HeadersImpl.o QueueImpl.o MetadataImpl.o -o librdkafka++.so.1 -L../src -lrdkafka -lstdc++
Creating static library librdkafka++.a
ar rcs librdkafka++.a RdKafka.o ConfImpl.o HandleImpl.o ConsumerImpl.o ProducerImpl.o KafkaConsumerImpl.o TopicImpl.o TopicPartitionImpl.o MessageImpl.o HeadersImpl.o QueueImpl.o MetadataImpl.o
Creating librdkafka++.so symlink
rm -f "librdkafka++.so" && ln -s "librdkafka++.so.1" "librdkafka++.so"
Generating pkg-config file rdkafka++.pc
Generating pkg-config file rdkafka++-static.pc
Checking librdkafka++ integrity
librdkafka++.so.1              OK
librdkafka++.a                 OK
make[2]: Leaving directory `/www/lrs/node_modules/node-rdkafka/deps/librdkafka/src-cpp'
make[2]: Entering directory `/www/lrs/node_modules/node-rdkafka/deps/librdkafka/src'
Install librdkafka to /www/lrs/node_modules/node-rdkafka/build/deps
install -d $DESTDIR/www/lrs/node_modules/node-rdkafka/build/deps/include/librdkafka && \
install -d $DESTDIR/www/lrs/node_modules/node-rdkafka/build/deps && \
install rdkafka.h $DESTDIR/www/lrs/node_modules/node-rdkafka/build/deps/include/librdkafka && \
install librdkafka.a $DESTDIR/www/lrs/node_modules/node-rdkafka/build/deps && \
install librdkafka.so.1 $DESTDIR/www/lrs/node_modules/node-rdkafka/build/deps && \
[ -f "rdkafka.pc" ] && ( \
    install -d $DESTDIR/www/lrs/node_modules/node-rdkafka/build/deps/pkgconfig && \
    install -m 0644 rdkafka.pc $DESTDIR/www/lrs/node_modules/node-rdkafka/build/deps/pkgconfig \
) && \
[ -f "rdkafka-static.pc" ] && ( \
    install -d $DESTDIR/www/lrs/node_modules/node-rdkafka/build/deps/pkgconfig && \
    install -m 0644 rdkafka-static.pc $DESTDIR/www/lrs/node_modules/node-rdkafka/build/deps/pkgconfig \
) && \
(cd $DESTDIR/www/lrs/node_modules/node-rdkafka/build/deps && ln -sf librdkafka.so.1 librdkafka.so)
make[2]: Leaving directory `/www/lrs/node_modules/node-rdkafka/deps/librdkafka/src'
make[2]: Entering directory `/www/lrs/node_modules/node-rdkafka/deps/librdkafka/src-cpp'
Install librdkafka++ to /www/lrs/node_modules/node-rdkafka/build/deps
install -d $DESTDIR/www/lrs/node_modules/node-rdkafka/build/deps/include/librdkafka && \
install -d $DESTDIR/www/lrs/node_modules/node-rdkafka/build/deps && \
install rdkafkacpp.h $DESTDIR/www/lrs/node_modules/node-rdkafka/build/deps/include/librdkafka && \
install librdkafka++.a $DESTDIR/www/lrs/node_modules/node-rdkafka/build/deps && \
install librdkafka++.so.1 $DESTDIR/www/lrs/node_modules/node-rdkafka/build/deps && \
[ -f "rdkafka++.pc" ] && ( \
    install -d $DESTDIR/www/lrs/node_modules/node-rdkafka/build/deps/pkgconfig && \
    install -m 0644 rdkafka++.pc $DESTDIR/www/lrs/node_modules/node-rdkafka/build/deps/pkgconfig \
) && \
[ -f "rdkafka++-static.pc" ] && ( \
    install -d $DESTDIR/www/lrs/node_modules/node-rdkafka/build/deps/pkgconfig && \
    install -m 0644 rdkafka++-static.pc $DESTDIR/www/lrs/node_modules/node-rdkafka/build/deps/pkgconfig \
) && \
(cd $DESTDIR/www/lrs/node_modules/node-rdkafka/build/deps && ln -sf librdkafka++.so.1 librdkafka++.so)
make[2]: Leaving directory `/www/lrs/node_modules/node-rdkafka/deps/librdkafka/src-cpp'
make[1]: Leaving directory `/www/lrs/node_modules/node-rdkafka/deps/librdkafka'
  TOUCH Release/obj.target/deps/librdkafka.stamp
  CXX(target) Release/obj.target/node-librdkafka/src/binding.o
  CXX(target) Release/obj.target/node-librdkafka/src/callbacks.o
../src/callbacks.cc: In member function ‘void NodeKafka::Callbacks::Dispatcher::Dispatch(int, v8::Local<v8::Value>*)’:
../src/callbacks.cc:103:25: warning: ‘v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const’ is deprecated (declared at ../node_modules/nan/nan.h:1740) [-Wdeprecated-declarations]
     cb.Call(_argc, _argv);
                         ^
../src/callbacks.cc: In member function ‘virtual int32_t NodeKafka::Callbacks::Partitioner::partitioner_cb(const RdKafka::Topic*, const string*, int32_t, void*)’:
../src/callbacks.cc:575:60: warning: ‘v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const’ is deprecated (declared at ../node_modules/nan/nan.h:1740) [-Wdeprecated-declarations]
   v8::Local<v8::Value> return_value = callback.Call(3, argv);
                                                            ^
../src/callbacks.cc: In member function ‘void NodeKafka::Callbacks::Partitioner::SetCallback(v8::Local<v8::Function>)’:
../src/callbacks.cc:612:14: warning: ‘v8::Local<v8::Value> Nan::Callback::operator()(v8::Local<v8::Object>, int, v8::Local<v8::Value>*) const’ is deprecated (declared at ../node_modules/nan/nan.h:1638) [-Wdeprecated-declarations]
   callback(cb);
              ^
  CXX(target) Release/obj.target/node-librdkafka/src/common.o
../src/common.cc: In function ‘rd_kafka_NewTopic_t* NodeKafka::Conversion::Admin::FromV8TopicObject(v8::Local<v8::Object>, std::string&)’:
../src/common.cc:537:31: warning: comparison between ‘enum rd_kafka_resp_err_t’ and ‘enum RdKafka::ErrorCode’ [-Wenum-compare]
           if (err != RdKafka::ERR_NO_ERROR) {
                               ^
  CXX(target) Release/obj.target/node-librdkafka/src/config.o
  CXX(target) Release/obj.target/node-librdkafka/src/connection.o
In file included from ../src/connection.cc:14:0:
/www/lrs/node_modules/node-rdkafka/src/workers.h: In member function ‘virtual void NodeKafka::Workers::ErrorAwareWorker::HandleErrorCallback()’:
/www/lrs/node_modules/node-rdkafka/src/workers.h:42:30: warning: ‘v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const’ is deprecated (declared at ../node_modules/nan/nan.h:1740) [-Wdeprecated-declarations]
     callback->Call(argc, argv);
                              ^
  CXX(target) Release/obj.target/node-librdkafka/src/errors.o
  CXX(target) Release/obj.target/node-librdkafka/src/kafka-consumer.o
In file included from ../src/kafka-consumer.cc:14:0:
/www/lrs/node_modules/node-rdkafka/src/workers.h: In member function ‘virtual void NodeKafka::Workers::ErrorAwareWorker::HandleErrorCallback()’:
/www/lrs/node_modules/node-rdkafka/src/workers.h:42:30: warning: ‘v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const’ is deprecated (declared at ../node_modules/nan/nan.h:1740) [-Wdeprecated-declarations]
     callback->Call(argc, argv);
                              ^
  CXX(target) Release/obj.target/node-librdkafka/src/producer.o
In file included from ../src/producer.cc:14:0:
/www/lrs/node_modules/node-rdkafka/src/workers.h: In member function ‘virtual void NodeKafka::Workers::ErrorAwareWorker::HandleErrorCallback()’:
/www/lrs/node_modules/node-rdkafka/src/workers.h:42:30: warning: ‘v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const’ is deprecated (declared at ../node_modules/nan/nan.h:1740) [-Wdeprecated-declarations]
     callback->Call(argc, argv);
                              ^
  CXX(target) Release/obj.target/node-librdkafka/src/topic.o
  CXX(target) Release/obj.target/node-librdkafka/src/workers.o
In file included from ../src/workers.cc:13:0:
/www/lrs/node_modules/node-rdkafka/src/workers.h: In member function ‘virtual void NodeKafka::Workers::ErrorAwareWorker::HandleErrorCallback()’:
/www/lrs/node_modules/node-rdkafka/src/workers.h:42:30: warning: ‘v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const’ is deprecated (declared at ../node_modules/nan/nan.h:1740) [-Wdeprecated-declarations]
     callback->Call(argc, argv);
                              ^
../src/workers.cc: In member function ‘virtual void NodeKafka::Workers::Handle::OffsetsForTimes::HandleOKCallback()’:
../src/workers.cc:69:28: warning: ‘v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const’ is deprecated (declared at ../node_modules/nan/nan.h:1740) [-Wdeprecated-declarations]
   callback->Call(argc, argv);

  SOLINK_MODULE(target) Release/obj.target/node-librdkafka.node
  COPY Release/node-librdkafka.node
rm deps_librdkafka_gyp_librdkafka_target_build_dependencies.intermediate
make: Leaving directory `/www/lrs/node_modules/node-rdkafka/build'
lrs@0.0.1 /www/lrs
`-- node-rdkafka@2.7.4 

找到我的测试代码

const Kafka = require('node-rdkafka');
const path = require('path');
console.log(Kafka.features);
var producer = new Kafka.Producer({
  'client.id': 'my-client', // Specifies an identifier to use to help trace activity in Kafka
  'metadata.broker.list': 'hosturl', // Connect to a Kafka instance on localhost
  'security.protocol': 'SSL',
  'ssl.key.password': 'pwd',
  'ssl.key.location': path.join(__dirname, '/config/service.key'),
  'ssl.certificate.location': path.join(__dirname, '/config/service.cert'),
  'ssl.ca.location': path.join(__dirname, '/config/ca.pem'),
  'socket.keepalive.enable': true,
});

producer.connect();
console.log(path.join(__dirname, '/config/kafka_service.key')) ;
// Poll for events every 100 ms
producer.setPollInterval(100);

producer.on('delivery-report', function(err, report) {
  // Report of delivery statistics here:
  //
  console.log(report);
});

producer.on("ready", function(err,res){
    producer.produce("pj_testnew", null, Buffer.from('alliance4ever'), null, Date.now(), (err, offset) => {
      // The offset if our acknowledgement level allows us to receive delivery offsets
      console.log(offset);
    })
})

找到以下错误,我得到

/www/lrs >node rdkafka.js 

    throw new Error('Producer not connected');
    ^

Error: Producer not connected
    at Producer.produce (/www/lrs/node_modules/node-rdkafka/lib/producer.js:125:11)
    at Object.<anonymous> (/www/lrs/rdkafka.js:25:10)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)


注意: 相同的代码适用于 Ubuntu 16。我们遵循以下步骤

Install dependencies
apt-get install -y --no-install-recommends build-essential node-gyp make ca-certificates

Install  node-rdkafka
          npm install node-rdkafka

4

0 回答 0