wget http://download.redis.io/releases/redis-5.0.3.tar.gz
如果没有安装wget:yum -y install wget screen #for CentOS/Redhat
解压tar zxvf redis-5.0.3.tar.gz
cd redis-5.0.3
安装依赖 yum install -y wget gcc make tcl
make && make install PREFIX=/usr/local/redis
如果报错:zmalloc.h:50:31: 致命错误:jemalloc/jemalloc.h:没有那个文件或目录
make MALLOC=libc && make install PREFIX=/usr/local/redis
出现以下完成:
cd /usr/local/redis
创建两个文件夹:mkdir etc var
注释:etc存放redis配置文件redis.conf,var存放启动后的pid文件
cd /usr/local/src/redis-5.0.3
复制文件到/usr/local/redis/etc/
cp redis.conf /usr/local/redis/etc/redis.conf
vim /usr/local/redis/etc/redis.conf 编辑配置文件,将daemonize属性改为yes(表明需要在后台运行),pidfile属性改为/usr/local/redis/var/redis.pid
设置systemctl启动文件:vim /usr/lib/systemd/system/redis-server.service
[Unit]
Description=Redis In-Memory Data Store
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/redis/var/redis.pid
Environment=statedir=/usr/local/redis/var
PermissionsStartOnly=true
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
Restart=always
LimitNOFILE=1000000
LimitNPROC=1000000
LimitCORE=1000000
[Install]
WantedBy=multi-user.target
systemctl start redis-server启动
ps:
[root@localhost redis]# systemctl start redis-server
Warning: redis-server.service changed on disk. Run 'systemctl daemon-reload' to reload units.
[root@localhost redis]# systemctl daemon-reload
[root@localhost redis]# systemctl start redis-server