1. 程式人生 > >centos 7下安裝 redis

centos 7下安裝 redis

[[email protected] local]# wget http://download.redis.io/releases/redis-4.0.6.tar.gz
--2017-12-13 12:35:12--  http://download.redis.io/releases/redis-4.0.6.tar.gz
Resolving download.redis.io (download.redis.io)... 109.74.203.151
Connecting to download.redis.io (download.redis.io)|109.74.203.151|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1723533 (1.6M) [application/x-gzip]
Saving to: ‘redis-4.0.6.tar.gz’
 
100%[==========================================================================================================>] 1,723,533    608KB/s   in 2.8s  
 
2017-12-13 12:35:15 (608 KB/s) - ‘redis-4.0.6.tar.gz’ saved [1723533/1723533]

第二步:解壓壓縮包
tar -zxvf redis-4.0.6.tar.gz

[[email protected] local]# tar -zxvf redis-4.0.6.tar.gz

第三步:yum安裝gcc依賴

yum install gcc

[[email protected] local]# yum install gcc  
遇到選擇,輸入y即可<br><br><br>

第四步:跳轉到redis解壓目錄下
cd redis-4.0.6

[[email protected] local]# cd redis-4.0.6

第五步:編譯安裝

make MALLOC=libc

[[email protected] redis-4.0.6]# make MALLOC=libc

將/usr/local/redis-4.0.6/src目錄下的檔案加到/usr/local/bin目錄

cd src && make install

[[email protected] redis-4.0.6]# cd src && make install
    CC Makefile.dep
 
Hint: It's a good idea to run 'make test' ;)
 
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install

第六步:測試是否安裝成功

先切換到redis src目錄下

[[email protected] redis-4.0.6]# cd src

1、直接啟動redis

./redis-server

