centos redis5.0.7 安装、自启
原创 bellys 发表于:2019-12-05 14:15:04
  阅读 :266   收藏   编辑

一、下载

wget http://download.redis.io/releases/redis-5.0.7.tar.gz

二、解压编译

#解压
tar -zxvf redis-5.0.7.tar.gz
cd redis-5.0.7
#编译安装
make MALLOC=libc
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

三、配置

复制配置文件

#创建目录
mkdir /etc/redis
#复制一份默认配置文件 
cp REDIS_HOME/redis.conf  /etc/redis/
#更名
mv redis.conf  6379.conf

后台模式

vim /etc/redis/6379.conf
daemonize no #改为yes表示在后台运行

四、启动

指定配置文件路径

REDIS_HOME/src/redis-server  /etc/reids/6379.conf 

关闭

ps -ef|grep redis
root      3183     1  0 13:32 ?        00:00:00 ./redis-5.0.7/src/redis-server 127.0.0.1:6379
root      3218  1639  0 13:32 pts/0    00:00:00 grep --color=auto redis

kill杀死

kill -9 3183 #pid

五、开机自启

复制启动脚本到/etc目录下

REDIS_HOME/utils/redis_init_script /etc/init.d/redisd

设置自启

systemctl enable redisd.service

命令启动

#启动
systemctl start redisd.service
#关闭
systemctl stop  redisd.service
#查看状态
systemctl status redisd.service

若启动失败,查看状态如下

/var/run/redis_6379.pid exists, process is already running or crashed

执行以下命令即可

REDIS_HOME/src/redis-server /etc/redis/6379.conf