Redis学习笔记(一)—在centos7上搭建环境
1 环境
1.1 系统环境
- CentOS Linux release 7.5.1804 (Core)
1.2 依赖环境
-
gcc
yum install gcc
2 安装
2.1 从官网下载redis环境
从官网上找到资源,直接使用wget
的方式下载
[root@localhost software]# wget http://download.redis.io/releases/redis-5.0.3.tar.gz
--2019-02-20 09:37:23-- http://download.redis.io/releases/redis-5.0.3.tar.gz
正在解析主机 download.redis.io (download.redis.io)... 109.74.203.151
正在连接 download.redis.io (download.redis.io)|109.74.203.151|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1959445 (1.9M) [application/x-gzip]
正在保存至: “redis-5.0.3.tar.gz”
100%[===============================================================================================================================================>] 1,959,445 667KB/s 用时 2.9s
2019-02-20 09:37:30 (667 KB/s) - 已保存 “redis-5.0.3.tar.gz” [1959445/1959445])
2.2 解压
进入下载目录,解压下载的redis安装包
[root@localhost /]# cd /root/software/
[root@localhost software]# tar -zxvf redis-5.0.3.tar.gz
2.3 编译
进入解压目录,执行编译指令make MALLOC=libc
[root@localhost software]# cd redis-5.0.3/
[root@localhost redis-5.0.3]# make MALLOC=libc
执行make test
测试一下
2.4 安装
在安装目录执行make install
进行安装
[root@localhost redis-5.0.3]# make install
cd src && make install
make[1]: 进入目录“/root/software/redis-5.0.3/src”
Hint: It's a good idea to run 'make test' ;)
INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install
make[1]: 离开目录“/root/software/redis-5.0.3/src”
2.5 配置Redis开机自启
在安装目录执行./utils/install_server.sh
[root@localhost redis-5.0.3]# ./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] 6379
Please select the redis config file name [/etc/redis/6379.conf] /etc/redis/6379.conf
Please select the redis log file name [/var/log/redis_6379.log] /var/log/redis_6379.log
Please select the data directory for this instance [/var/lib/redis/6379] /var/lib/redis/6379
Please select the redis executable path [/usr/local/bin/redis-server] /usr/local/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 : /usr/local/bin/redis-server
Cli Executable : /usr/local/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!
3 查看、启动、停止
3.1 查看
通过ps -ef|grep redis
命令查看redis进程
3.2 启动
开启Redis服务操作通过/etc/init.d/redis_6379 start命令,也可通过(service redis_6379 start)
3.3 停止
关闭Redis服务操作通过/etc/init.d/redis_6379 stop命令,也可通过(service redis_6379 stop)
4 安装过程中出现的问题
4.1 You need tcl 8.5 or newer in order to run the Redis test
-
错误日志
You need tcl 8.5 or newer in order to run the Redis test make[1]: *** [test] 错误 1 make[1]: 离开目录“/root/software/redis-5.0.3/src” make: *** [test] 错误 2
-
解决方案
wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz sudo tar xzvf tcl8.6.1-src.tar.gz -C /usr/local/ cd /usr/local/tcl8.6.1/unix/ sudo ./configure sudo make sudo make install
5 参考的文章
Ubuntu 14.04下Redis安装报错:“You need tcl 8.5 or newer in order to run the Redis test”问题解决