centos7安装redis并设置开机启动
1、首先redis安装
tar xzf redis-3.0.0.tar.gz
cd redis-3.0.0/
make
make install PREFIX=/usr/local/redis
创建存储redis的目录并复制文件
mkdir -p /usr/local/redis
cd src/
cp ./redis-server /usr/local/redis/
cp ./redis-cli /usr/local/redis/
cd ..
cp redis.conf /usr/local/redis/
后端启动
将redis源码包中的redis.conf配置文件复制到/usr/local/redis/bin/下(上面)
修改redis.conf,将daemonize由no改为yes
完成后启动:
./redis-server redis.conf
设置开机启动
在/etc 目录下创建redis 文件夹
cd /etc/
mkdir redis
将 /usr/local/redis/redis.conf 文件复制一份到/etc/redis目录下,并命名为6379.conf
cp /usr/local/redis/redis.conf /etc/redis/6379.conf
将redis的启动脚本复制一份放到/etc/init.d目录下
cp /redis-3.0.0/utils/redis_init_script /etc/init.d/redisd
设置redis开机自启动
cd /etc/init.d/
vi redisd
修改路径,保存并退出vi
EXEC=/usr/local/redis/redis-server
CLIEXEC=/usr/local/redis/redis-cli
执行开机自启命令
chkconfig redisd on
启动和关闭redis
service redisd start
service redisd stop