Redis 安装(单机版)
1. 检查并确保安装gcc(用来编译源代码生成Makefile)
[root@rocketmq-nameserver1 redis-3.2.1]# rpm -qa |grep gcc-c++
[root@rocketmq-nameserver1 redis-3.2.1]# yum -y install gcc-c++
[root@rocketmq-nameserver1 redis-3.2.1]# rpm -qa |grep gcc-c++
gcc-c++-4.8.5-28.el7_5.1.x86_64
2. 下载并上传安装包到centos上
下载地址:http://download.redis.io/releases/
[root@rocketmq-nameserver1 local]# ls
alibaba-rocketmq-3.2.6 bin games lib libexec rocketmq share
alibaba-rocketmq-3.2.6.tar.gz etc include lib64 redis-cluster sbin src
[root@rocketmq-nameserver1 local]# rz -b
z waiting to receive.**B0100000023be50
[root@rocketmq-nameserver1 local]# ls
alibaba-rocketmq-3.2.6 bin games lib libexec redis-cluster sbin src
alibaba-rocketmq-3.2.6.tar.gz etc include lib64 redis-5.0.0.tar.gz rocketmq share
或者直接用wget从官网上直接获取(需要linux联网)
wget http://download.redis.io/releases/redis-4.0.10.tar.gz
3. 安装配置
[root@rocketmq-nameserver1 local]# tar -xzvf redis-5.0.0.tar.gz
[root@rocketmq-nameserver1 local]# cd redis-5.0.0
[root@rocketmq-nameserver1 redis-5.0.0]# ls
00-RELEASENOTES CONTRIBUTING deps Makefile README.md runtest runtest-sentinel src utils
BUGS COPYING INSTALL MANIFESTO redis.conf runtest-cluster sentinel.conf tests
[root@rocketmq-nameserver1 redis-5.0.0]# make
[root@rocketmq-nameserver1 redis-5.0.0]# cd src/
[root@rocketmq-nameserver1 src]# make install PREFIX=/usr/local/redis
注:其实执行make编译后就可以在src目录下生成相关可执行文件(如下图标绿色的文件),再执行make install 只是把这些可执行文件安装在系统特定目录下(默认:/usr/local/redis,可以通过prefix指定安装目录)
查看安装目录
[root@rocketmq-nameserver1 src]# cd /usr/local/redis/bin/
[root@rocketmq-nameserver1 bin]# ls
redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server
把解压文件夹中 redis.conf 复制一份到安装路径下
[root@rocketmq-nameserver1 bin]# mkdir conf
[root@rocketmq-nameserver1 bin]# cd conf/
[root@rocketmq-nameserver1 conf]# cp /usr/local/redis-5.0.0/redis.conf .
[root@rocketmq-nameserver1 conf]# ls
redis.conf
修改配置文件
[root@bogon conf]# vi redis.conf
# 设置后台启动
daemonize yes
4. 启动测试
[root@rocketmq-nameserver1 conf]# cd /usr/local/redis/bin/
[root@rocketmq-nameserver1 bin]# ./redis-server conf/redis.conf
35138:C 04 Aug 2018 11:07:09.476 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
35138:C 04 Aug 2018 11:07:09.476 # Redis version=5.0.0, bits=64, commit=00000000, modified=0, pid=35138, just started
35138:C 04 Aug 2018 11:07:09.476 # Configuration loaded
[root@rocketmq-nameserver1 bin]# ps -ef |grep redis
root 35139 1 0 11:07 ? 00:00:00 ./redis-server 127.0.0.1:6379
root 35144 25790 0 11:08 pts/1 00:00:00 grep --color=auto redis
[root@rocketmq-nameserver1 bin]# ./redis-cli
127.0.0.1:6379> set name johnson
OK
127.0.0.1:6379> get name
"johnson"
5. 退出服务
- pkill redis-server
- kill 进程号
- src/redis-cli shutdown