This is the 29th day of my participation in Gwen Challenge

Accumulate over a long period, constant dripping wears away a stone 😄

First, prepare the GCC environment

yum install gcc-c++
Copy the code

If the following log is displayed, the installation is successful. Package gcc-C ++-4.8.5-39.el7.x86_64 already installed and latest version

Loaded plugins: Fastestmirror Determining fastest mirrors base | 3.6 kB 00:00:00 docker - ce - stable | 3.5 kB 00:00:00 epel | 4.7 kB 00:00:00 extras | 2.9 kB 00:00:00 nginx | 2.9 kB 00:00:00 updates | 2.9 kB 00:00:00 (1/7) : Epel/x86_64 / group_gz | 95 kB 00:00:00 (2/7) : epel/x86_64 / updateinfo | 1.0 MB 00:00:00 (3/7) : docker-ce-stable/x86_64/primary_db | 45 kB 00:00:00 (4/7): extras/7/x86_64/primary_db | 205 kB 00:00:00 (5/7): 7 / x86_64 / updates/primary_db | 3.0 MB 00:00:00 (6/7) : epel/x86_64 / primary_db | 6.8 MB 00:00:00 (7/7) : Nginx/x86_64 / primary_db | 55 kB 00:00:02 Package GCC - c + + - 4.8.5-39. El7. X86_64 already installed and latest version Nothing todo
[root@root ~]# 
Copy the code

Download and install Redis

Execute the command: wget HTTP: / / http://download.redis.io/releases/redis-5.0.7.tar.gz. When the download is complete, unpack it. Then run the make and make install commands.

[root@root /]# cd usr/java
[root@root java]# mkdir redis
[root@root java]# cd redis/
[root@root redis]Wget # http://download.redis.io/releases/redis-5.0.7.tar.gz
[root@root redis]# tar - ZXVF redis - 5.0.7. Tar. Gz
[root@root redis]# CD redis - 5.0.7[root @ root redis - 5.0.7]# make[root @ root redis - 5.0.7]# make install
Copy the code

Three, start,

Run the redis-server redis.conf command to start Redis. If the following page is displayed, the startup is successful.

[root @ root redis - 5.0.7]# redis-server redis.conf_ the _ _. - ` ` __' '-) _ _) - ` ` `. ` _.' '- _ Redis 5.0.7 (00000000/0), 64 - bit. - ` `. - ` ` `. ` ` ` \ / _, _' '-. _ (' , .-` | `, ) Running in standalone mode |`-._`-... - ` __... -. ` ` - _ | '` _....'| Port: 6379 | `-._ `._ / _.-'    |     PID: 12513
  `-._    `-._  `-./  _.-'_. -| ` -) _ ` -) _ ` -. __. -'_. -_. -'| | ` -. _ ` -. _ _. -'_. -' | http://redis.io `-._ `-._`-.__.-'_. -'_. -| ` -) _ ` -) _ ` -. __. -'_. -_. -'| | ` -. _ ` -. _ _. -'_. -'| ` -) _ ` -) _ ` - __. -'_. -'_. -` - _ ` -. __. -'_. -` -. _ _. -'` -. __. -                                               
Copy the code

But this startup can’t do anything on the TAB page, because now after Ctrl+ C, it will look like this. That is, turn off Redis, which is foreground boot.

^C13082:signal-handler (1594381754) Received SIGINT scheduling shutdown...
13082:M 10 Jul 2020 19:49:14.132 # User requested shutdown...13082:M 10 Jul 2020 19:49:14.132 * Saving the Final RDB Snapshot before Withdraw. 13082:M 10 Jul 2020 19:49:14.135 * DB Saved on Disk 13082:M 10 Jul 2020 19:49:14.135 * Removing the pid file. 13082:M 10 Jul 2020 19:49:14.135# Redis is now ready to exit, bye bye...
Copy the code

Iv. Background startup

Open the redis. Conf file. This is also the Redis configuration file.

[root @ root redis - 5.0.7]# vim redis.conf 
After opening, press/type daem in the command window and press Enter
Copy the code

Change to yes


daemonize yes
Copy the code

By default, Redis does not run as a daemon. You can modify this configuration item by using yes to enable the daemon. After enabling the daemon, Redis will write pid to a pidfile in /var/run/redis_6379.pid.

To start again

[root @ root redis - 5.0.7]# redis-server redis.conf 
13352:C 10 Jul 2020 19:54:34.301 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
13352:C 10 Jul 2020 19:54:34.301 # Redis version=5.0.7, bits=64, commit=00000000, Modified =0, PID =13352, just started
13352:C 10 Jul 2020 19:54:34.301 # Configuration loaded
Copy the code

5. Connect to Redis

[root @ root redis - 5.0.7]# redis-cli 
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> config get requirepass
# check password
1) "requirepass"
2) ""127.0.0.1:6379 >Copy the code

Set the password

We discovered that you don’t need a password to get into Redis. So how do you set it up?

Requirepass foobared: Set the Redis connection password. If the connection password is configured, the client needs to use the AUTH password command to provide the password when connecting to Redis, which is disabled by default.

1. Temporary Settings

config set requirepass 123456
Copy the code

2. Permanent Settings

[root @ root redis - 5.0.7]# vim redis.conf
Once open, press/type requirePass in the command window and press Enter
Copy the code

Find what is shown in the picture, open the comment and set your own password.

Then restart Redis.

[root @ root redis - 5.0.7]# redis-server redis.conf [root @ root redis - 5.0.7]# redis-cli 127.0.0.1:6379> ping (error) NOAUTH Authentication required. 127.0.0.1:6379> auth XXX OK 127.0.0.1:6379> ping PONG 127.0.0.1:6379 >Copy the code

You can see that the first ping prompts me to authenticate. Auth XXX this is connected after entering the password. You can also enter:

[root @ root redis - 5.0.7]# redis-cli -p 6379 -a xxx
Copy the code

Online experience: try.redis. IO /

  • If you have any questions or errors in this article, please feel free to comment. If you find this article helpful, please like it and follow it.