Centos7編譯安裝redis

2021-09-24 02:49:20 字數 2464 閱讀 1699

yum -y install gcc-c++

wget

tar -xvf redis-5.0.4.tar.gz -c /usr/local/

cd /usr/local/redis-5.0.4/

make

make prefix=/usr/local/redis install

如果不做成systemctl服務

vim /usr/local/redis-5.0.4/redis.conf

daemonize yes 以守護程序的方式執行在後台

/usr/local/redis-5.0.4/src/redis-server /usr/local/redis-5.0.4/redis.conf 啟動

/usr/local/redis-5.0.4/src/redis-cli shutdown 停止

做systemctl服務執行以下步驟

vim /usr/lib/systemd/system/redis.service

[unit]

description=redis persistent key-value database

after=network.target

[service]

execstart=/usr/local/redis-5.0.4/src/redis-server /usr/local/redis-5.0.4/redis.conf --supervised systemd 指定啟動用**的配置檔案啟動

execstop=/usr/libexec/redis-shutdown

type=notify

user=redis

group=redis

runtimedirectory=redis

runtimedirectorymode=0755

[install]

wantedby=multi-user.target

vim /usr/libexec/redis-shutdown 停止指令碼

#!/bin/bash

test x"$redis_debug" != x && set -x

redis_cli=/usr/local/redis-5.0.4/src/redis-cli

service_name="$1"

if [ -z "$service_name" ]; then

service_name=redis

ficonfig_file="/etc/$service_name.conf"

host=`awk '/^[[:blank:]]*bind/ ' $config_file | tail -n1`

port=`awk '/^[[:blank:]]*port/ ' $config_file | tail -n1`

pass=`awk '/^[[:blank:]]*requirepass/ ' $config_file | tail -n1`

sock=`awk '/^[[:blank:]]*unixsocket\s/ ' $config_file | tail -n1`

host=$

if [ "$service_name" = redis ]; then

port=$

else

port=$

fi[ -z "$pass" ] || additional_params="-a $pass"

if [ -e "$sock" ] ; then

$redis_cli -s $sock $additional_params shutdown

else

$redis_cli -h $host -p $port $additional_params shutdown

fiuseradd -r redis -s /sbin/nologin

chmod a+x /usr/libexec/redis-shutdown

vim /usr/local/redis-5.0.4/redis.conf

logfile /var/log/redis/redis_log.log 日誌目錄,不做日誌可以不寫

dir /usr/local/redis/redis_dbfile/ 存放dump.rdb的目錄

mkdir /usr/local/redis/redis_dbfile/

chmod 777 /usr/local/redis/redis_dbfile/ 存放dump.rdb的目錄

cp /usr/local/redis-5.0.4/redis.conf /etc/ 若不做日誌定義,可不執行這條(配置檔案不參考etc下的這個、而是啟動指令碼哪個)

systemctl daemon-reload

systemctl start redis

systemctl enable redis.service

systemctl stop redis

Centos7安裝Redis 設定Redis啟動

wgettar zxvf redis 5.0.4.tar.gzyum install gcccd redis 5.0.4make malloc libcmv redis 5.0.4 usr local 選擇資料夾執行 cd src make install安裝完成!執行完make命令後,進入src ...

centos7使用yum命令安裝redis

redis的臨時密碼配置 redis cli進入redis的客戶端 config get requirepss檢視臨時密碼,如果是第一次設定,結果如下 config set requirepass your password 設定你的密碼 config get requirepass再次檢視密碼時出...

CentOS7使用yum安裝配置Redis

一 配置第三方源 su root yum install epel release yum update exit 二 安裝redis su root yum install redis exit 三 配置redis conf su root vim etc redis.conf 開放遠端訪問 加上...