1. 杨乐多博客首页
  2. 技术杂谈
  3. Data Analysis

CentOS 7安装Redis服务

由于大家系统环境各有差异,因此安装时或多或少会遇到问题,遇到问题不可怕,针对性解决即可。下面是博主在虚拟机上的安装步骤,供参考,谢谢!

# 下载安装包并解压
[root@localhost src]# wget http://download.redis.io/releases/redis-4.0.1.tar.gz
[root@localhost src]# tar -zxvf redis-4.0.1.tar.gz
[root@localhost src]# cd redis-4.0.1
[root@localhost redis-4.0.1]# make
[root@localhost redis-4.0.1]# make install
# 上述步骤执行成功后,切换至utils目录,使用脚本安装redis服务
# 在使用脚本安装服务的过程中,可以一路按回车完成安装。之后可以再次运行脚本文件,并通过输入不同的端口号建立多个Redis服务
[root@localhost redis-4.0.1]# cd utils/
[root@localhost utils]# ./install_server.sh
Welcome to the redis service installer
This script will help you easily set up a running redis server

Please select the redis port for this instance: [6379]
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf]
Selected default - /etc/redis/6379.conf
Please select the redis log file name [/var/log/redis_6379.log]
Selected default - /var/log/redis_6379.log
Please select the data directory for this instance [/var/lib/redis/6379]
Selected default - /var/lib/redis/6379
Please select the redis executable path [/usr/local/bin/redis-server]
Selected config:
Port           : 6379
Config file    : /etc/redis/6379.conf
Log file       : /var/log/redis_6379.log
Data dir       : /var/lib/redis/6379
Executable     : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
Starting Redis server...
Installation successful!
# 启动redis服务
[root@localhost utils]# systemctl start redis_6379
[root@localhost utils]# systemctl status redis_6379
● redis_6379.service - LSB: start and stop redis_6379
   Loaded: loaded (/etc/rc.d/init.d/redis_6379; bad; vendor preset: disabled)
   Active: active (exited) since Sun 2017-09-17 16:11:32 CST; 6s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 10584 ExecStart=/etc/rc.d/init.d/redis_6379 start (code=exited, status=0/SUCCESS)

Sep 17 16:11:31 localhost.localdomain systemd[1]: Starting LSB: start and st...
Sep 17 16:11:31 localhost.localdomain redis_6379[10584]: /var/run/redis_6379...
Sep 17 16:11:32 localhost.localdomain systemd[1]: Started LSB: start and sto...
Hint: Some lines were ellipsized, use -l to show in full.
# 测试redis是否正常可用
[root@localhost utils]# cd /usr/local/bin/
[root@localhost bin]# redis-cli
127.0.0.1:6379> set name yangcheng
OK
127.0.0.1:6379> get name
"yangcheng"
127.0.0.1:6379> exit
[root@localhost bin]#

更多信息,请查阅Redis官网:http://redis.cn/

原创文章,作者:iConan,如若转载,请注明出处:https://www.aspyc.com/archives/480.html

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据