$ wget http://download.redis.io/releases/redis-5.0.5.tar.gz # 下载redis
$ tar xzf redis-5.0.5.tar.gz # 解压redis
$ cd redis-5.0.5 # 进入解压后的主目录
$ make # 进行编译
$ src/redis-server
redis启动成功,但是这种启动方式需要一直打开窗口,不能进行其他操作,不太方便。按ctrl+c可以关闭窗口
[master@instance-05vnda62 redis-5.0.5]$ vim redis.conf
将 daemonize no 改为 daemonize yes
./redis-server /home/master/redis-5.0.5/redis.conf
5.1 使用ps -aux | grep redis查看redis进程
[master@instance-05vnda62 redis-5.0.5]$ ps -aux | grep redis
master 5724 0.0 0.2 151516 5136 ? T 11:49 0:00 vim /etc/redis.conf
master 5892 0.0 0.2 151520 5204 ? T 11:50 0:00 vim /etc/redis.conf
master 10133 0.0 0.2 151504 5204 ? T 11:58 0:00 vim /etc/redis.conf
master 10957 0.1 0.4 153892 8256 ? Sl 13:59 0:03 src/redis-server
master 11421 0.0 0.0 112704 976 pts/1 R+ 14:40 0:00 grep --color=auto redis
5.2使用kill命令杀死进程
[master@instance-05vnda62 redis-5.0.5]$ kill -9 10957
在/etc/目录下新建一个redis目录:
[master@instance-05vnda62 redis-5.0.5]$ cd /etc
[master@instance-05vnda62 etc]$ sudo mkdir redis
将/usr/local/redis-4.0.6/redis.conf 文件复制一份到/etc/redis目录下,并命名为6379.conf
[master@instance-05vnda62 etc]$ sudo cp /home/master/redis-5.0.5/redis.conf /etc/redis/6379.conf
将redis的启动脚本复制一份放到**/etc/init.d**目录下
[master@instance-05vnda62 etc]$ sudo cp /home/master/redis-5.0.5/utils/redis_init_script /etc/init.d/redisd
先切换到/etc/init.d目录下,然后执行自启命令
[master@instance-05vnda62 etc]$ cd /etc/init.d/
[master@instance-05vnda62 init.d]$ chkconfig redisd on
然后启动:
[master@instance-05vnda62 etc]$ service redisd start
Starting Redis server...
/etc/init.d/redisd: line 28: /usr/local/bin/redis-server: No such file or directory
结果报错了。
**方法一:**我就去这个目录下修改这两行
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli
修改为这个:
EXEC=/home/master/redis-5.0.5/src/redis-server
CLIEXEC=/home/master/redis-5.0.5/src/redis-cli
方法二: 复制两个文件到这个目录下也是一样的。
[master@instance-05vnda62 src]$ sudo cp redis-server /usr/local/bin/redis-server
[master@instance-05vnda62 src]$ sudo cp redis-cli /usr/local/bin/redis-cli
然后再次启动:
[master@instance-05vnda62 init.d]$ service redisd start
Starting Redis server...
11918:C 04 Jun 2019 15:20:36.825 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
11918:C 04 Jun 2019 15:20:36.825 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=11918, just started
11918:C 04 Jun 2019 15:20:36.825 # Configuration loaded
关闭:
service redisd stop