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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM