一、Redis在Centos7上面安装步骤:
1、下载redis安装包及安装相关依赖包
1.1下载最新稳定版的redis:
wget https://download.redis.io/releases/redis-5.0.14.tar.gz
1.2安装依赖包:
yum install -y epel-release yum install -y gcc
2、解压及编译
2.1进入下载目录并解压:
cd /root tar -xzvf redis-5.0.14.tar.gz 2.2编译: cd redis-5.0.14 cd deps make jemalloc make hiredis make linenoise make lua cd .. make make install
3、修改配置文件
3.1打开配置文件:
cd /root/redis-5.0.14 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
logfile "" 修改为指定的日志文件 logfile "/var/log/redis/6379.log"
4、设置启动服务
4.1将第三步配置好的配置文件复制到指定目录
cp /root/redis-5.0.14/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
参考https://segmentfault.com/a/1190000017780463
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。