linux中安装redis

来源:互联网 发布:淘宝女装从哪里进货好 编辑:程序博客网 时间:2024/06/06 01:22
在CentOS 7.0 x64 测试


文档:
http://redis.io/download
http://sharadchhetri.com/2015/07/05/install-redis-3-0-from-source-on-ubuntu-14-04-centos-7-rhel-7/


依赖gcc make wget
# yum install make gcc wget


下载解压编译安装


# wget http://download.redis.io/releases/redis-stable.tar.gz
# tar xvzf redis-stable.tar.gz
# cd redis-stable
# make
# make install
# cd utils
# ./install_server.sh


一路回车使用默认配置


[root@dev 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-server安装为服务并开机启动


启动Redis数据库


## To check status of Redis Server
systemctl stop redis_6379


## To start Redis Server
systemctl start redis_6379


## To stop Redis Server
systemctl stop redis_6379


## To restart the Redis Server
systemctl restart redis_6379




登录进入Redis数据库


# redis-cli
127.0.0.1:6379>
127.0.0.1:6379> exit






判断6379是否在监听


# ss -tanp|grep 6379
LISTEN     0      128                       *:6379                     *:*      users:(("redis-server",2435,5))
TIME-WAIT  0      0                 127.0.0.1:46901            127.0.0.1:6379  
LISTEN     0      128                      :::6379                    :::*      users:(("redis-server",2435,4))




Redis通讯确认
[root@dev redis]# redis-cli ping
PONG


PONG就是通讯成功了






启动Redis



0 0
原创粉丝点击