redis集群搭建:解决gem install redis报错

在使用ruby脚本安装Redis集群时,需要先安装Ruby语言环境和redis插件,但是安装redis插件时遇到以下报错,下面记录一下解决过程。

因为执行Ruby脚本需要Ruby语言环境,所以首先安装Ruby语言环境和Ruby的包管理器Gems。

然后使用gem安装Redis和Ruby的接口。

RubyGems 是 Ruby 的一个包管理器,它提供一个分发 Ruby 程序和库的标准格式,还提供一个管理程序包安装的工具。

RubyGems 旨在方便地管理 gem 安装的工具,以及用于分发 gem 的服务器。这类似于 Ubuntu 下的apt-get, Centos 的 yum,Python 的 pip。
————————————————
版权声明:本文为CSDN博主「DBA之路」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_35209838/java/article/details/86307469

安装Ruby和Redis的接口时

报错

[root@localhost ruby-2.2.7]# gem install redis
ERROR:  Loading command: install (LoadError)
        cannot load such file -- zlib
ERROR:  While executing gem ... (NoMethodError)
    undefined method `invoke_with_build_args' for nil:NilClass

报错原因

缺少zlib库依赖

yum install zlib-devel

 集成zlib库到Ruby环境

[root@localhost ruby-2.2.7]# pwd
/root/ruby-2.2.7
[root@localhost ruby-2.2.7]# cd ext/zlib/
[root@localhost zlib]# ls
depend  extconf.rb  Makefile  mkmf.log  zlib.c
[root@localhost zlib]# ruby extconf.rb 
checking for deflateReset() in -lz... yes
checking for zlib.h... yes
checking for crc32_combine() in zlib.h... yes
checking for adler32_combine() in zlib.h... yes
checking for z_crc_t in zlib.h... yes
creating Makefile
[root@localhost zlib]# make
compiling zlib.c
linking shared-object zlib.so
[root@localhost zlib]# 
[root@localhost zlib]# make install
/usr/bin/install -c -m 0755 zlib.so /usr/local/ruby-2.2.7/lib/ruby/site_ruby/2.2.0/x86_64-linux
[root@localhost zlib]# 

缺少openssl库

报错信息

[root@localhost zlib]# gem install redis
ERROR:  While executing gem ... (Gem::Exception)
    Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources

使用yum安全openssl库,不能用yum install openssl,在ruby extconf.rb时会提示找不到ssl.h文件

[root@localhost zlib]# yum install openssl-devel

执行以下操作

 1 /root/ruby-2.2.7/ext/openssl
 2 [root@localhost openssl]# ruby extconf.rb
 3 checking for t_open() in -lnsl... no
 4 checking for socket() in -lsocket... no
 5 checking for assert.h... yes
 6 checking for openssl/ssl.h... yes
 7 checking for openssl/conf_api.h... yes
 8 checking for SSL_library_init() in openssl/ssl.h with -Werror=deprecated-declarations... yes
 9 checking for openssl/ssl.h... yes
10 checking for ERR_peek_last_error()... yes
11 checking for ASN1_put_eoc()... yes
12 checking for BN_mod_add()... yes
13 checking for BN_mod_sqr()... yes
14 checking for BN_mod_sub()... yes
15 checking for BN_pseudo_rand_range()... yes
16 checking for BN_rand_range()... yes
17 checking for CONF_get1_default_config_file()... yes
18 checking for EVP_CIPHER_CTX_copy()... yes
19 checking for EVP_CIPHER_CTX_set_padding()... yes
20 checking for EVP_CipherFinal_ex()... yes
21 checking for EVP_CipherInit_ex()... yes
22 checking for EVP_DigestFinal_ex()... yes
23 checking for EVP_DigestInit_ex()... yes
24 checking for EVP_MD_CTX_cleanup()... yes
25 checking for EVP_MD_CTX_create()... yes
26 checking for EVP_MD_CTX_destroy()... yes
27 checking for EVP_MD_CTX_init()... yes
28 checking for HMAC_CTX_cleanup()... yes
29 checking for HMAC_CTX_copy()... yes
30 checking for HMAC_CTX_init()... yes
31 checking for PEM_def_callback()... yes
32 checking for PKCS5_PBKDF2_HMAC()... yes
33 checking for PKCS5_PBKDF2_HMAC_SHA1()... yes
34 checking for RAND_egd()... yes
35 checking for X509V3_set_nconf()... yes
36 checking for X509V3_EXT_nconf_nid()... yes
37 checking for X509_CRL_add0_revoked()... yes
38 checking for X509_CRL_set_issuer_name()... yes
39 checking for X509_CRL_set_version()... yes
40 checking for X509_CRL_sort()... yes
41 checking for X509_NAME_hash_old()... yes
42 checking for X509_STORE_get_ex_data()... no
43 checking for X509_STORE_set_ex_data()... no
44 checking for OBJ_NAME_do_all_sorted()... yes
45 checking for SSL_SESSION_get_id()... yes
46 checking for SSL_SESSION_cmp()... no
47 checking for OPENSSL_cleanse()... yes
48 checking for SSLv2_method()... yes
49 checking for SSLv2_server_method()... yes
50 checking for SSLv2_client_method()... yes
51 checking for SSLv3_method()... yes
52 checking for SSLv3_server_method()... yes
53 checking for SSLv3_client_method()... yes
54 checking for TLSv1_1_method()... yes
55 checking for TLSv1_1_server_method()... yes
56 checking for TLSv1_1_client_method()... yes
57 checking for TLSv1_2_method()... yes
58 checking for TLSv1_2_server_method()... yes
59 checking for TLSv1_2_client_method()... yes
60 checking for SSL_CTX_set_next_proto_select_cb()... yes
61 checking for SSL_set_tlsext_host_name() in openssl/ssl.h... no
62 checking for SSL_set_tlsext_host_name in openssl/ssl.h... yes
63 checking for openssl/engine.h... yes
64 checking for ENGINE_add()... yes
65 checking for ENGINE_load_builtin_engines()... yes
66 checking for ENGINE_load_openbsd_dev_crypto()... no
67 checking for ENGINE_get_digest()... yes
68 checking for ENGINE_get_cipher()... yes
69 checking for ENGINE_cleanup()... yes
70 checking for ENGINE_load_dynamic()... yes
71 checking for ENGINE_load_4758cca()... no
72 checking for ENGINE_load_aep()... no
73 checking for ENGINE_load_atalla()... no
74 checking for ENGINE_load_chil()... no
75 checking for ENGINE_load_cswift()... no
76 checking for ENGINE_load_nuron()... no
77 checking for ENGINE_load_sureware()... no
78 checking for ENGINE_load_ubsec()... no
79 checking for ENGINE_load_padlock()... no
80 checking for ENGINE_load_capi()... no
81 checking for ENGINE_load_gmp()... no
82 checking for ENGINE_load_gost()... no
83 checking for ENGINE_load_cryptodev()... yes
84 checking for ENGINE_load_aesni()... yes
85 checking for DH_generate_parameters_ex()... yes
86 checking for DSA_generate_parameters_ex()... yes
87 checking for RSA_generate_key_ex()... yes
88 checking for OpenSSL version is 0.9.7 or later... yes
89 checking for openssl/ocsp.h... yes
90 checking for CRYPTO_THREADID.ptr in openssl/crypto.h... yes
91 checking for EVP_CIPHER_CTX.flags in openssl/evp.h... yes
92 checking for EVP_CIPHER_CTX.engine in openssl/evp.h... yes
93 checking for X509_ATTRIBUTE.single in openssl/x509.h... yes
94 checking for OPENSSL_FIPS in openssl/opensslconf.h... yes
95 checking for EVP_CTRL_GCM_GET_TAG in openssl/evp.h... yes
96 creating extconf.h
97 creating Makefile
View Code
cd /root/ruby-2.2.7/ext/openssl
[root@localhost openssl]# ruby extconf.rb
checking for t_open() in -lnsl... no
checking for socket() in -lsocket... no
checking for assert.h... yes
checking for openssl/ssl.h... yes
checking for openssl/conf_api.h... yes
checking for SSL_library_init() in openssl/ssl.h with -Werror=deprecated-declarations... yes
checking for openssl/ssl.h... yes
checking for ERR_peek_last_error()... yes
checking for ASN1_put_eoc()... yes
checking for BN_mod_add()... yes
checking for BN_mod_sqr()... yes
checking for BN_mod_sub()... yes
checking for BN_pseudo_rand_range()... yes
checking for BN_rand_range()... yes
checking for CONF_get1_default_config_file()... yes
checking for EVP_CIPHER_CTX_copy()... yes
checking for EVP_CIPHER_CTX_set_padding()... yes
checking for EVP_CipherFinal_ex()... yes
checking for EVP_CipherInit_ex()... yes
checking for EVP_DigestFinal_ex()... yes
checking for EVP_DigestInit_ex()... yes
checking for EVP_MD_CTX_cleanup()... yes
checking for EVP_MD_CTX_create()... yes
checking for EVP_MD_CTX_destroy()... yes
checking for EVP_MD_CTX_init()... yes
checking for HMAC_CTX_cleanup()... yes
checking for HMAC_CTX_copy()... yes
checking for HMAC_CTX_init()... yes
checking for PEM_def_callback()... yes
checking for PKCS5_PBKDF2_HMAC()... yes
checking for PKCS5_PBKDF2_HMAC_SHA1()... yes
checking for RAND_egd()... yes
checking for X509V3_set_nconf()... yes
checking for X509V3_EXT_nconf_nid()... yes
checking for X509_CRL_add0_revoked()... yes
checking for X509_CRL_set_issuer_name()... yes
checking for X509_CRL_set_version()... yes
checking for X509_CRL_sort()... yes
checking for X509_NAME_hash_old()... yes
checking for X509_STORE_get_ex_data()... no
checking for X509_STORE_set_ex_data()... no
checking for OBJ_NAME_do_all_sorted()... yes
checking for SSL_SESSION_get_id()... yes
checking for SSL_SESSION_cmp()... no
checking for OPENSSL_cleanse()... yes
checking for SSLv2_method()... yes
checking for SSLv2_server_method()... yes
checking for SSLv2_client_method()... yes
checking for SSLv3_method()... yes
checking for SSLv3_server_method()... yes
checking for SSLv3_client_method()... yes
checking for TLSv1_1_method()... yes
checking for TLSv1_1_server_method()... yes
checking for TLSv1_1_client_method()... yes
checking for TLSv1_2_method()... yes
checking for TLSv1_2_server_method()... yes
checking for TLSv1_2_client_method()... yes
checking for SSL_CTX_set_next_proto_select_cb()... yes
checking for SSL_set_tlsext_host_name() in openssl/ssl.h... no
checking for SSL_set_tlsext_host_name in openssl/ssl.h... yes
checking for openssl/engine.h... yes
checking for ENGINE_add()... yes
checking for ENGINE_load_builtin_engines()... yes
checking for ENGINE_load_openbsd_dev_crypto()... no
checking for ENGINE_get_digest()... yes
checking for ENGINE_get_cipher()... yes
checking for ENGINE_cleanup()... yes
checking for ENGINE_load_dynamic()... yes
checking for ENGINE_load_4758cca()... no
checking for ENGINE_load_aep()... no
checking for ENGINE_load_atalla()... no
checking for ENGINE_load_chil()... no
checking for ENGINE_load_cswift()... no
checking for ENGINE_load_nuron()... no
checking for ENGINE_load_sureware()... no
checking for ENGINE_load_ubsec()... no
checking for ENGINE_load_padlock()... no
checking for ENGINE_load_capi()... no
checking for ENGINE_load_gmp()... no
checking for ENGINE_load_gost()... no
checking for ENGINE_load_cryptodev()... yes
checking for ENGINE_load_aesni()... yes
checking for DH_generate_parameters_ex()... yes
checking for DSA_generate_parameters_ex()... yes
checking for RSA_generate_key_ex()... yes
checking for OpenSSL version is 0.9.7 or later... yes
checking for openssl/ocsp.h... yes
checking for CRYPTO_THREADID.ptr in openssl/crypto.h... yes
checking for EVP_CIPHER_CTX.flags in openssl/evp.h... yes
checking for EVP_CIPHER_CTX.engine in openssl/evp.h... yes
checking for X509_ATTRIBUTE.single in openssl/x509.h... yes
checking for OPENSSL_FIPS in openssl/opensslconf.h... yes
checking for EVP_CTRL_GCM_GET_TAG in openssl/evp.h... yes
creating extconf.h
creating Makefile

猜你喜欢

转载自www.cnblogs.com/shy-1208/p/12633969.html