Centos7离线安装redis
参考文档:https://www.cnblogs.com/yy3b2007com/p/10513752.html
1、下载redis安装包 在/opt/redis/ 如没有这个目录需要手动建立
[root@localhost redis]# wget http://download.redis.io/releases/redis-4.0.11.tar.gz
[root@localhost redis]# tar -xf redis-4.0.11.tar.gz
[root@localhost redis]# cd redis-4.0.11/
2、查看是否安装了gcc 如没安装 需要安装gcc
[root@localhost redis]# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4)
Copyright © 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
3、编译安装redis
[root@localhost redis]# make MALLOC=libc
cd src && make all
。。。。。。。。
CC rax.o
LINK redis-server
INSTALL redis-sentinel
CC redis-cli.o
LINK redis-cli
CC redis-benchmark.o
LINK redis-benchmark
INSTALL redis-check-rdb
INSTALL redis-check-aof
Hint: It’s a good idea to run ‘make test’ 😉
make[1]: Leaving directory `/opt/redis/redis-4.0.11/src’
[root@localhost redis]# cd src && make install
CC Makefile.dep
Hint: It’s a good idea to run ‘make test’ 😉
INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install
4、启动redis
[root@CDH-143 src]# ./redis-server
24496:C 11 Mar 13:49:56.298 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
24496:C 11 Mar 13:49:56.298 # Redis version=4.0.11, bits=64, commit=00000000, modified=0, pid=24496, just started
24496:C 11 Mar 13:49:56.298 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
5、设置redis开机启动,并添加到系统服务
[root@CDH-143 src]# mkdir /etc/redis
[root@CDH-143 src]# cd …
[root@CDH-143 redis-4.0.11]# cp redis.conf /etc/redis/6379.conf
修改redis启动为后台启动:
[root@CDH-143 redis-4.0.11]# vi /etc/redis/6379.conf
将启动文件拷贝到init.d中
[root@CDH-143 redis-4.0.11]# cp utils/redis_init_script /etc/init.d/redisd
修改启动脚本参数
[root@CDH-143 redis-4.0.11]# vi /etc/init.d/redisd
添加
# chkconfig: 2345 10 90
# description: Start and Stop redisd
修改:
EXEC=/opt/redis/redis-4.0.11/src/redis-server
CLIEXEC=/opt/redis/redis-4.0.11/src/redis-cli
PIDFILE=/opt/redis/redis-4.0.11/redis_${REDISPORT}.pid
6、增加脚本权限
[root@CDH-143 redis-4.0.11]# chmod +x /etc/init.d/redisd
7、增加系统服务
[root@CDH-143 redis-4.0.11]# chkconfig --add redisd
[root@CDH-143 redis-4.0.11]# chkconfig --list redisd
8、启动redis服务测试
[root@CDH-143 redis-4.0.11]# service redisd start
Starting Redis server…
9084:C 11 Mar 15:23:36.469 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
9084:C 11 Mar 15:23:36.469 # Redis version=4.0.11, bits=64, commit=00000000, modified=0, pid=9084, just started
9084:C 11 Mar 15:23:36.469 # Configuration loaded
[root@CDH-143 redis-4.0.11]#
[root@CDH-143 redis-4.0.11]# ps -aux | grep redis
root 3575 0.0 0.0 38260 2140 ? Ssl 15:09 0:00 /opt/redis/redis-4.0.11/src/redis-server 127.0.0.1:6379
root 8870 0.0 0.0 112660 956 pts/2 S+ 15:22 0:00 grep --color=auto redis