Centos7-redis-4.0.9安装及开机自启设置

安装redis

下载地址:http://redis.io/download

1、将下载好的redis复制到:/opt/software/redis-4.0.9.tar.gz

2、在/opt/software/目录下执行命令:tar -zxvf redis-4.0.9.tar.gz -C /opt/local/

3、进入/opt/local/redis-4.0.9/目录:cd /opt/local/redis-4.0.9

4、执行make install命令;

以上步骤可以将redis安装完成。

将redis设置成开机启动

1、进入redis目录:/opt/local/redis-4.0.9

2、执行命令:./utils/install_server.sh 

3、一直默认即可:

[root@localhost redis-4.0.9]# ./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] 
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 [/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!

以上操作可以将redis设置为开机启动。

PS:通过这种方式这是redis开机启动,redis的配置文件路径:/etc/redis/6379.conf

扫描二维码关注公众号,回复: 94460 查看本文章

        所以如果修改redis的配置文件,修改路径应该是:/etc/redis/6379.conf

        redis安装目录下的配置文件/opt/local/redis-4.0.9/redis.conf修改会不生效;

        如果想要使用/opt/local/redis-4.0.9/redis.conf,修改/etc/init.d/redis_6379文件即可。

redis客户端命令redis-cli任意位置执行

将export PATH=$PATH:/opt/local/redis-4.0.9/redis-cli加入到/etc/profile最后一行

[root@localhost redis-4.0.9]# vi /etc/profile
[root@localhost redis-4.0.9]# source /etc/profile
[root@localhost redis-4.0.9]# redis-cli 

猜你喜欢

转载自my.oschina.net/zhangdq/blog/1786746