In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Relational database and non-relational database
Relational database:
An institutionalized database, created on the basis of a relational model, generally oriented to records
Including oracle,mysql,sqlserver,db2
Non-relational databases:
Except for mainstream relational databases, unexpected databases are artificially non-relational.
Including redis,mongdb,hbase,couhdb
Background of non-relational database high concurrent reading and writing requirements for massive data efficient storage and access requirements for database high scalability and high availability requirements Redis introduction Redis runs based on memory and supports persistence using key-value (key-value pairs) storage form advantages: extremely high data read and write speed support rich data types support data persistence atomicity support data backup 1 Install the necessary environment components And install localhost [root @ root ~] # yum install gcc gcc-c++ make-y # # installation environment components [root@localhost ~] # mount.cifs / / 192.168.100.3/LNMP-C7 / mnt/ # # mount Password for root@//192.168.100.3/LNMP-C7: [root@localhost ~] # cd / mnt/ [root@localhost mnt] # tar zxvf redis-5.0.7.tar.gz-C / opt/ # # decompress [root@localhost mnt] # cd / opt/redis-5.0.7/ [root@localhost redis-5.0.7] # make # # compile [root@localhost redis-5.0.7] # make PREFIX=/usr/local/redis/ install # # install 2 Execute the configuration Redis profile script And configure [root@localhost redis-5.0.7] # cd utils/ [root@localhost utils] #. / install_server.sh # # execute script to configure Welcome to the redis service installerThis script will help you easily set up a running redis serverPlease select the redis port for this instance: [6379] # # default port Selecting default: 6379Please select the redis config file name [/ etc/redis/6379.conf] # # configuration file Selected default-/ etc/ Redis/6379.confPlease select the redis log file name [/ var/log/redis_6379.log] # # Log file Selected default-/ var/log/redis_6379.logPlease select the data directory for this instance [/ var/lib/redis/6379] # # data file Selected default-/ var/lib/redis/6379Please select the redis executable path [] / usr/local/redis/bin/redis-server executable file path [root@localhost utils] # ln-s / Usr/local/redis/bin/* / usr/local/bin/ # # makes it easy for the system to identify [root@localhost utils] # netstat-ntap | grep 6379tcp 0 0127.0.0.1 netstat 6379 0.0.0.0 ntap * LISTEN 44510/redis-server [root@localhost utils] # / etc/init.d/redis_6379 stop # # close redisStopping. Redis stopped [root@localhost utils ] # / etc/init.d/redis_6379 start # # Open redisStarting Redis server... [root@localhost utils] # vim / etc/redis/6379.conf # # modify the configuration file bind 127.0.0.1 192.168.13.128 # # set the listening address [root@localhost utils] # / etc/init.d/redis_6379 restart # # restart the redis service Stopping. Redis stoppedStarting Redis server... [root@localhost utils] # redis -cli-h 192.168.13.128-p 6379 # # Login redis192.168.13.128:6379 > help set # # help help SET key value [expiration EX seconds | PX milliseconds] [NX | XX] summary: Set the string value of a key since: 1.0.0 group: string192.168.13.128:6379 > set teacher zhangsan # # set key for OK192.168.13.128:6379 > set tea redOK192.168.13.128:6379 > KEYS * # check Look at all the keys 1) "teacher" 2) "tea" 192.168.13.128 keys 6379 > keys tweets? # # check that the key is followed by two characters at the beginning of t 1) "tea" 192.168.13.128 keys 6379 > get tea # # check the value of the key "red" 192.168.13.128 keys 6379 > EXISTS tea # # to see if the key exists (integer) 1 # 1 0 is 192.168.13.128integer 6379 > EXISTS teas (integer) 0192.168.13.128purl 6379 > del teacher # # Delete key (integer) 1192.168.13.128integer 6379 > KEYS * 1) "tea" 192.168.13.128KEYS 6379 > type tea # # View key type string192.168.13.128:6379 > rename tea T1 # # rename key OK192.168.13.128:6379 > keys * 1) "T1" 192.168.13.128 : 6379 > get T1 "red" 192.168.13.128 exit # exit 3 Perform pressure test [root@localhost utils] # redis-benchmark-h 192.168.13.128-p 6379-c 100-n 1000000 # concurrent 100 100000 requests = SET = 100000 requests completed in 1.14 seconds # # time spent 100 parallel clients 3 bytes payload keep alive: 184.66% select 10 # # enter the 11th library OK192.168.13.128:6379 [10] > keys * # View key 1) "T1" 192.168.13.1286379 [10] > get T1 "red" 192.168.13.128seconds 6379 [10] > flushdb # Qing Except for the data in the library OK192.168.13.128:6379 [10] > keys * # View all keys (empty list or set) 192.168.13.128 select 6379 [10] > select 0 # # switch to the first library OK192.168.13.128:6379 > keys * # View all keys 1) "myset:__rand_int__" 2) "mylist" 3) "key:__rand_int__" 4) "counter:__rand_int__" 192.168.13.128 Redis > Redis persistence Redis is running in memory Data in memory lost after power outage in order to reuse Redis data later, or to prevent system failure, we need to write the data in Redis to disk space, that is, persistent classification RDB mode: create a snapshot to get a copy of all the data in the Redis at a certain time AOF mode: write the executed write command to the end of the file Log data changes RDB persistent Redis default file name dump.rdb trigger condition: within a specified time interval, perform a specified number of writes (configuration file control) execute save or bgsave (asynchronous) command execute flushall command, empty all data in the database and execute shutdown command Ensure that the server shuts down normally without losing any data advantages and disadvantages: suitable for large-scale data recovery if the business does not require high data integrity and consistency, RDB is a good choice for low data integrity and consistency when backup takes up memory to restore data through RDB files copy dump.rdb files to the bin directory of redis's installation directory Restart the redis service to configure RDB persistence [root@localhost utils] # vim / etc/redis/6379.conf # at least one write within 900 seconds save 900 write operations within 300 seconds save 300 write operations occur at least 10000 times within 60 seconds save 60 1000 write operations will trigger snapshot operations as long as one of them is satisfied Note all save entries turn off RDB#RDB file name dbfilename dump.rdb#RDB file path dir / var/lib/redis/6379# enable compression function rdbcompression yesAOF persistence Redis is not enabled by default to make up for the deficiency of RDB (data inconsistency) use the form of log to record each write operation And append to the file Redis restart will execute the write instruction from front to back according to the contents of the log file to complete the data recovery work. According to the AOF file recovery data, copy the appendonly.aof file to the bin directory of the redis installation directory. Restart the redis service to enable AOF persistence configuration [root@localhost utils] # vim / etc/redis/6379.conf # enable AOF persistence appendonly yes#AOF file name appendfilename "appendonly.aof" # always: synchronous persistence Every time the data changes, it will be written to disk immediately # appendfsync always#everysec: recommended by default, asynchronous records per second (default) appendfsync everysec#no: out of sync, left to the operating system to decide how to synchronize # appendfsync no# ignores the last potentially problematic instruction aof-load-truncated yesAOF rewriting mechanism AOF works by appending write operations to the file The redundant content of the file will become more and more when the size of the AOF file exceeds the set threshold, Redis will compress the contents of the AOF file the principle of AOF rewriting Redis will fork a new process, read the data in memory (not read the old file), and rewrite it to a temporary file, and finally replace the old aof file AOF rewrite configuration [root@localhost utils] # vim / etc/redis/6379.conf # when the log is BGREWRITEAOF If it is set to yes, it means that the new write operation is not synchronized. Fsync,# is only temporarily stored in the buffer to avoid disk I0 operation conflicts, and write after the rewrite is completed. By default in redis, the current AOF file size of nono-appendfsync-on-rewrite no# is twice the size of the AOF file when the last log rewrite occurs. The BGREWRITEAOF operation auto-aof-rewrite-percentage 10 executes the minimum BGREWRITEAOF command of the current AOF file. # avoid frequent BGREWRITEAOFauto-aof-rewrite-min-size 64mbRedis performance management due to small file size at the beginning of starting Reids. Check redis memory usage [root@localhost utils] # / usr/local/redis/bin/redis-cli127.0.0.1:6379 > info memory memory fragmentation rate ● calculates ● memory fragmentation by dividing the memory value allocated by the system used_ _ memory_ _ rss by the memory value used by redis used_ _ memory Slices are discontinuous physical memory allocation caused by inefficient allocation / recovery of physical memory by the operating system. ● tracking memory fragmentation rate is very important to understand the resource performance of redis instances. Memory fragmentation rate is slightly greater than 1 is reasonable. This value indicates that the memory fragmentation rate is lower than 1.5, indicating that redis consumes 150% of the actual physical memory, of which 50% is the memory fragmentation rate less than 1, indicating that the Redis memory allocation exceeds the physical memory, and the operating system is swapping memory utilization.
The memory usage of the ● redis instance exceeds the maximum available memory, and the operating system will begin to
Exchange of memory and swap space
● avoids memory swapping
Select for cached data size
Use Hash data structures whenever possible
Set the expiration time of key
Recycling key ● ensures rational allocation of redis's limited memory resources ● when memory usage reaches the set maximum threshold You need to select a recycling policy for key. By default, the recycling policy forbids deleting the maxmemory-policy property value from the redis.conf configuration file-volatile-lru: use the LRU algorithm to phase out data from data sets with set expiration times-volatile-ttl: select expired data from data sets with set expiration times (recommended)-volatile-random: from data sets with set expiration time Randomly selected data elimination in data sets-allkeys-lru: use the LRU algorithm to phase out data from all data sets-allkeys-random: randomly select data elimination from data sets-no-enviction: ban elimination data thank you for reading
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.