fbf-centos7 mounted redis

1. Download the installation package

[root @ CentOS7 opt] # pwd # view the current directory, download the source package in this directory
/ opt
[root @ CentOS7 opt] # wget http://download.redis.io/releases/redis-5.0.5.tar. gz

2. Extract the source package

[Root @ CentOS7 opt] # tar -zxvf redis-5.0.5.tar.gz # decompression will generate a directory of redis-5.0.5

3. Install GCC relies

[Root @ CentOS7 opt] # yum install gcc gcc-c ++ # encountered choose, you can directly enter y

4. Compile & install

[root @ CentOS7 opt] # cd redis-5.0.5 / # redis into the directory
[root @ CentOS7 redis-5.0.5] # make # compiled to wait, i.e. not being given to the next step
[root @ CentOS7 redis- 5.0.5] # make install # installation, when performing the copy will make install several src the following command to the / usr / local / bin / lower

5. Modify redis.conf file, redis.conf file in the directory under redis

① configuration allows all ip can access redis, before bind 127.0.0.1 add "#" to comment out
② default protection mode, the protected-mode yes changed the MODE NO-protected
③ The default is no daemon mode, the daemonize no change yes daemonize
④ front of requirepass foobared "#" removed, changed the password to the password you want to set (training set to 123456, 123456 upcoming foobared changed)

6. Redis new directory in the / etc directory

[root@CentOS7 redis-5.0.5]# mkdir -pv /etc/redis

7. copy the profile into the / etc / redis / under, and named 6379.conf

[root@CentOS7 redis]# cp /opt/redis-5.0.5/redis.conf /etc/redis/6379.conf

8. Create a service

When a service to manage services, create a script in the /etc/init.d/ directory file, to manage start and stop services.
In systemctl, but also similar, different file directory in / etc / systemd / system directory to create a script file redis.service, which reads as follows:
[Unit]
the Description = Redis
the After = network.target

[Service]
Type=forking
ExecStart=/usr/local/bin/redis-server /etc/redis/6379.conf
ExecStop=/usr/locl/bin/redis-cli -h 127.0.0.1 -p 6379 shutdown

RestartSec=10
Restart=always

[Install]
WantedBy=multi-user.target

9. Refresh configuration, so systemctl get recognition

[root@CentOS7 redis]# systemctl daemon-reload

10. Start Close redis

[root @ CentOS7 system] # systemctl start redis # start redis service
[root @ CentOS7 system] # systemctl stop redis # close redis service

11. Set the boot redis

[root@CentOS7 system]# systemctl enable redis

Reference
https://www.cnblogs.com/cdw0724/p/10876869.html

Guess you like

Origin www.cnblogs.com/fb010001/p/12037792.html