Centos7安装Redis
一、Redis在Centos7上面安装步骤:
1、下载redis安装包及安装相关依赖包
1.1下载最新稳定版的redis:
wget https://github.com/antirez/redis/archive/5.0.2.tar.gz
1.2安装依赖包:
yum install -y epel-release yum install -y gcc
2、解压及编译
2.1进入下载目录并解压:
cd /root tar -xzvf redis-5.0.2.tar.gz 2.2编译: cd redis-5.0.2 cd deps make jemalloc make hiredis make linenoise make lua cd .. make make install
3、修改配置文件
3.1打开配置文件:
cd /root/redis-5.0.2 vi redis.conf
3.2修改允许远程访问:
bind 127.0.0.1 修改为 #bind 127.0.0.1
3.3设置密码:
# requirepass foobared 修改为 requirepass password(需要设置的密码)
3.4进程在后台运行:
daemonize no 修改为 daemonize yes
3.5日志输出文件等信息:
logfile "" 修改为指定的日志文件 logfile "/var/log/redis/6379.log"
4、设置启动服务
4.1将第三步配置好的配置文件复制到指定目录
cp /root/redis-5.0.2/redis.conf /etc/redis/redis.conf
4.2设置启动服务脚本
cat > /usr/lib/systemd/system/redis.service <<-EOF [Unit] Description=Redis 6379 After=syslog.target network.target [Service] Type=forking PrivateTmp=yes Restart=always ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf ExecStop=/usr/local/bin/redis-cli -h 127.0.0.1 -p 6379 -a jcon shutdown User=root Group=root LimitCORE=infinity LimitNOFILE=100000 LimitNPROC=100000 [Install] WantedBy=multi-user.target EOF # 使服务自动运行 systemctl daemon-reload systemctl enable redis # 启动服务 systemctl restart redis systemctl status redis
相关推荐
王道革 2020-11-25
wangdonghello 2020-11-03
Langeldep 2020-11-16
chenhualong0 2020-11-16
聚合室 2020-11-16
koushr 2020-11-12
MRFENGG 2020-11-11
guoyanga 2020-11-10
fackyou00 2020-11-10
Orangesss 2020-11-03
dongCSDN 2020-10-31
rainandtear 2020-10-30
Quietboy 2020-10-30
liuyulong 2020-10-29
fansili 2020-10-29
温攀峰 2020-10-23
jackbon 2020-10-19
kaixinfelix 2020-10-04