
Redis介紹:
Redis 是完全開源免費的,遵守BSD協議,是一個高性能的key-value資料庫,
Redis 與其他 key - value 快取產品有以下三個特點:
- Redis支持資料的持久化RDB和AOF,可以將記憶體中的資料保存在磁盤中,重啟的時候可以再次加載進行使用,
- Redis不僅僅支持簡單的key-value型別的資料,同時還提供list,set,zset,hash等資料結構的存盤,
- Redis支持資料的備份,即master-slave模式的資料備份,
- 性能極高 – Redis能讀的速度是110000次/s,寫的速度是81000次/s ,
- 豐富的資料型別 – Redis支持二進制案例的 Strings, Lists, Hashes, Sets 及 Ordered Sets 資料型別操作,
- 原子 – Redis的所有操作都是原子性的,意思就是要么成功執行要么失敗完全不執行,單個操作是原子性的,多個操作也支持事務,即原子性,通過MULTI和EXEC指令包起來,
- 豐富的特性 – Redis還支持 publish/subscribe, 通知, key 過期等等特性,
安裝環境:
- 作業系統:CentOS Linux release 7.7.1908 (Core)
- IP地址:192.168.85.16
- 組態檔:/data/redis/conf/redis.conf
- 日志目錄:/data/redis/log/redis.log
- 資料目錄:/data/redis/data/
- 服務:/data/redis/bin/redis-server
環境準備:
yum install -y openssl gcc
Redis安裝:
官網地址:http://redis.io/download
下載最新穩定版本,
本文章用到的是4.0.11版本,下載并安裝:
cd /data wget http://download.redis.io/releases/redis-4.0.11.tar.gz tar zxvf redis-4.0.11.tar.gz
添加用戶:
[root@localhost data]# useradd -M -s /sbin/nologin redis
#查看redisid資訊:
[root@localhost data]# id redis uid=1000(redis) gid=1000(redis) groups=1000(redis)
#設定redis用戶密碼
[root@localhost data]# passwd redis
創建相關目錄:
[root@localhost conf]# mkdir -p /data/redis/{log,conf,data} [root@localhost conf]# chown -R redis:redis /data/redis
編譯安裝:
[root@localhost redis-4.0.11]# pwd /data/redis-4.0.11 [root@localhost redis-4.0.11]# make [root@localhost redis-4.0.11]# cd src/ #指定編譯安裝路徑 [root@localhost src]# make PREFIX=/data/redis install [root@localhost src]# cp ../redis.conf /data/redis/conf
配置環境變數:
[root@localhost src]# vi ~/.bash_profile [root@localhost src]# PATH=$PATH:$HOME/.local/bin:/data/redis/bin:$HOME/bin [root@localhost src]# source ~/.bash_profile
調整redis組態檔:
這個按需設定,我這里列出僅供參考基本的引數
[root@localhost src]# vi /data/redis/conf/redis.conf #daemonize yes #守護行程模式 daemonize yes #日志檔案目錄 logfile "/data/redis/log/redis.log" #redis密碼 requirepass tse123 bind 192.168.85.16
啟停redis服務:
[root@localhost log]# /data/redis/bin/redis-server /data/redis/conf/redis.conf
#查看服務是否啟動成功 [root@localhost log]# netstat -lntp|grep redis tcp 0 0 192.168.85.16:6379 0.0.0.0:* LISTEN 5613/redis-server 1
#停止redis實體服務 /data/redis/bin/redis-cli -h 192.168.85.16 -p 6379 -a 密碼 shutdown
開機自啟動和做成服務啟動:
https://www.cnblogs.com/Sungeek/p/11691231.html
客戶端連接測驗:
[root@localhost log]# /data/redis/bin/redis-cli -h 192.168.85.16 -p 6379 -a 密碼 Warning: Using a password with '-a' option on the command line interface may not be safe. 192.168.85.16:6379> PING PONG 192.168.85.16:6379>
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/6062.html
標籤:NoSQL
