Redis安装

本文详细介绍在Linux环境下安装和配置Redis数据库的过程,包括依赖库的安装、Redis源码编译、环境变量设置、服务化配置及启动操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.安装gcc tcl

sudo yum -y install gcc tcl

 

2. 解压redis包,解压后的目录如下:

3. 到deps目录下编译 jemalloc,lua,linenoise,hiredis

make jemalloc lua linenoise hiredis

4.到redis的根目录下执行make

5.安装到指定位置:

make PREFIX=/opt/cdh5.15.0/redis install

 

6. redis目录:

7.设置环境变量:

export REDIS_HOME=/opt/cdh5.15.0/redis
export PATH=$PATH:$REDIS_HOME/bin

别忘了还要:

source /etc/profile

8. 将redis改为service:

切换为root用户,到目录/opt/cdh5.15.0/redis-2.8.18/utils目录下:

 执行:

./install_server.sh
[root@slave2 utils]# ./install_server.sh 
Welcome to the redis service installer
This script will help you easily set up a running redis server

Please select the redis port for this instance: [6379] 
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf] 
Selected default - /etc/redis/6379.conf
Please select the redis log file name [/var/log/redis_6379.log] 
Selected default - /var/log/redis_6379.log
Please select the data directory for this instance [/var/lib/redis/6379] 
Selected default - /var/lib/redis/6379
Please select the redis executable path [/opt/cdh5.15.0/redis/bin/redis-server] 
Selected config:
Port           : 6379
Config file    : /etc/redis/6379.conf
Log file       : /var/log/redis_6379.log
Data dir       : /var/lib/redis/6379
Executable     : /opt/cdh5.15.0/redis/bin/redis-server
Cli Executable : /opt/cdh5.15.0/redis/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
Starting Redis server...
Installation successful!

 9.进入/etc/init.d目录下:

[root@slave2 utils]# cd /etc/init.d/
[root@slave2 init.d]# ll
total 44
-rw-r--r--. 1 root root 17500 May  3  2017 functions
-rwxr-xr-x. 1 root root  4334 May  3  2017 netconsole
-rwxr-xr-x. 1 root root  7293 May  3  2017 network
-rw-r--r--. 1 root root  1160 Aug  5  2017 README
-rwxr-xr-x  1 root root  1698 Nov  3 16:47 redis_6379

将redis_6379改为redisd

设置开机启动服务:

systemctl enable redisd

启动并查看:

[root@slave2 init.d]# chkconfig redisd
[root@slave2 init.d]# service redisd start
/var/run/redis_6379.pid exists, process is already running or crashed
You have new mail in /var/spool/mail/root
[root@slave2 init.d]# ss -tanl
State      Recv-Q Send-Q               Local Address:Port                              Peer Address:Port              
LISTEN     0      128                              *:6379                                         *:*                  
LISTEN     0      128                              *:22                                           *:*                  
LISTEN     0      100                      127.0.0.1:25                                           *:*                  
LISTEN     0      128                             :::6379                                        :::*                  
LISTEN     0      128                             :::22                                          :::*                  
LISTEN     0      100                            ::1:25                                          :::*

 10.启动client:

[root@slave2 init.d]# redis-cli 
127.0.0.1:6379> 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值