Redis学习——01.redis安装
来源:互联网 发布:最新网络歌曲下载 编辑:程序博客网 时间:2024/06/05 04:47
下载
tar -xzvf redis-3.2.10.tar.gzcd redis-3.2.10makemake install
执行完之后会在/usr/local/bin下生成redis相关的可执行文件
➜ ~ cd /usr/local/bin➜ bin git:(master) ll -h redis*-rwxr-xr-x 1 mahaiyuan admin 98K 8 1 22:17 redis-benchmark-rwxr-xr-x 1 mahaiyuan admin 14K 8 1 22:17 redis-check-aof-rwxr-xr-x 1 mahaiyuan admin 1.0M 8 1 22:17 redis-check-rdb-rwxr-xr-x 1 mahaiyuan admin 159K 8 1 22:17 redis-clilrwxr-xr-x 1 mahaiyuan admin 12B 8 1 22:17 redis-sentinel -> redis-server-rwxr-xr-x 1 mahaiyuan admin 1.0M 8 1 22:17 redis-server
- redis-server redis服务器
- redis-cli Redis命令行客户端
- redis-benchmark Redis性能测试工具
- redis-check-aof AOF文件修复工具
启动
后台启动
redis-server &[1] 2387023870:C 01 Aug 22:59:39.866 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf23870:M 01 Aug 22:59:39.868 * Increased maximum number of open files to 10032 (it was originally set to 7168). _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 3.2.10 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 23870 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-'23870:M 01 Aug 22:59:39.871 # Server started, Redis version 3.2.1023870:M 01 Aug 22:59:39.872 * DB loaded from disk: 0.001 seconds23870:M 01 Aug 22:59:39.872 * The server is now ready to accept connections on port 6379
停止redis
➜ ~ redis-cli shutdown23870:M 01 Aug 23:00:38.226 # User requested shutdown...23870:M 01 Aug 23:00:38.226 * Saving the final RDB snapshot before exiting.23870:M 01 Aug 23:00:38.227 * DB saved on disk23870:M 01 Aug 23:00:38.227 # Redis is now ready to exit, bye bye...[1] + 23870 done redis-server
客户端使用
➜ ~ redis-cli127.0.0.1:6379>
or
➜ ~ redis-cli -h 127.0.0.1 -p 6379127.0.0.1:6379>
自定义启动和停止脚本
➜ redis ll -htotal 104-rw-r--r--@ 1 mahaiyuan staff 46K 8 1 23:07 redis.conf-rwxr-xr-x 1 mahaiyuan staff 1.6K 8 1 23:24 redis.sh
redis.sh内容如下
#!/bin/bashpath=$(cd "$(dirname "$0")"; pwd)cd $pathCONFIG_FILE=./redis.conf# check pid existspsid=0checkpid() { redisps=`ps -ef | grep redis-server | grep 6379` if [ -n "$redisps" ]; then psid=`echo $redisps | awk '{print $2}'` else psid=0 fi}## 启动redis操作start() { checkpid if [ $psid -ne 0 ]; then echo "================================" echo "warn: redis already started! (pid=$psid)" echo "================================" else echo -n "Starting redis ..." /usr/local/bin/redis-server $CONFIG_FILE & checkpid if [ $psid -ne 0 ]; then echo "(pid=$psid) [Success]" else echo "[Failed]" fi fi}## 停止redis操作stop() { checkpid if [ $psid -ne 0 ]; then echo -n "Stopping redis ...(pid=$psid) " ## shutdown gracefully first /usr/local/bin/redis-cli SHUTDOWN count=0 while [ $count -lt 20 ] do echo "Sleep 3s to wait server stopping..." sleep 3 checkpid if [ $psid -eq 0 ]; then echo "Redis stopped." break fi count=`expr $count + 1` done checkpid if [ $psid -ne 0 ]; then echo "Shutdown gracefully failed, kill -9." kill -9 $psid if [ $? -eq 0 ]; then echo "[Success]" else echo "[Failed]" fi fi else echo "================================" echo "warn: Redis is not running" echo "================================" fi}case "$1" in 'start') start ;; 'stop') stop ;; *) echo "Usage: $0 {start|stop}" exit 1esacexit 0
阅读全文
0 0
- Redis学习——01.redis安装
- Redis学习系列——Redis安装
- redis学习:redis安装
- Redis入门—安装Redis
- Redis学习笔记——Redis安装部署
- Redis学习笔记二——redis安装
- Redis学习笔记三——redis分布式安装
- redis学习(一)——redis介绍及安装
- Redis学习笔记——(一)Redis安装配置
- Redis学习笔记——(三)Redis集群安装
- Redis的学习—安装启动(二)
- Redis学习笔记-Redis安装
- redis学习一 ------ redis安装
- redis学习之安装redis
- JAVAWEB开发之redis学习(一)——redis重点介绍、redis应用场景以及redis的安装运行
- redis——redis安装、启动、停止
- Redis学习——Redis事务
- Redis学习11——Redis事务
- leetcode 340. Longest Substring with At Most K Distinct Characters
- Java NIO Pipe使用示例
- Java集合分类以及各自特点
- jdk 源码分析(2)java hashtable的结构及hashMap对比
- 查看本机ssh公钥,生成公钥
- Redis学习——01.redis安装
- 链表操作(链表面试题)
- Bye, sent_keys
- MySQL存储过程中的3种循环
- sql基础语句
- Python2与Python3中除法功能的异同
- Unity+Behavior Tree行为树 Behavior Designer TaskList介绍一
- 权限与指令
- 17.8.1 收获总结