性能测试复习准备——linux环境下安装redis(7.0.5)

参考博客:https://blog.csdn.net/qq_52227892/article/details/130649748

 

 

参考博客:https://www.cnblogs.com/756623607-zhang/p/17412640.html

 

 

使用的redis版本下载:本文中安装的版本为:http://download.redis.io/releases/redis-7.0.5.tar.gz

 

 

=============================================================================

 

 

 

 

一、通用安装方式

要在Linux上安装Redis,可以按照以下步骤进行操作:

1. 打开终端,使用以下命令下载Redis的压缩包:

1
wget http://download.redis.io/releases/redis-x.x.x.tar.gz

注意将 "x.x.x" 替换为你想要下载的Redis版本号。

2. 解压下载的压缩包:

1
tar xzf redis-x.x.x.tar.gz

进入解压后的目录:

cd redis-x.x.x

3. 编译和安装Redis:

1
2
make
make install  

4. 安装完成后,进入Redis安装目录:

1
cd /usr/local/bin  

5. 启动Redis服务器:

1
./redis-server

或者在后台运行:

1
./redis-server --daemonize yes  

Redis默认监听端口为6379。如果你想修改端口,可以编辑配置文件`redis.conf`进行相应的配置。

6. 检查Redis是否成功运行,可以使用以下命令连接到Redis服务器:

1
./redis-cli

 

这将打开Redis命令行界面。你可以输入Redis命令进行操作,例如 `ping` 测试连接是否正常,`set key value` 设置键值对等。

以上是基本的Redis安装过程。根据你的需求,你还可以进行其他配置和优化,例如设置密码、修改配置文件等。请参考Redis官方文档或其他相关资源获取更多详细信息。

 

 

 

 

 

=================================================================

 

 

 

 

 

 

 创建放置软件包的文件夹以及解压的文件夹,并进行解压缩:

 

 

 

 

 

 

 

Redis是基于c语言编写的需要安装依赖,需要安装gcc:
yum install gcc-c++

 

 

 

 

 

 

 查看gcc版本:

 

 gcc -v

 

 

 

 

 

 

 

 输入make命令配置Gcc需要的文件:

make

 

执行成功后,再次进行make:

make

 

 make install确认所有都安装完成:

make install

 

 

 

 

 

 

 

 

redis默认安装路径:/usr/local/bin

 

 

 

 

 

 

 

在后台启动运行:

./redis-server --daemonize yes 

 

检查Redis是否成功运行,可以使用以下命令连接到Redis服务器:

./redis-cli

 

 

打开Redis命令行界面。你可以输入Redis命令进行操作:

 

 

 

 

 

 

 

 

 

============================================================================

 

 

 

 

 

 

 

 

 

 

 

 

 

 

[root@iZbp14cdvd1cf45cy90gqcZ ~]# cd /soft/

[root@iZbp14cdvd1cf45cy90gqcZ soft]# ls -alt
total 16
drwxr-xr-x   2 root root 4096 Nov 11 15:22 mysql8
drwxr-xr-x   4 root root 4096 Nov 11 14:00 .
dr-xr-xr-x. 21 root root 4096 Nov 11 10:04 ..
drwxr-xr-x   2 root root 4096 Nov 11 10:02 jdk8

[root@iZbp14cdvd1cf45cy90gqcZ soft]# mkdir redis705

[root@iZbp14cdvd1cf45cy90gqcZ soft]# cd redis705/

[root@iZbp14cdvd1cf45cy90gqcZ redis705]# ls -alt

total 8
drwxr-xr-x 5 root root 4096 Nov 12 14:02 ..
drwxr-xr-x 2 root root 4096 Nov 12 14:02 .
[root@iZbp14cdvd1cf45cy90gqcZ redis705]# pwd
/soft/redis705


[root@iZbp14cdvd1cf45cy90gqcZ redis705]# cd ../..

[root@iZbp14cdvd1cf45cy90gqcZ /]# cd /evir

[root@iZbp14cdvd1cf45cy90gqcZ evir]# ls -alt

total 16
drwxr-xr-x   3 root root 4096 Nov 11 15:28 mysql8
drwxr-xr-x   4 root root 4096 Nov 11 14:08 .
drwxr-xr-x   3 root root 4096 Nov 11 10:06 jdk8
dr-xr-xr-x. 21 root root 4096 Nov 11 10:04 ..

