1. 下载
- 指定某一目录, 下载安装包
[root@localhost install]# wget http://download.redis.io/releases/redis-5.0.7.tar.gz
- 解压
[root@localhost install]#tar xf redis-5.0.7.tar.gz
- 进入
[root@localhost install]#cd redis-5.0.7/
2. 编译
- 查看指导文件
[root@localhost redis-5.0.7]# cat README.md
- 执行
[root@localhost redis-5.0.7]# make
- gcc
[root@localhost redis-5.0.7]# yum install gcc -y
- 清除
[root@localhost redis-5.0.7]# make distclean
- 执行
[root@localhost redis-5.0.7]# make
3. 安装
- 选定路径
[root@localhost redis-5.0.7]# make PREFIX=/opt/bigdata/redis5 install
- 环境变量
[root@localhost redis-5.0.7]# vim /etc/profile
export REDIS_HOME=/opt/bigdata/redis5
export PATH=$PATH:$REDIS_HOME/bin
[root@localhost redis-5.0.7]# source /etc/profile
配置完环境变量后, 可以在任何目录使用redis命令
[root@localhost ~]# redis-
redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server
[root@localhost ~]# redis-
4. 部署service服务
- 进入redis目录
[root@localhost redis-5.0.7]# cd utils/
- 配置端口, 日志等相关参数
./install_server.sh
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/bigdata/redis5/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/bigdata/redis5/bin/redis-server
Cli Executable : /opt/bigdata/redis5/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!
- 查看服务
cd /etc/init.d/
[root@localhost init.d]# ll
total 44
-rw-r--r--. 1 root root 18281 Aug 24 2018 functions
-rwxr-xr-x. 1 root root 4569 Aug 24 2018 netconsole
-rwxr-xr-x. 1 root root 7923 Aug 24 2018 network
-rw-r--r--. 1 root root 1160 Oct 31 2018 README
-rwxr-xr-x. 1 root root 1720 Feb 29 10:47 redis_6379
- 使用service
[root@localhost init.d]# service redis_6379 status
Redis is running (40164)
[root@localhost init.d]# ps -fe | grep redis
root 40164 1 0 10:47 ? 00:00:00 /opt/bigdata/redis5/bin/redis-server 127.0.0.1:6379
root 40182 7418 0 10:48 pts/0 00:00:00 grep --color=auto redis
[root@localhost init.d]# service redis_6379 start
[root@localhost init.d]# service redis_6379 stop
[root@localhost init.d]# service redis_6379 restart