日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

Linux 下 Redis 6 的安装使用(Ubuntu 18.04)

發布時間:2025/1/21 linux 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux 下 Redis 6 的安装使用(Ubuntu 18.04) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Redis 的安裝使用


我的小站、Github


Redis(Remote Dictionary Server )是一個使用ANSI C編寫的開源、支持網絡、基于內存、可選持久性的鍵值對存儲數據庫,提供了多種語言的API。


下面是 Ubuntu 18.04 系統上安裝Redis簡易版教程



第一步:下載安裝包

  • 獲取下載地址

    Redis官方網站:https://redis.io/


  • 選擇安裝路徑,我選擇的是 /root/tools/software/
  • cd tools/software/


  • 下載Redis安裝包(6.0.5為版本號,可更換成最新的版本號,若連接更換,請移步官網)
  • wget http://download.redis.io/releases/redis-6.0.5.tar.gz



    第二步:安裝

  • 解壓(請使用對應的文件名)
  • tar -xvf redis-6.0.5.tar.gz


    圖文過長,只截取前面一部分



  • 創建軟鏈接(為了方便,非必須,如果沒有創建,接下來的涉及到redis路徑請用redis-6.0.5)
  • ? ln -s 原始目錄名 快速訪問目錄名

    ln -s redis-6.0.5 redis


  • 進入redis目錄,對解壓的Redis文件進行編譯
  • cd redis make


    如果沒有配置好編譯環境,則使用以下命令配置:

    yum install gcc-c++
  • 進入src文件夾進行Redis安裝
  • cd src make install



    第三步:部署

  • 回到redis目錄下,創建data、conf文件夾用于保存數據和配置文件
  • cd .. mkdir data mkdir conf


  • 進入conf目錄,編寫配置文件 redis-端口號.conf
  • 例:redis-6379.conf (除了帶注釋的行,其他均為默認設置,見redis目錄下的redis.conf文件)

    # 綁定的ip,請根據需求自行更換 bind 127.0.0.1 protected-mode yes # 端口設置 port 6379 tcp-backlog 511 timeout 0 tcp-keepalive 300 # 以守護進程的方式啟動,redis以服務的形式存在,日志不再打印到命令窗口中 daemonize yes supervised no pidfile /var/run/redis_6379.pid loglevel notice # 日志文件名 logfile "6379.log" databases 16 always-show-logo yes save 900 1 save 300 10 save 60 10000 stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename dump.rdb rdb-del-sync-files no # 當前服務文件保存位置,包含日志文件、持久化文件等 dir ../data replica-serve-stale-data yes replica-read-only yes repl-diskless-sync no repl-diskless-sync-delay 5 repl-diskless-load disabled repl-disable-tcp-nodelay no replica-priority 100 acllog-max-len 128 lazyfree-lazy-eviction no lazyfree-lazy-expire no lazyfree-lazy-server-del no replica-lazy-flush no lazyfree-lazy-user-del no appendonly no appendfilename "appendonly.aof" appendfsync everysec no-appendfsync-on-rewrite no auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb aof-load-truncated yes aof-use-rdb-preamble yes lua-time-limit 5000 slowlog-log-slower-than 10000 slowlog-max-len 128 latency-monitor-threshold 0 notify-keyspace-events "" hash-max-ziplist-entries 512 hash-max-ziplist-value 64 list-max-ziplist-size -2 list-compress-depth 0 set-max-intset-entries 512 zset-max-ziplist-entries 128 zset-max-ziplist-value 64 hll-sparse-max-bytes 3000 stream-node-max-bytes 4096 stream-node-max-entries 100 activerehashing yes client-output-buffer-limit normal 0 0 0 client-output-buffer-limit replica 256mb 64mb 60 client-output-buffer-limit pubsub 32mb 8mb 60 hz 10 dynamic-hz yes aof-rewrite-incremental-fsync yes rdb-save-incremental-fsync yes jemalloc-bg-thread yes # 內存到達上限之后的處理策略 maxmemory-policy noeviction # 1. volatile-lru:對設置了過期時間的key執行LRU逐出策略(默認值) # 2. allkeys-lru : 對所有key使用LRU逐出策略 # 3. volatile-random:隨機刪除即將過期key(LFU) # 4. allkeys-random:隨機刪除 # 5. volatile-ttl : 刪除即將過期的 # 6. noeviction : 永不過期,返回錯誤

    第四步:測試

  • 指定配置文件開啟redis服務
  • redis-server redis-6379.conf
  • 連接指定服務器(請使用對應的IP和端口號)
  • redis-cli -h 127.0.0.1 –port 6379
  • set、get測試
  • set name redis get name




    PS:

    Linux命令:

  • 查看當前redis服務進程:
  • ps -ef | grep redis
  • 去除空行和注釋行復制 redis.conf (在redis目錄下復制到conf目錄):
  • grep -Ev "^$|#" redis.conf > ./conf/redis-6379.conf
  • 關閉指定redis進程
  • kill PID



    Reids命令:

  • 默認方式啟動redis服務
  • redis-server

    ? 默認端口號 6379,下面為指定端口號啟動

    redis-server --port 6379

    使用 Ctrl + C 快捷鍵可結束服務


  • redis客戶端中結束服務并退出
  • shutdown exit



    總結

    以上是生活随笔為你收集整理的Linux 下 Redis 6 的安装使用(Ubuntu 18.04)的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。