[root@iZbp14cdvd1cf45cy90gqcZ evir]# mkdir redis705

[root@iZbp14cdvd1cf45cy90gqcZ evir]# ls -alt
total 20
drwxr-xr-x   5 root root 4096 Nov 12 14:04 .
drwxr-xr-x   2 root root 4096 Nov 12 14:04 redis705
drwxr-xr-x   3 root root 4096 Nov 11 15:28 mysql8
drwxr-xr-x   3 root root 4096 Nov 11 10:06 jdk8
dr-xr-xr-x. 21 root root 4096 Nov 11 10:04 ..

[root@iZbp14cdvd1cf45cy90gqcZ evir]# cd /soft/redis705

[root@iZbp14cdvd1cf45cy90gqcZ redis705]# ls -alt
total 2908
-rw-r--r-- 1 root root 2968205 Nov 12 14:02 redis-7.0.5.tar.gz
drwxr-xr-x 2 root root    4096 Nov 12 14:02 .
drwxr-xr-x 5 root root    4096 Nov 12 14:02 ..


[root@iZbp14cdvd1cf45cy90gqcZ redis705]# tar -zxvf redis-7.0.5.tar.gz -C /evir/redis705


  [root@iZbp14cdvd1cf45cy90gqcZ redis-7.0.5]# yum install gcc-c++



[root@iZbp14cdvd1cf45cy90gqcZ redis-7.0.5]#  gcc -v

   gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)

 

 

   [root@iZbp14cdvd1cf45cy90gqcZ redis-7.0.5]# make



[root@iZbp14cdvd1cf45cy90gqcZ redis-7.0.5]# make install


[root@iZbp14cdvd1cf45cy90gqcZ redis-7.0.5]# cd /usr/local/bin

[root@iZbp14cdvd1cf45cy90gqcZ bin]# ls -alt
total 21540
drwxr-xr-x.  2 root root     4096 Nov 12 14:08 .
lrwxrwxrwx   1 root root       12 Nov 12 14:08 redis-sentinel -> redis-server
lrwxrwxrwx   1 root root       12 Nov 12 14:08 redis-check-aof -> redis-server
lrwxrwxrwx   1 root root       12 Nov 12 14:08 redis-check-rdb -> redis-server
-rwxr-xr-x   1 root root  5411072 Nov 12 14:08 redis-cli
-rwxr-xr-x   1 root root  5197872 Nov 12 14:08 redis-benchmark
-rwxr-xr-x   1 root root 11398080 Nov 12 14:08 redis-server
-rwxr-xr-x   1 root root      424 Sep 19 11:57 normalizer
-rwxr-xr-x   1 root root      397 Sep 19 11:57 jsonschema
-rwxr-xr-x   1 root root      399 Sep 19 11:57 cloud-id
-rwxr-xr-x   1 root root      403 Sep 19 11:57 cloud-init
-rwxr-xr-x   1 root root     2108 Sep 19 11:57 cloud-init-per
-rwxr-xr-x   1 root root     1003 Sep 19 11:56 jsondiff
-rwxr-xr-x   1 root root     3858 Sep 19 11:56 jsonpatch
-rwxr-xr-x   1 root root     1837 Sep 19 11:56 jsonpointer
drwxr-xr-x. 13 root root     4096 Sep 19 11:55 ..



[root@iZbp14cdvd1cf45cy90gqcZ bin]# ./redis-server
22762:C 12 Nov 2023 14:10:19.335 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
22762:C 12 Nov 2023 14:10:19.335 # Redis version=7.0.5, bits=64, commit=00000000, modified=0, pid=22762, just started
22762:C 12 Nov 2023 14:10:19.335 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
22762:M 12 Nov 2023 14:10:19.335 * monotonic clock: POSIX clock_gettime
                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 7.0.5 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 22762
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           https://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'

22762:M 12 Nov 2023 14:10:19.336 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
22762:M 12 Nov 2023 14:10:19.336 # Server initialized
22762:M 12 Nov 2023 14:10:19.336 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
22762:M 12 Nov 2023 14:10:19.336 * Ready to accept connections
./redis-cli
^C22762:signal-handler (1699769487) Received SIGINT scheduling shutdown...


