Skip to content

Redis

webdesc
redis
Redis Desktop Manager

centos安装依赖

sh
yum install -y gcc-c++ autoconf automake

# install scl source
yum install -y centos-release-scl scl-utils-build

# 替换源
#===================================================================================
# CentOS-SCLo-sclo.repo
#
# Please see http://wiki.centos.org/SpecialInterestGroup/SCLo for more
# information

[centos-sclo-sclo]
name=CentOS-7 - SCLo sclo
baseurl=http://vault.centos.org/centos/7/sclo/$basearch/sclo/
#mirrorlist=http://mirrorlist.centos.org?arch=$basearch&release=7&repo=sclo-sclo
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

[centos-sclo-sclo-testing]
name=CentOS-7 - SCLo sclo Testing
baseurl=http://buildlogs.centos.org/centos/7/sclo/$basearch/sclo/
gpgcheck=0
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

[centos-sclo-sclo-source]
name=CentOS-7 - SCLo sclo Sources
baseurl=http://vault.centos.org/centos/7/sclo/Source/sclo/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

[centos-sclo-sclo-debuginfo]
name=CentOS-7 - SCLo sclo Debuginfo
baseurl=http://debuginfo.centos.org/centos/7/sclo/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

#===================================================================================
# CentOS-SCLo-rh.repo
#
# Please see http://wiki.centos.org/SpecialInterestGroup/SCLo for more
# information

[centos-sclo-rh]
name=CentOS-7 - SCLo rh
baseurl=https://vault.centos.org/centos/7/sclo/$basearch/rh/
#mirrorlist=http://mirrorlist.centos.org?arch=$basearch&release=7&repo=sclo-rh
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

[centos-sclo-rh-testing]
name=CentOS-7 - SCLo rh Testing
baseurl=http://buildlogs.centos.org/centos/7/sclo/$basearch/rh/
gpgcheck=0
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

[centos-sclo-rh-source]
name=CentOS-7 - SCLo rh Sources
baseurl=http://vault.centos.org/centos/7/sclo/Source/rh/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

[centos-sclo-rh-debuginfo]
name=CentOS-7 - SCLo rh Debuginfo
baseurl=http://debuginfo.centos.org/centos/7/sclo/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

#===================================================================================


# install gcc, gcc-c++ gdb toolchain of version 9
 yum install -y devtoolset-9-toolchain
 
 # 临时富泰系统原有的gcc引用
 scl enable devtoolset-9 bash
 
 # show gcc version
 gcc -v

编译安装

sh
# download redis
wget https://download.redis.io/releases/redis-6.0.9.tar.gz


#unzip
cd /usr/local/src/
tar -zxvf https://download.redis.io/releases/redis-6.0.9.tar.gz

# make
make

#make test
make test 
# error: You need tcl 8.5 or newer in order to run the Redis test
yum install -y tcl 

mkdir -p /usr/local/redis

# install
make PREFIX=/usr/local/redis/ install

cp /usr/local/src/redis-6.0.9/redis.conf /usr/local/redis/bin/

# change daemonize no -> yes
 220 ################################# GENERAL #####################################
 221
 222 # By default Redis does not run as a daemon. Use 'yes' if you need it.
 223 # Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
 224 # daemonize no
 224 daemonize yes
 
 # start
/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf

# kill
kill -p pid

加入系统服务目录vim /etc/systemd/system/redis.service

sh
[Unit]
Description=redis-server
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf
PrivateTmp=true

[Install]
WantedBy=multi-user.target

重载系统服务

sh
systemctl daemon-reload

启动系统redis服务

sh
systemctl start redis.service

systemctl restart redis.service

systemctl stop redis.service

将服务添加到开机启动

sh
systemctl enable redis.service

# Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /etc/systemd/system/redis.service.

redis配置文件

  • daemonize默认情况下,redis不是在和后台运行的,如果需要在后台运行,把该项的设置为yes。
  • databases设置数据库的个数,默认16个,默认是使用的数据库编号是0。
  • save设置redis进行数据库镜像的频率。
  • dbfilename镜像备份文件名。
  • dir数据库镜像备份文件放置的路径。
  • requirepass设置客户端连接后进行任何其他指定前需要使用的密码。
  • maxclients限制同时连接的客户数量。
  • maxmemory设置redis能够使用的最大内存。

授权的两种模式

一种是命令行-a passwrod,另一种是进入redis,然后通过AUTH password