[[email protected] src]# ./redis-server
18685:C 13 Dec 12:56:12.507 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
18685:C 13 Dec 12:56:12.507 # Redis version=4.0.6, bits=64, commit=00000000, modified=0, pid=18685, just started
18685:C 13 Dec 12:56:12.507 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
                _._                                                 
           _.-``__ ''-._                                            
      _.-``    `.  `_.  ''-._           Redis 4.0.6 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                  
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 18685
  `-._    `-._  `-./  _.-'    _.-'                                  
 |`-._`-._    `-.__.-'    _.-'_.-'|                                 
 |    `-._`-._        _.-'_.-'    |           http://redis.io       
  `-._    `-._`-.__.-'_.-'    _.-'                                  
 |`-._`-._    `-.__.-'    _.-'_.-'|                                 
 |    `-._`-._        _.-'_.-'    |                                 
  `-._    `-._`-.__.-'_.-'    _.-'                                  
      `-._    `-.__.-'    _.-'                                      
          `-._        _.-'                                          
              `-.__.-'                                              
 
18685:M 13 Dec 12:56:12.508 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
18685:M 13 Dec 12:56:12.508 # Server initialized
18685:M 13 Dec 12:56:12.508 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
18685:M 13 Dec 12:56:12.508 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
18685:M 13 Dec 12:56:12.508 * Ready to accept connections  

如上圖:redis啟動成功,但是這種啟動方式需要一直開啟視窗,不能進行其他操作,不太方便。

按 ctrl + c可以關閉視窗。

2、以後臺程序方式啟動redis

第一步:修改redis.conf檔案

daemonize no  

修改為

	
daemonize yes

第二步:指定redis.conf檔案啟動

./redis-server /usr/local/redis-4.0.6/redis.conf

[[email protected] src]# ./redis-server /usr/local/redis-4.0.6/redis.conf
18713:C 13 Dec 13:07:41.109 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
18713:C 13 Dec 13:07:41.109 # Redis version=4.0.6, bits=64, commit=00000000, modified=0, pid=18713, just started
18713:C 13 Dec 13:07:41.109 # Configuration loaded

第三步:關閉redis程序

首先使用ps -aux | grep redis檢視redis程序

[[email protected] src]# ps -aux | grep redis
root     18714  0.0  0.1 141752  2008 ?        Ssl  13:07   0:00 ./redis-server 127.0.0.1:6379
root     18719  0.0  0.0 112644   968 pts/0    R+   13:09   0:00 grep --color=auto redis

使用kill命令殺死程序

[[email protected] src]# kill -9 18714

第七步:設定redis開機自啟動

1、在/etc目錄下新建redis目錄

mkdir redis

[[email protected] etc]# mkdir redis

2、將/usr/local/redis-4.0.6/redis.conf 檔案複製一份到/etc/redis目錄下,並命名為6379.conf

[[email protected] init.d]# cp /usr/local/redis-4.0.6/utils/redis_init_script /etc/init.d/redisd

4、設定redis開機自啟動

先切換到/etc/init.d目錄下

然後執行自啟命令

[[email protected] init.d]# chkconfig redisd on
service redisd does not support chkconfig 

看結果是redisd不支援chkconfig

解決方法
使用vim編輯redisd檔案,在第一行加入如下兩行註釋,儲存退出

# chkconfig:   2345 90 10
# description:  Redis is a persistent key-value database

再次執行開機自啟命令,成功

[[email protected] init.d]# chkconfig redisd on

再次執行開機自啟命令,成功

[[email protected] init.d]# chkconfig redisd on

現在可以直接已服務的形式啟動和關閉redis了

啟動:

service redisd start

[[email protected] ~]# service redisd start
Starting Redis server...
2288:C 13 Dec 13:51:38.087 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
2288:C 13 Dec 13:51:38.087 # Redis version=4.0.6, bits=64, commit=00000000, modified=0, pid=2288, just started
2288:C 13 Dec 13:51:38.087 # Configuration loaded

關閉:

service redisd stop

[[email protected] ~]# service redisd stop
Stopping ...
Redis stopped

參考資料:

如果出現如下問題:

[[email protected] ~]# service redisd start
/var/run/redis_6379.pid exists, process is already running or crashed 

Redis服務停止報錯解決方案[NOAUTH Authentication required]
Redis伺服器設定密碼後,使用service redis stop 會出現以下資訊:

service redis stop
Stopping …
OK
(error) NOAUTH Authentication required.
Waiting for Redis to shutdown …
Waiting for Redis to shutdown …
Waiting for Redis to shutdown …
Waiting for Redis to shutdown …
Waiting for Redis to shutdown …
Waiting for Redis to shutdown …
Waiting for Redis to shutdown …
Waiting for Redis to shutdown …

出現這樣的錯誤資訊,redis 這時是沒有停止服務的。
可以使用ps -ef | grep redis 查程序號 然後kill 掉,如果在deamon下還需要去刪除pid檔案,有點繁瑣。

解決辦法:

用redis-cli 密碼登陸(redis-cli -a password)就OK了。

再用ps -ef | grep redis 可以看到redis程序已經正常退出。

修改redis服務指令碼,加入如下所示的紅色授權資訊即可:

vi /etc/init.d/redis
$CLIEXEC -a “password” -p $REDISPORT shutdown

相關推薦

CentOS 7安裝redis 4.0.6

安裝redis 第一步:下載redis安裝包 wget http://download.redis.io/releases/redis-4.0.6.tar.gz 第二步:解壓壓縮包 tar -zxvf redis-4.0.6.tar.gz 第三步:yum安裝gcc依賴

Linux安裝配置Redis CentOS 7 安裝Redis

Redis是一個高效能的,開源key-value型資料庫。是構建高效能,可擴充套件的Web應用的完美解決方案,可以記憶體儲存亦可持久化儲存。因為要使用跨程序,跨服務級別的資料快取,在對比多個方案後,決定使用Redis。順便整理下Redis的安裝過程,以便查閱。

centos 7安裝 redis

[[email protected] local]# wget http://download.redis.io/releases/redis-4.0.6.tar.gz --2017-12-13 12:35:12-- http://download

linux環境centos 7安裝redis(4.0.11版本)

以下是我安裝redis的筆記: 首先進入到linux環境需要安裝redis的目錄,我的是/etc/local/hxq 然後 wget http://download.redis.io/releases/redis-4.0.11.tar.gz 解壓到當前目錄:tar -z

CentOS 7安裝使用Github

git push 文件 rep ica not 使用 管理系統 非root oba 在虛擬機安裝了QT以後,想把工程代碼放在版本管理系統軟件裏面,免得一遍遍創建checkpoint麻煩的要死。又因為虛擬機跟物理機數據很難交互,只好借助github了。搜了搜安裝配置方法,記錄

centos 7 安裝Matplotlib

matplotlib[[email protected]/* */ bin]# [[email protected]/* */ bin]# [[email protected]/* */ bin]# [[email protected]/* */ bin]# p

【轉】CentOS 7.0 安裝Redis 3.2.1詳細過程和使用常見問題

nec count ges des useful 內存 warning before outside http://www.linuxidc.com/Linux/2016-09/135071.htm 環境:CentOS 7.0 Redis 3.2.1 Redis的安裝與啟動

CentOS 7 安裝 Nginx

表達 dev 默認 tro 二次 編譯 stc style idc CentOS 7 下安裝 Nginx [日期:2016-09-05] 來源:Linux社區 作者:mafly [字體:大 中 小] 轉載:http://www.linu

Centos 7 安裝 samba 服務

創建 oba art man rect 匿名訪問 登陸 sys 工作站 yum install samba 配置文件在:/etc/samba/smb.conf [global] #添加下面這句 map to guest = Bad User #這個選項是保證匿名

CentOS 7安裝部署Zabbix3.4

zabbix zabbix3.4 centos7 Zabbix安裝: 環境: 系統環境:CentOS 7Zabbix版本:Zabbix 3.4 安裝步驟: 關閉防火墻和SELINUXsystemctl stop firewalld && setenforce 0 安裝zabb

Centos 7 安裝強大的視頻播放器Smplayer

mplayer sha lease 如果 是否 mpeg yum 因此 .com Centos雖然 默認帶有視頻播放器,但特別垃圾,幾乎所有格式的視頻都不能打開,也下載不了解碼庫,因此為你的電腦安裝一個強大的視頻播放器顯得有為重要,這裏推薦的是Smplayer 第一步 :

CentOS 7安裝Python3.6.4

編譯 python str CA 目錄 wget gdbm grep www. CentOS 7下安裝Python3.6.4 •安裝python3.6可能使用的依賴 yum install -y openssl-devel bzip2-devel expat-

Centos 7安裝Docker並采用加速器進行鏡像下載加速

docker 安裝 docker拉取鏡像慢 系統版本:[root@c720120 _data]# cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core) 在Centos 7上安裝Docker$sudo yum u pdate$sudo

centos 7安裝pycharm專業版

targe ofo get 添加 count host blank target har 1.下載pycharm的linux版本的軟件包,下載地址: http://www.jetbrains.com/pycharm/download/#section=linux 2.解壓

Centos 7安裝Oracle 12c 以及裝後優化(附軟件包)

strong 當前 unix kernel immediate .so 大數 相等 圖形化 Oracle 12c 數據庫概述 ORACLE數據庫系統是美國ORACLE公司(甲骨文)提供的以分布式數據庫為核心的一組軟件產品,是目前最流行的客戶/服務器(CLIENT/SERV

centos 7安裝tomcat

準備工作,啟動centos 7 並且使用xshell 連線好centos7 1、在網上查詢到tomcat,點選右鍵複製連線,如圖所示: 2、在urs目錄下下載tomcat,命令為: wget  http://mirrors.hust.edu.cn/apache

CentOS 7安裝Python3.6

•安裝python3.6可能使用的依賴 yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel   •到python官網找到下載路徑, 用wget下載 wget http

Centos 7.5安裝 Redis 5.0.0

1 我的環境  1.1 linux(騰訊雲) CentOS Linux release 7.5.1804 (Core)  1.2 Redis Redis 5.0.0 2 下載 官網 官網下載地址 3 上傳  3.1 使用xftp上傳到指定目錄,我的目錄

CentOS 7安裝nexus 3

安裝nexus 3的幾個注意事項: 1、nexus 3和nexus 2不一樣,nexus 2可以搜尋Maven主倉庫的包,但在nexus 3不能,只能搜尋快取過的包。 2、安裝時關心的點在於執行環境,倉庫地址修改,執行使用者,JVM引數 下面是安裝步驟: 1、執行環境為Java 8,很多網上說要Mav

簡單記錄在centos 7安裝docker的過程

首先是要刪除舊版本的docker,使用以下命令: $ sudo yum remove docker \ docker-client \ docker-client-latest \ doc