CentOS 7 上安装 redis3.2.3安装与配置

来源:互联网 发布:中学学校网络管理制度 编辑:程序博客网 时间:2024/05/16 15:35

CentOS 7 上安装 redis3.2.3安装与配置


一、redis源码安装

下载redis源码,并进行相关操作,如下:

[root@localhost ~]# wget http://download.redis.io/releases/redis-3.2.3.tar.gz
[root@localhost ~]# tar -zxvf redis-3.2.3.tar.gz
[root@localhost ~]# mv redis-3.2.3 redis

解压完毕后,现在开始安装,如下:

[root@localhost ~]# cd redis
[root@localhost redis]# make && make install

然后再切换到utils目录下,执行redis初始化脚本install_server.sh,如下:

[root@localhost redis]# cd utils/[root@localhost utils]# ./install_server.sh
Welcome to the redis service installerThis script will help you easily set up a running redis serverPlease select the redis port for this instance: [6379] 6379Please select the redis config file name [/etc/redis/6379.conf] /etc/redis/6379.sh       Please select the redis log file name [/var/log/redis_6379.log] /var/log/redis_6379.logPlease select the data directory for this instance [/var/lib/redis/6379] /var/local/bin/6379Please select the redis executable path [/usr/local/bin/redis-server] /usr/local/bin/redis-cliSelected config:Port           : 6379Config file    : /etcshLog file       : /var/log/redis—_6379.logData dir       : /var/local/bin/6379Executable     : /usr/local/bin/redis-cliCli Executable : /usr/local/bin/redis-cliIs this ok? Then press ENTER to go on or Ctrl-C to abort.Copied /tmp/6379.conf => /etc/init.d/redis_6379Installing service...Successfully added to chkconfig!Note: Forwarding request to 'systemctl enable redis_6379.service'.Created symlink from /etc/systemd/system/multi-user.target.wants/redis_6379.service to /etc/systemd/system/redis_6379.service.Successfully added to runlevels 345!/var/run/redis_6379.pid exists, process is already running or crashedInstallation successful![root@localhost utils]# vi /etc/systemd/system/redis_6379.service[Unit]Description=Redis on port 6379[Service]Type=forkingExecStart=/etc/init.d/redis_6379 startExecStop=/etc/init.d/redis.6379 stop[Install]WantedBy=multi-user.target

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

Copied /tmp/6379.conf => /etc/init.d/redis_6379

我们可以看出redis初始化后redis配置文件为/etc/redis/6379.conf,日志文件为/var/log/redis_6379.log,数据文件dump.rdb存放到/var/lib/redis/6379目录下,启动脚本为/etc/init.d/redis_6379。

现在我们要使用 systemd,所以在 /etc/systems/system 下创建一个单位文件名字为 redis_6379.service。

[root@localhost ~]# vi /etc/systemd/system/redis_6379.service

填写下面的内容,详情可见 systemd.service。

[Unit]Description=Redis on port 6379[Service]Type=forkingExecStart=/etc/init.d/redis_6379 startExecStop=/etc/init.d/redis_6379 stop[Install]WantedBy=multi-user.target

现在来查看redis版本使用redis-cli –version命令,如下:

[root@localhost utils]# redis-cli --versionredis-cli 3.2.3

我们可以看到redis版本是3.2.3。

现在我们只要启动redis就可以使用redis了,到此源码方式安装redis就介绍完毕

原创粉丝点击