In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
1. Redis conf parameter configuration:
1. Whether # runs as a daemon: runs as a background process.
Daemonize yes
# if running as a background process, you need to specify a pid. Default is / var/run/redis.pid
Pidfile redis.pid
2. # bind the host IP. The default value is 127.0.0.1.
Redis can only be accessed at 127.0.0.1, so the development environment should be commented out as follows:
# bind 127.0.0.1
3. # Redis default listening port
Port 6379
4. # after how many seconds the client is idle, disconnect. The default is 300 (seconds).
Timeout 300
5. # logging level:
There are 4 optional values, debug,verbose (default), notice,warning
Loglevel verbose
# specify the file name of the log output. The default value is stdout, or it can be set to / dev/null to mask the log.
Logfile stdout
6. # number of available databases. Default value is 16, default database is 0
Databases 16
7. # policies for saving data to disk
(1) # when a piece of Keys data is changed, refresh to disk once in 900s
Save 900 1
(2) # when 10 pieces of Keys data are changed, refresh to disk once in 300 seconds
Save 300 10
(3) # when 1w pieces of keys data are changed, refresh to disk once in 60 seconds
Save 60 10000
8. Whether to log after each update operation. If it is not turned on, it may result in data loss for a period of time in the event of a power outage. Because redis itself synchronizes data files according to the above save conditions, some data will only exist in memory for a period of time. The default value is no
Appendonly no
9. # whether to compress data objects when dump .rdb database
Rdbcompression yes
10. # Local database file name. Default is dump.rdb.
Dbfilename dump.rdb
11. # Local database storage path. The default value is. /
Dir / var/lib/redis/
12. # connection password
# requirepass password
13. # maximum number of client connections, which is not limited by default
# maxclients 128
14. # maximum memory usage setting. After reaching the maximum memory setting, Redis will first try to clear the expired or expiring Key. When this method is processed, any maximum memory setting can no longer be written.
# maxmemory 300mb
15. Replication configuration of # Redis
# slaveof when the machine is a slave service, set the IP and port of the master service
# masterauth set the connection password of the master service when the machine is a slave service
2. Save / backup:
Data backup can be achieved by backing up the file on a regular basis.
Because redis is written to disk asynchronously, if you want to write data in memory to the hard disk immediately, you can execute the following command:
Redis-cli save or redis-cli-p 6380 save (designated port)
Note that the above deployment operations require certain permissions, such as copying and setting kernel parameters.
Memory data is also written to the hard disk when the redis-benchmark command is executed.
3. Enable the port number:
1. Open / etc/sysconfig/iptables
2. After-[An INPUT-p tcp-m state-- state NEW-m tcp-- dport 22-j ACCEPT], add [- An INPUT-p tcp-m state-- state NEW-m tcp-- dport 6379-j ACCEPT] / / where 6379 is the default port number of Redis
3. Save and restart the firewall: / etc/init.d/iptables restart
Fourth, the common operation instructions of redis:
1. Judge whether key exists: exists key.
2. Delete key:del key1 key2 key3...
3. Judge the type of key: type key
4. Use wildcards to find multiple key:
Such as: keys a * find the key that starts with a
5. Rename key:
Rename oldkey newkey
6. Return the number of key of the current database: dbsize
7. Set the expiration time of key:
Expire key seconds
8. Return the remaining expiration seconds of key:
Ttl key
9. Select database: select db_index
Redis defaults to 16 databases, and the default database is the first database, that is, the database with the subscript 0.
For example, select 1 selects the second database.
10. Move key from the current database to the specified database: movemove key db_index
11. Flushdb deletes all key in the current database.
12. Flushall deletes all key in all databases.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.