[root@iZbp14cdvd1cf45cy90gqcZ bin]# ps -ef|grep redis
root     23699 15084  0 14:12 pts/1    00:00:00 grep --color=auto redis



[root@iZbp14cdvd1cf45cy90gqcZ bin]# ls -alt
total 21544
drwxr-xr-x.  2 root root     4096 Nov 12 14:11 .
-rw-r--r--   1 root root       88 Nov 12 14:11 dump.rdb
lrwxrwxrwx   1 root root       12 Nov 12 14:08 redis-sentinel -> redis-server
lrwxrwxrwx   1 root root       12 Nov 12 14:08 redis-check-aof -> redis-server
lrwxrwxrwx   1 root root       12 Nov 12 14:08 redis-check-rdb -> redis-server
-rwxr-xr-x   1 root root  5411072 Nov 12 14:08 redis-cli
-rwxr-xr-x   1 root root  5197872 Nov 12 14:08 redis-benchmark
-rwxr-xr-x   1 root root 11398080 Nov 12 14:08 redis-server
-rwxr-xr-x   1 root root      424 Sep 19 11:57 normalizer
-rwxr-xr-x   1 root root      397 Sep 19 11:57 jsonschema
-rwxr-xr-x   1 root root      399 Sep 19 11:57 cloud-id
-rwxr-xr-x   1 root root      403 Sep 19 11:57 cloud-init
-rwxr-xr-x   1 root root     2108 Sep 19 11:57 cloud-init-per
-rwxr-xr-x   1 root root     1003 Sep 19 11:56 jsondiff
-rwxr-xr-x   1 root root     3858 Sep 19 11:56 jsonpatch
-rwxr-xr-x   1 root root     1837 Sep 19 11:56 jsonpointer
drwxr-xr-x. 13 root root     4096 Sep 19 11:55 ..


[root@iZbp14cdvd1cf45cy90gqcZ bin]# ./redis-server --daemonize yes

[root@iZbp14cdvd1cf45cy90gqcZ bin]# ./redis-cli

127.0.0.1:6379> set a 123;
OK
127.0.0.1:6379> get a
"123;"
127.0.0.1:6379> get a
"123;"
127.0.0.1:6379>shutdown

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

=============================================================================

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

