CentOS installation and configuration -Redis
Introduction of Redis
- The characteristics of
Redis supports data persistence. Data stored in memory can be saved to disk, which can be reloaded and used upon restart.
Redis supports not only simple key-value data, but also lists, sets, zsets, hash and other data structures. Redis supports data backup in master-slave mode.
- advantage
High performance – Redis can read at 110000 times per second and write at 81000 times per second.
Rich data types – Redis supports Strings, Lists, Hashes, Sets, and Ordered Sets operations for binary cases. Atomic – All operations of Redis are atomic, meaning that they either succeed or fail at all. Individual operations are atomic. Multiple operations also support transactions, that is, atomicity, wrapped through MULTI and EXEC instructions. Rich features – Redis also supports Publish/SUBSCRIBE, notifications, key expiration, and more.
Usr /local/ Redis = usr/local/ Redis
- download
Wget download. Redis. IO/releases/re…
- Unpack the
The tar XZVF redis – 4.0.8. Tar. Gz
- The installation
CD redis-4.0.8 make CD SRC make install PREFIX=/usr/local/redis
- Moving a profile
cd .. / mkdir /usr/local/redis/etc mv redis.conf /usr/local/redis/etc
CentOS configure Redis
- Configure background startup
# change daemonize no to daemonize yes vi/usr/local/redis/etc/redis. Conf
- Add boot automatically
In the add content: / usr/local/redis/bin/redis server/usr/local/redis/etc/redis. Conf vi/etc/rc. Local
- Disable firewall (specify port configuration for security — see appendix for details)
service firewalld stop
- Configure a password
Use the/requirePass command to quickly find # requirePass foobared and uncomment it, changing the foobared to its own password. Then save the vi redis.conf file
- Open access
Redis.conf has a bind 127.0.0.1 configuration that allows only native access by default. Comment this out and use the * to allow external access
You can use Vim to edit files better because they are highlighted. Install vim: 1. The RPM - qa | grep vim (if vim has been installed correctly, return the following three lines of code) vim - enhanced - 7.0.109-7. El5 vim - minimal - 7.0.109-7. El5 Vim - common - 7.0.109-7. El5. 2. If one of these is missing, use the yum -y install command to install (for example, without vim-enhanced) yum -y install vim-enhanced 3. If not, download all of the yum -y install vim* filesCopy the code
Redis Common commands
- Start the
1.redis-server /usr/local/redis/etc/redis.conf 2.redis-server &
- Shut down
1.pkill redis 2.kill pid
- Check the process
ps -ef|grep redis
- Local client
Redis -cli -h 127.0.0.1 -p 6379 -a password
Appendix (Firewall)
For more information about firewall configuration, see this appendix
- Check the firewall service status (running– running /not running– off)
systemctl status firewalld
- Enable, restart, disable, and Firewalld services
Start service Firewalld start
Restart service Firewalld restart Disable service Firewalld stop
- View the firewall configuration rule
firewall-cmd –list-all
- Example Query, enable, and disable the Firewall port
Firewall -cmd –query-port=8080/ TCP Open port 8080. Firewall -cmd –permanent –add-port=8080/ TCP Remove port 8080 –permanent –remove-port=8080/ TCP The configuration parameters are described as follows: 1. Firwall-cmd: is a tool provided by Linux to operate the firewall.
2. –permanent: indicates that the value is permanent. 3. –add-port: identifies the port to be added. 4. –remove-port: indicates the port to be removed. 5, –query-port: identifies the port to be queried;
- Restart the firewall (restart the firewall after modifying port configuration rules)
firewall-cmd –reload
Have a question comment area didi, regular reply