centos7 安装redis

centos7.0 安装redis

本站点下载: redis-3.2.3.tar.gz

wget http://download.redis.io/releases/redis-3.2.3.tar.gz
tar -xf redis-3.2.3.tar.gz
cd redis-3.2.3
make
make install
cd utils
./install_server.sh

centos7 安装redis

如果redis make 出错:

zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h:55:2: error: #error "Newer version of jemalloc required"
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/data0/src/redis-2.6.2/src'
make: *** [all] Error 2

解决:

wget http://www.canonware.com/download/jemalloc/jemalloc-3.3.0.tar.bz2
或者本站下载:
wget https://www.jinchuang.org/novel/lnmp/jemalloc-3.3.0.tar.bz2
tar jxvf jemalloc-3.3.0.tar.bz2 
cd jemalloc-3.3.0
./configure
make && make install

再进入redis安装目录 进行make 操作,make clean 或者 删除解压目录从新解压

redis 安装后配置文件默认在 /etc/redis/6379.conf

使用 systemd,在 /etc/systemd/system 下创建一个单位文件名字为 redis.service

vim /etc/systemd/system/redis.service
#内容如下:

[Unit]
Description=Redis on port 6379
[Service]
Type=forking
ExecStart=/etc/init.d/redis start
ExecStop=/etc/init.d/redis stop
[Install]
WantedBy=multi-user.target

由于/etc/init.d/ 下面redis启动脚本名称为redis_6379 我这里改下文件名称方便操作

cd /etc/init.d/
mv redis_6379 redis
启动redis
service redis start

停止redis
service redis stop

考虑到安全性,我们需要启用redis的密码验证功能requirepass参数 (可选)

vim /etc/redis/6379.conf

requirepass 修改为自定义的密码;

centos7 安装redis

重启redis即可

分享