[root@iZbp14cdvd1cf45cy90gqcZ /]# mv /redisconfig/ /usr/local/bin
[root@iZbp14cdvd1cf45cy90gqcZ /]# cd /usr/local/bin/
[root@iZbp14cdvd1cf45cy90gqcZ bin]# ls -alt
total 21548
drwxr-xr-x.  3 root root     4096 Nov 12 15:48 .
drwxr-xr-x   2 root root     4096 Nov 12 15:35 redisconfig
-rw-r--r--   1 root root      101 Nov 12 14:41 dump.rdb
lrwxrwxrwx   1 root root       12 Nov 12 14:08 redis-sentinel -> redis-server
lrwxrwxrwx   1 root root       12 Nov 12 14:08 redis-check-aof -> redis-server
lrwxrwxrwx   1 root root       12 Nov 12 14:08 redis-check-rdb -> redis-server
-rwxr-xr-x   1 root root  5411072 Nov 12 14:08 redis-cli
-rwxr-xr-x   1 root root  5197872 Nov 12 14:08 redis-benchmark
-rwxr-xr-x   1 root root 11398080 Nov 12 14:08 redis-server
-rwxr-xr-x   1 root root      424 Sep 19 11:57 normalizer
-rwxr-xr-x   1 root root      397 Sep 19 11:57 jsonschema
-rwxr-xr-x   1 root root      399 Sep 19 11:57 cloud-id
-rwxr-xr-x   1 root root      403 Sep 19 11:57 cloud-init
-rwxr-xr-x   1 root root     2108 Sep 19 11:57 cloud-init-per
-rwxr-xr-x   1 root root     1003 Sep 19 11:56 jsondiff
-rwxr-xr-x   1 root root     3858 Sep 19 11:56 jsonpatch
-rwxr-xr-x   1 root root     1837 Sep 19 11:56 jsonpointer
drwxr-xr-x. 13 root root     4096 Sep 19 11:55 ..
[root@iZbp14cdvd1cf45cy90gqcZ bin]# cd redisconfig
[root@iZbp14cdvd1cf45cy90gqcZ redisconfig]# ls -alt
total 116
drwxr-xr-x. 3 root root   4096 Nov 12 15:48 ..
-rw-r--r--  1 root root 106564 Nov 12 15:37 redis.conf
drwxr-xr-x  2 root root   4096 Nov 12 15:35 .
[root@iZbp14cdvd1cf45cy90gqcZ redisconfig]# pwd
/usr/local/bin/redisconfig
[root@iZbp14cdvd1cf45cy90gqcZ redisconfig]# ls -alt
total 116
drwxr-xr-x. 3 root root   4096 Nov 12 15:48 ..
-rw-r--r--  1 root root 106564 Nov 12 15:37 redis.conf
drwxr-xr-x  2 root root   4096 Nov 12 15:35 .
[root@iZbp14cdvd1cf45cy90gqcZ redisconfig]# redis-server redis.conf
[root@iZbp14cdvd1cf45cy90gqcZ redisconfig]# redis-cli -p 6379
127.0.0.1:6379> 123456
(error) ERR unknown command '123456', with args beginning with:
127.0.0.1:6379> get a;
(error) NOAUTH Authentication required.
127.0.0.1:6379> 123456
(error) ERR unknown command '123456', with args beginning with:
127.0.0.1:6379> set a 123;
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth 123456
OK
127.0.0.1:6379> shutdown
not connected> exit
[root@iZbp14cdvd1cf45cy90gqcZ redisconfig]# vi /etc/systemd/system/redis.service
[root@iZbp14cdvd1cf45cy90gqcZ redisconfig]# systemctl daemon-reload
[root@iZbp14cdvd1cf45cy90gqcZ redisconfig]# systemctl start redis
[root@iZbp14cdvd1cf45cy90gqcZ redisconfig]# systemctl status redis
● redis.service - redis-server
   Loaded: loaded (/etc/systemd/system/redis.service; disabled; vendor preset: disabled)
   Active: active (running) since Sun 2023-11-12 15:56:50 CST; 18s ago
  Process: 28720 ExecStart=/usr/local/bin/redis-server /usr/local/bin/redisconfig/redis.conf (code=exited, status=0/SUCCESS)
 Main PID: 28721 (redis-server)
   CGroup: /system.slice/redis.service
           └─28721 /usr/local/bin/redis-server 127.0.0.1:6379

Nov 12 15:56:50 iZbp14cdvd1cf45cy90gqcZ systemd[1]: Starting redis-server...
Nov 12 15:56:50 iZbp14cdvd1cf45cy90gqcZ systemd[1]: Started redis-server.
[root@iZbp14cdvd1cf45cy90gqcZ redisconfig]# systemctl enable redis
Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /etc/systemd/system/redis.service.
[root@iZbp14cdvd1cf45cy90gqcZ redisconfig]# redis-benchmark -h localhost -p 6379 -c 100 -n 100000
ERROR: NOAUTH Authentication required.
ERROR: failed to fetch CONFIG from localhost:6379
[root@iZbp14cdvd1cf45cy90gqcZ redisconfig]# systemctl restart redis
[root@iZbp14cdvd1cf45cy90gqcZ redisconfig]# ps -ef|grep redis
root     29429     1  0 15:58 ?        00:00:00 /usr/local/bin/redis-server 127.0.0.1:6379
root     29591 11801  0 15:59 pts/1    00:00:00 grep --color=auto redis
[root@iZbp14cdvd1cf45cy90gqcZ redisconfig]# ./redis-cli
-bash: ./redis-cli: No such file or directory
[root@iZbp14cdvd1cf45cy90gqcZ redisconfig]# redis-cli -p 6379
127.0.0.1:6379> auth 123456
OK
127.0.0.1:6379> get a;
(nil)
127.0.0.1:6379> set a 123;
OK
127.0.0.1:6379> get a;
(nil)
127.0.0.1:6379> keys
(error) ERR wrong number of arguments for 'keys' command
127.0.0.1:6379> set a 123
OK
127.0.0.1:6379> get a
"123"
127.0.0.1:6379> shutdown
not connected> quit
[root@iZbp14cdvd1cf45cy90gqcZ redisconfig]#

 

posted @ 2023-11-12 14:40  小白龙白龙马  阅读(168)  评论(0编辑  收藏  举报