有時需要離線安裝redis,所以需要redis離線安裝包,不同的centos版本和redis版本,依賴包不同,本例中,centos: CentOS Linux release 7.0.1406 (Core),Basic Web Server版本,自動下載的redis版本為3.2.12
1、檢查是否存在redis安裝包
yum search redis
2、若未找到redis安裝包,則安裝epel-release源
yum -y install epel-release
3、再次查詢倉庫中是否存在redis,若出現如下異常,則在/usr/lib/python2.7/site-packages/urlgrabber/grabber.py中1510行左右將elif errcode in (42, 55, 56) 改為elif errcode == 42 ,然后再次查詢
[root@localhost ~]# yum search redis Loaded plugins: fastestmirror, langpacks epel/x86_64/metalink | 6.9 kB 00:00:00 epel | 4.7 kB 00:00:00 epel/x86_64/primary_db FAILED https://mirror.lzu.edu.cn/epel/7/x86_64/repodata/d1d0107c74472c4a2af56fa4436caafe3c76a57c446b11b54901609d26893a17-primary.sqlite.bz2: [Errno 14] curl#35 - "Cannot communicate securely with peer: no common encryption algorithm(s)." Trying other mirror. Traceback (most recent call last): File "/usr/libexec/urlgrabber-ext-down", line 75, in <module> main() File "/usr/libexec/urlgrabber-ext-down", line 61, in main fo = PyCurlFileObject(opts.url, opts.filename, opts) File "/usr/lib/python2.7/site-packages/urlgrabber/grabber.py", line 1258, in __init__ self._do_open() File "/usr/lib/python2.7/site-packages/urlgrabber/grabber.py", line 1589, in _do_open self._do_grab() File "/usr/lib/python2.7/site-packages/urlgrabber/grabber.py", line 1723, in _do_grab self._do_perform() File "/usr/lib/python2.7/site-packages/urlgrabber/grabber.py", line 1517, in _do_perform raise KeyboardInterrupt KeyboardInterrupt
4、正常查詢,出現
redis.x86_64 : A persistent key-value database
則源安裝成功
5、下載安裝包
yum install --downloadonly --downloaddir=/work redis
出現
exiting because "Download Only" specified
下載結束,查看redis
[root@localhost ~]# whereis redis redis:[root@localhost ~]# ll /work/ total 660 -rw-r--r--. 1 root root 107040 Apr 2 2014 jemalloc-3.6.0-1.el7.x86_64.rpm -rw-r--r--. 1 root root 556969 Oct 26 15:10 redis-3.2.12-2.el7.x86_64.rpm [root@localhost ~]#
redis安裝包及依賴包下載完成,並且沒有安裝
6、安裝
rpm -ivh /work/*
安裝結束后,查看redis安裝情況
[root@localhost ~]# whereis redis redis: /etc/redis.conf
7、啟動redis(開機啟動文件在redis安裝完成后,自動放入/usr/lib/systemd/system/中)
systemctl start redis
/usr/lib/systemd/system/redis.service
[Unit] Description=Redis persistent key-value database After=network.target After=network-online.target Wants=network-online.target [Service] ExecStart=/usr/bin/redis-server /etc/redis.conf --supervised systemd ExecStop=/usr/libexec/redis-shutdown Type=notify User=redis Group=redis RuntimeDirectory=redis RuntimeDirectoryMode=0755 [Install] WantedBy=multi-user.target
8、登錄
[root@localhost ~]# redis-cli 127.0.0.1:6379>
這種方式看似方便,但redis官方不推薦這種方式來安裝redis,因為這種方式安裝的redis不是當前最新的可用版本。當前穩定版本是5.0.4,但目前通過yum下載到的版本是3.2.12.