Redis installation and configuration detailed operation steps

Preface

What is Redis: Redis
is a key-value storage system. Similar to Memcached, it supports more stored value types, including string (string), list (linked list), set (collection), zset (sorted set - ordered collection) and hash (hash type)

Redis is a high-performance key-value database.

To ensure efficiency, data is cached in memory. The difference is that redis periodically writes updated data to disk or writes modification operations to additional record files, and on this basis, it realizes master-slave (master-slave) synchronization.


Install Redis

1. Go to the official website to download the latest Redis package
Official website address: https://redis.io/
There are multiple versions, we choose the stable version.
Insert picture description here
2. Upload to the server and unzip

[root@localhost opt]# ls
redis-6.0.9.tar.gz
[root@localhost opt]# tar -zxvf redis-6.0.9.tar.gz 

Insert picture description here

3. Install the compilation environment

yum -y install gcc-c++

升级gcc       #这里要升级一下,否则编译时候会报错
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile  

4. Enter the decompressed package and execute make
Insert picture description here Insert picture description here
5. Enter the configuration file to modify the login password

vim /opt/redis-6.0.9/redis.conf  # 在解压的包里
#requirepass foobared   #找到这一行

requirepass abc.123   #去掉前面的注释,将foobared修改成密码即可

6. Start Redis

cd /usr/local/bin  #进入启动目录

redis-server  /opt/redis-6.0.9/redis.conf &  #跟上配置文件,并 “&”放到后台运行

After successful startup as shown below
Insert picture description here

7. Log in to view and test.

[root@localhost bin]# redis-cli -p 6379 -a abc.123   #  -p 默认端口号是 6379 -a 后面跟密码
127.0.0.1:6379> ping
PON127.0.0.1:6379> set name jack  # 创建一条name是jack的数据
OK
127.0.0.1:6379> get name   # 查看name键值
"kingxin"
127.0.0.1:6379> keys *    # 查看所有键值
1) "name"
127.0.0.1:6379> shutdown  # 关闭redis服务
23615:M 05 Jan 2021 22:20:15.305 # User requested shutdown...
23615:M 05 Jan 2021 22:20:15.305 * Saving the final RDB snapshot before exiting.
23615:M 05 Jan 2021 22:20:15.305 * DB saved on disk
23615:M 05 Jan 2021 22:20:15.305 * Removing the pid file.
23615:M 05 Jan 2021 22:20:15.306 # Redis is now ready to exit, bye bye...
not connected> exit     # 退出程序

----------So far, the installation is over ----------


================================================= ================================================= ================================================= ================================================= ================================================= =============================================
Hard browsing and watching, if right You are helpful, please like it (σ゚∀゚)σ…:*☆

Guess you like

Origin blog.csdn.net/qq_26129413/article/details/112253729