> 本次为在
CentOS 7.x安装
redis-4.0.6`
1. 首先安装依赖包
yum install cpp -y
yum install binutils -y
yum install glibc-kernheaders -y
yum install glibc-common -y
yum install glibc-devel -y
yum install gcc -y
yum install make -y
2. 下载redis
- 创建下载目录
cd /usr/local
mkdir redis
cd redis
wget http://download.redis.io/releases/redis-4.0.6.tar.gz
如果提示找不到
wget
命令, 运行yum -y install wget
进行安装
3. 安装redis
- 解压缩
tar -zxvf redis-4.0.6.tar.gz
- 安装
cd redis-4.0.6
make
等待安装完毕
4. 配置
- 创建常用命令和配置存储目录
mkdir /usr/local/redis/conf
# 复制配置文件
cp redis.conf /usr/local/redis/conf
- 进入
src
目录把常用的命令文件复制到conf
文件夹下
cp redis-benchmark /usr/local/redis/conf
cp redis-check-aof /usr/local/redis/conf
cp redis-check-rdb /usr/local/redis/conf
cp redis-cli /usr/local/redis/conf
cp redis-sentinel /usr/local/redis/conf
cp redis-server /usr/local/redis/conf
- 下面是
conf
目录下的文件列表
[root@localhost redis]# cd conf/
[root@localhost conf]# ll
总用量 27492
-rwxr-xr-x. 1 root root 2451904 12月 17 15:43 redis-benchmark
-rwxr-xr-x. 1 root root 5753016 12月 17 15:44 redis-check-aof
-rwxr-xr-x. 1 root root 5753016 12月 17 15:44 redis-check-rdb
-rwxr-xr-x. 1 root root 2617048 12月 17 15:44 redis-cli
-rw-r--r--. 1 root root 57764 12月 17 15:47 redis.conf
-rwxr-xr-x. 1 root root 5753016 12月 17 15:45 redis-sentinel
-rwxr-xr-x. 1 root root 5753016 12月 17 15:45 redis-server
[root@localhost conf]#
- 配置
vim redis.conf
# 查询密码设置, 直接输入
/requirepass
# 按回车键进行查找, 按 n 键查询下一个位置
n
# 找到 requirepass, 按 i 键进入插入模式
i
# 如果是注释状态, 打开注释, 修改密码为 12345678
# 按 Esc 键退出插入模式
Esc
# 查询 bing
/bing
# 查询到 bing 127.0.0.1 修改为 bing 192.168.100.101, 本机ip
# 如果需要后台运行,查询 daemonize, 把 no 改为 yes 即可
# 按 Esc 退出插入模式, 输入 :wq 保存退出
:wq
# 不保存退出 qw!
5. 启动
# 启动
./redis-server redis.conf
# 客户端链接
./redis-cli -h 192.168.100.101 -p 6379 -a 12345678