linux(ubuntu20.10) :編譯安裝redis6.0.9
阿新 • • 發佈:2020-12-17
一,下載redis
1,redis的官方站:https://redis.io/下載頁面:
https://redis.io/download2,下載到原始碼儲存目錄:
root@ku:/usr/local/source/redis# wget https://download.redis.io/releases/redis-6.0.9.tar.gz
說明:劉巨集締的架構森林是一個專注架構的部落格,地址:https://www.cnblogs.com/architectforest
對應的原始碼可以訪問這裡獲取:https://github.com/liuhongdi/
說明:作者:劉巨集締 郵箱: [email protected]
二,安裝redis6.0.9
1,準備gcc:root@ku:/usr/local/source/redis# gcc --version Command 'gcc' not found, but can be installed with: apt install gcc安裝gcc
root@ku:/usr/local/source/redis# apt install gcc檢視效果:
root@ku:/usr/local/source/redis# gcc --version gcc (Ubuntu 10.2.0-13ubuntu1) 10.2.0 Copyright (C) 2020 Free Software Foundation, Inc. This is2,準備make 安裝makefree software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
root@ku:/usr/local/source/redis# apt install make檢視安裝的效果:
root@ku:/usr/local/source/redis# make --version GNU Make 4.3 為 x86_64-pc-linux-gnu 編譯 Copyright (C)3,解壓redis的原始碼包:1988-2020 Free Software Foundation, Inc. 許可證:GPLv3+:GNU 通用公共許可證第 3 版或更新版本<http://gnu.org/licenses/gpl.html>。 本軟體是自由軟體:您可以自由修改和重新發布它。 在法律允許的範圍內沒有其他保證。
root@ku:/usr/local/source/redis# tar -zxvf redis-6.0.9.tar.gz4,編譯並安裝:
#PREFIX=/usr/local/soft/redis6:用來指定安裝目錄 root@ku:/usr/local/source/redis# cd redis-6.0.9/ root@ku:/usr/local/source/redis/redis-6.0.9# make PREFIX=/usr/local/soft/redis6 install檢視已安裝的目錄:
root@ku:/usr/local/source/redis/redis-6.0.9# ls /usr/local/soft/redis6/ bin5,生成配置檔案:
root@ku:/usr/local/source/redis/redis-6.0.9# mkdir /usr/local/soft/redis6/conf root@ku:/usr/local/source/redis/redis-6.0.9# cp redis.conf /usr/local/soft/redis6/conf/6,生成啟動檔案:
root@ku:/usr/local/source/redis/redis-6.0.9/utils# cp -axv redis_init_script /etc/init.d/redis 'redis_init_script' -> '/etc/init.d/redis’
注意這個啟動檔案位於原始碼的utils目錄下
三,配置redis
1,生成日誌和資料目錄:root@ku:/usr/local/source/redis/redis-6.0.9# mkdir -p /data/redis6 root@ku:/usr/local/source/redis/redis-6.0.9# mkdir -p /data/redis6/logs root@ku:/usr/local/source/redis/redis-6.0.9# mkdir -p /data/redis6/data2,編輯配置檔案
root@ku:/usr/local/source/redis/redis-6.0.9# cd /usr/local/soft/redis6/conf/ root@ku:/usr/local/soft/redis6/conf# vi redis.conf配置項:
1,繫結ip:這裡使用預設值即可 bind 127.0.0.1 2,以daemon方式執行 daemonize yes 3,日誌儲存目錄 logfile "/data/redis6/logs/redis.log" 4,資料儲存目錄: dir /data/redis6/data/ 5,使用的最大記憶體容量 maxmemory 128MB
四,修改啟動檔案
root@ku:/usr/local/source/redis/redis-6.0.9/utils# vi /etc/init.d/redis修改啟動指令碼開始處的變數為:
REDISPORT=6379 EXEC=/usr/local/soft/redis6/bin/redis-server CLIEXEC=/usr/local/soft/redis6/bin/redis-cli PIDFILE=/var/run/redis_${REDISPORT}.pid CONF="/usr/local/soft/redis6/conf/redis.conf"
五,測試執行redis
1,測試啟動server 增加可執行屬性root@ku:/usr/local/source/redis/redis-6.0.9/utils# chmod +x /etc/init.d/redis root@ku:/usr/local/source/redis/redis-6.0.9/utils# update-rc.d redis defaults啟動
root@ku:/usr/local/source/redis/redis-6.0.9/utils# service redis start檢查埠:
root@ku:/usr/local/source/redis/redis-6.0.9/utils# ss -lntp | grep redis LISTEN 0 511 127.0.0.1:6379 0.0.0.0:* users:(("redis-server",pid=16537,fd=6))檢視已安裝的redis版本:
root@ku:/usr/local/source/redis/redis-6.0.9/utils# /usr/local/soft/redis6/bin/redis-server -v Redis server v=6.0.9 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=861e278c5c605f672,測試用cli訪問:
root@ku:/usr/local/source/redis/redis-6.0.9/utils# /usr/local/soft/redis6/bin/redis-cli 127.0.0.1:6379> set a avalue OK 127.0.0.1:6379> get a "avalue"
六,檢視linux的版本:
root@ku:~# more /etc/os-release NAME="Ubuntu Kylin" VERSION="20.10 (Groovy Gorilla)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 20.10" VERSION_ID="20.10" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=groovy UBUNTU_CODENAME=groovy