网站建设方案 报价,培训行业网站建设,广州工商局官网,宁波公司注册代理公司跟飞牛os上的docker容器安装MySQL大致步骤是一样的。不一样的步骤是关键步骤#xff0c;放到下面着重讲。
一、找redis镜像 二、创建Redis在NAS上映射的文件夹 在你想要的位置创建 redis文件夹。
三、添加容器并启动容器
打开桌面的【Docker】应用#xff0c;点击右上角的…跟飞牛os上的docker容器安装MySQL大致步骤是一样的。不一样的步骤是关键步骤放到下面着重讲。一、找redis镜像二、创建Redis在NAS上映射的文件夹在你想要的位置创建 redis文件夹。三、添加容器并启动容器打开桌面的【Docker】应用点击右上角的添加容器容器名称、资源限制任意即可【勾选☑️】开机自动开启。点击【下一步】进行端口设置和存储设置。端口设置容器端口6379映射到本地6379端口。存储位置/vol2/1000/qwx_space/redis/data对应/data/vol2/1000/qwx_space/redis/logs对应/logs/vol2/1000/qwx_space/redis/redis.conf对应/etc/redis/redis.conf四、成功启动用客户端连接看看是否成功yes成功五、redis.conf:#Redis配置文件样例#Note on units:when memory size is needed,it is possible to specifiy#itin the usual form of1k5GB4M and so forth:# #1k1000bytes #1kb1024bytes #1m1000000bytes #1mb1024*1024bytes #1g1000000000bytes #1gb1024*1024*1024bytes ##unitsarecaseinsensitive so1GB1Gb1gB are all the same.#Redis默认不是以守护进程的方式运行可以通过该配置项修改使用yes启用守护进程# 启用守护进程后Redis会把pid写到一个pidfile中在/var/run/redis.pid daemonize no # 当Redis以守护进程方式运行时Redis默认会把pid写入/var/run/redis.pid文件可以通过pidfile指定 pidfile/var/run/redis.pid # 指定Redis监听端口默认端口为6379# 如果指定0端口表示Redis不监听TCP连接 port6379# 绑定的主机地址 # 你可以绑定单一接口如果没有绑定所有接口都会监听到来的连接 # 默认情况bind127.0.0.1只能接受本机的访问请求 # 不写的情况下无限制接受任何ip地址的访问 # 生产环境肯定要写你应用服务器的地址服务器是需要远程访问的所以需要将其注释掉#bind127.0.0.1#Specify the pathforthe unix socket that will be used to listenfor#incomingconnections.There is nodefault,so Redis will not listen#ona unix socket when not specified.##unixsocket/tmp/redis.sock#unixsocketperm755# 当客户端闲置多长时间后关闭连接如果指定为0表示关闭该功能 timeout0# 指定日志记录级别Redis总共支持四个级别debug、verbose、notice、warning默认为verbose#debug(很多信息,对开发测试比较有用)#verbose(many rarely useful info,but not a mess like the debug level)#notice(moderately verbose,what you want in production probably)#warning(only very important/critical messages are logged)loglevel verbose # 日志记录方式默认为标准输出如果配置为redis为守护进程方式运行而这里又配置为标准输出则日志将会发送给/dev/null logfilestdout#To enable logging to the system logger,just setsyslog-enabledto yes,#andoptionally update the other syslog parameters to suit your needs.#syslog-enabled no#Specify the syslog identity.#syslog-ident redis#Specify the syslog facility.Must be USER or between LOCAL0-LOCAL7.#syslog-facility local0# 设置数据库的数量默认数据库为0可以使用selectdbid命令在连接上指定数据库id#dbid是从0到‘databases’-1的数目databases16################################ SNAPSHOTTING ################################# # 指定在多长时间内有多少次更新操作就将数据同步到数据文件可以多个条件配合#Save the DB on disk:##savesecondschanges##Will save the DBifboth the given number of seconds and the given#numberof write operations against the DB occurred.# # 满足以下条件将会同步数据:#900秒15分钟内有1个更改 #300秒5分钟内有10个更改 #60秒内有10000个更改#Note:可以把所有“save”行注释掉这样就取消同步操作了save9001save30010save6010000# 指定存储至本地数据库时是否压缩数据默认为yesRedis采用LZF压缩如果为了节省CPU时间可以关闭该选项但会导致数据库文件变的巨大 rdbcompression yes # 指定本地数据库文件名默认值为dump.rdb dbfilename dump.rdb # 工作目录.# 指定本地数据库存放目录文件名由上一个dbfilename配置项指定 ##Also the Append Only File will be created inside this directory.# # 注意这里只能指定一个目录不能指定文件名 dir./################################# REPLICATION ################################# # 主从复制。使用slaveof从 Redis服务器复制一个Redis实例。注意该配置仅限于当前slave有效#soforexample it is possible to configure the slave to save the DB with a#differentinterval,or to listen to another port,and so on.# 设置当本机为slav服务时设置master服务的ip地址及端口在Redis启动时它会自动从master进行数据同步#slaveofmasteripmasterport# 当master服务设置了密码保护时slav服务连接master的密码 # 下文的“requirepass”配置项可以指定密码#masterauthmaster-password#When a slave lost the connection with the master,or when the replication#isstill in progress,the slave can act in two different ways:# #1)ifslave-serve-stale-data is set toyes(thedefault)the slave will#stillreply to client requests,possibly with out of data data,or the#dataset may just be emptyifthis is the first synchronization.# #2)ifslave-serve-stale data is set tonothe slave will reply with#anerrorSYNC with master in progressto all the kind of commands#butto INFO and SLAVEOF.#slave-serve-stale-data yes#Slaves send PINGs to server in a predefined interval.Its possible to change#thisinterval with the repl_ping_slave_period option.Thedefaultvalue is10#seconds.##repl-ping-slave-period10#The following option sets a timeoutforboth Bulk transfer I/O timeout and#masterdata or ping response timeout.Thedefaultvalue is60seconds.##It is important to make sure that this value is greater than the value#specifiedforrepl-ping-slave-period otherwise a timeout will be detected#everytime there is low traffic between the master and the slave.##repl-timeout60################################## SECURITY ####################################Warning:since Redis is pretty fast an outside user can try up to#150k passwords per second against a good box.This means that you should#usea very strong password otherwise it will be very easy tobreak.# 设置Redis连接密码如果配置了连接密码客户端在连接Redis时需要通过authpassword命令提供密码默认关闭 requirepass Abcd.1234#Command renaming.##It is possilbe to change the name of dangerous commands in a shared#environment.For instance the CONFIG command may be renamed into something#ofhard to guess so that it will be still availableforinternal-use#toolsbut not availableforgeneral clients.##Example:##rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52##It is also possilbe to completely kill a command renaming it into#anempty string:##rename-command CONFIG################################### LIMITS #################################### # 设置同一时间最大客户端连接数默认无限制Redis可以同时打开的客户端连接数为Redis进程可以打开的最大文件描述符数 # 如果设置maxclients0表示不作限制。当客户端连接数到达限制时Redis会关闭新的连接并向客户端返回max Number of clients reached错误信息#maxclients128#Dont use more memory than the specified amount of bytes.#When the memory limit is reached Redis will try to remove keys with an#EXPIRE set.It will try to start freeing keys that are going to expire#inlittle time and preserve keys with a longer time to live.#Redis will also try to remove objects from free listsifpossible.##If all this fails,Redis will start to reply with errors to commands#thatwill use more memory,like SET,LPUSH,and so on,and willcontinue#toreply to most read-only commands like GET.##WARNING:maxmemory can be a good idea mainlyifyou want to use Redis as a#stateserver or cache,not as a real DB.When Redis is used as a real#databasethe memory usage will grow over the weeks,it will be obviousif#itis going to use too much memory in thelongrun,and youll have the time#toupgrade.With maxmemory after the limit is reached youll start to get#errorsforwrite operations,and this may even lead to DB inconsistency.# 指定Redis最大内存限制Redis在启动时会把数据加载到内存中达到最大内存后Redis会先尝试清除已到期或即将到期的Key # 当此方法处理后仍然到达最大内存设置将无法再进行写入操作但仍然可以进行读取操作。#Redis新的vm机制会把Key存放内存Value会存放在swap区#maxmemorybytes#MAXMEMORY POLICY:how Redis will select what to remove when maxmemory#isreached?You can select among five behavior:##volatile-lru-remove the key with an expire set using an LRU algorithm#allkeys-lru-remove any key accordingly to the LRU algorithm#volatile-random-remove a random key with an expire set#allkeys-random-remove a random key,any key#volatile-ttl-remove the key with the nearest expiretime(minor TTL)#noeviction-dont expire at all,justreturnan error on write operations##Note:with all the kind of policies,Redis willreturnan error on write#operations,when there are not suitable keysforeviction.##At the date of writing this commands are:set setnx setex append#incrdecr rpush lpush rpushx lpushx linsert lset rpoplpush sadd#sintersinterstore sunion sunionstore sdiff sdiffstore zadd zincrby#zunionstorezinterstore hset hsetnx hmset hincrby incrby decrby#getsetmset msetnx exec sort##Thedefaultis:##maxmemory-policyvolatile-lru#LRU and minimal TTL algorithms are not precise algorithms but approximated#algorithms(in order to save memory),so you can select as well the sample#sizeto check.For instancefordefaultRedis will check three keys and#pickthe one that was used less recently,you can change the sample size#usingthe following configuration directive.##maxmemory-samples3############################## APPEND ONLY MODE ############################### ##Note that you can have both the async dumps and the append only fileifyou#like(you have to comment thesavestatements above to disable the dumps).#Stillifappend only mode is enabled Redis will load the data from the#logfile at startup ignoring the dump.rdb file.# 指定是否在每次更新操作后进行日志记录Redis在默认情况下是异步的把数据写入磁盘如果不开启可能会在断电时导致一段时间内的数据丢失。 # 因为redis本身同步数据文件是按上面save条件来同步的所以有的数据会在一段时间内只存在于内存中。默认为no#IMPORTANT:Check the BGREWRITEAOF to check how to rewrite the append#logfile in background when it gets too big.appendonly yes # 指定更新日志文件名默认为appendonly.aof#appendfilenameappendonly.aof#Thefsync()call tells the Operating System to actually write data on disk#insteadto waitformore data in the output buffer.Some OS will really flush#dataon disk,some other OS will just try todoit ASAP.# 指定更新日志条件共有3个可选值#no:表示等操作系统进行数据缓存同步到磁盘快#always:表示每次更新操作后手动调用fsync()将数据写到磁盘慢安全#everysec:表示每秒同步一次折衷默认值appendfsync everysec#appendfsyncno#When the AOF fsync policy is set to always or everysec,and a background#savingprocess(a background save or AOF log background rewriting)is#performinga lot of I/O against the disk,in some Linux configurations#Redis may block toolongon thefsync()call.Note that there is no fixfor#thiscurrently,as even performing fsync in a different thread will block#oursynchronouswrite(2)call.##In order to mitigate this problem its possible to use the following option#thatwill preventfsync()from being called in the main processwhilea#BGSAVE or BGREWRITEAOF is in progress.##This means thatwhileanother child is saving the durability of Redis is#thesame asappendfsync none,that in pratical terms means that it is#possibleto lost up to30seconds of log in the worstscenario(with the#defaultLinux settings).##If you have latency problems turn this toyes.Otherwise leave it as#nothat is the safest pick from the point of view of durability.no-appendfsync-on-rewrite no#Automatic rewrite of the append only file.#Redis is able to automatically rewrite the log file implicitly calling#BGREWRITEAOF when the AOF log size will growth by the specified percentage.##This is how it works:Redis remembers the size of the AOF file after the#latestrewrite(orifno rewrite happened since the restart,the size of#theAOF at startup is used).##This base size is compared to the current size.If the current size is#biggerthan the specified percentage,the rewrite is triggered.Also#youneed to specify a minimal sizeforthe AOF file to be rewritten,this#isuseful to avoid rewriting the AOF file evenifthe percentage increase#isreached but it is still pretty small.##Specify a precentage of zero in order to disable the automatic AOF#rewritefeature.auto-aof-rewrite-percentage100auto-aof-rewrite-min-size64mb ################################## SLOW LOG ####################################The Redis Slow Log is a system to log queries that exceeded a specified#executiontime.The execution time does not include the I/O operations#liketalking with the client,sending the reply and so forth,#butjust the time needed to actually execute thecommand(this is the only#stageof command execution where the thread is blocked and can not serve#otherrequests in the meantime).##You can configure the slow log with two parameters:one tells Redis#whatis the execution time,in microseconds,to exceed in orderforthe#commandto get logged,and the other parameter is the length of the#slowlog.When a new command is logged the oldest one is removed from the#queueof logged commands.#The following time is expressed in microseconds,so1000000is equivalent#toone second.Note that a negative number disables the slow log,while#avalue of zero forces the logging of every command.slowlog-log-slower-than10000#There is no limit to this length.Just be aware that it will consume memory.#You can reclaim memory used by the slow log with SLOWLOG RESET.slowlog-max-len1024################################ VIRTUAL MEMORY ############################### ### WARNING!Virtual Memory is deprecated in Redis2.4### The use of Virtual Memory is strongly discouraged.### WARNING!Virtual Memory is deprecated in Redis2.4### The use of Virtual Memory is strongly discouraged.#Virtual Memory allows Redis to work with datasets bigger than the actual#amountof RAM needed to hold the whole dataset in memory.#In order todoso very used keys are taken in memorywhilethe other keys#areswapped into a swap file,similarly to what operating systemsdo#withmemory pages.# 指定是否启用虚拟内存机制默认值为no#VM机制将数据分页存放由Redis将访问量较少的页即冷数据swap到磁盘上访问多的页面由磁盘自动换出到内存中# 把vm-enabled设置为yes根据需要设置好接下来的三个VM参数就可以启动VM了 vm-enabled no#vm-enabled yes#This is the path of the Redis swap file.As you can guess,swap files#cant be shared by different Redis instances,so make sure to use a swap#fileforevery redis process you are running.Redis will complainifthe#swapfile is already in use.##Redis交换文件最好的存储是SSD固态硬盘# 虚拟内存文件路径默认值为/tmp/redis.swap不可多个Redis实例共享 #***WARNING***ifyou are using a shared hosting thedefaultof putting#theswap file under/tmp is not secure.Create a dir with access granted#onlyto Redis user and configure Redis to create the swap file there.vm-swap-file/tmp/redis.swap#With vm-max-memory0the system will swap everything it can.Not a good#default,just specify the max amount of RAM you can in bytes,but its#betterto leave some margin.For instance specify an amount of RAM#thats more or less between60and80%of your free RAM.# 将所有大于vm-max-memory的数据存入虚拟内存无论vm-max-memory设置多少所有索引数据都是内存存储的Redis的索引数据就是keys # 也就是说当vm-max-memory设置为0的时候其实是所有value都存在于磁盘。默认值为0vm-max-memory0#Redis swap文件分成了很多的page一个对象可以保存在多个page上面但一个page上不能被多个对象共享vm-page-size是要根据存储的数据大小来设定的。# 建议如果存储很多小对象page大小最后设置为32或64bytes如果存储很大的对象则可以使用更大的page如果不确定就使用默认值 vm-page-size32# 设置swap文件中的page数量由于页表一种表示页面空闲或使用的bitmap是存放在内存中的在磁盘上每8个pages将消耗1byte的内存#swap空间总容量为 vm-page-size*vm-pages##With thedefaultof32-bytes memory pages and134217728pages Redis will#usea4GB swap file,that will use16MB of RAMforthe page table.##Its better to use the smallest acceptable valueforyour application,#butthedefaultis large in order to work in most conditions.vm-pages134217728#Max number of VM I/O threads running at the same time.#This threads are used to read/write data from/to swap file,since they#alsoencode and decode objects from disk to memory or the reverse,a bigger#numberof threads can help with big objects evenifthey cant help with#I/O itself as the physical device may not be able to couple with many#reads/writes operations at the same time.# 设置访问swap文件的I/O线程数最后不要超过机器的核数如果设置为0那么所有对swap文件的操作都是串行的可能会造成比较长时间的延迟默认值为4vm-max-threads4############################### ADVANCED CONFIG ################################Hashes are encoded in a specialway(much more memory efficient)when they#haveat max a given numer of elements,and the biggest element does not#exceeda given threshold.You can configure this limits with the following#configurationdirectives.# 指定在超过一定的数量或者最大的元素超过某一临界值时采用一种特殊的哈希算法 hash-max-zipmap-entries512hash-max-zipmap-value64#Similarly to hashes,small lists are also encoded in a special way in order#tosave a lot of space.The special representation is only used when#youare under the following limits:list-max-ziplist-entries512list-max-ziplist-value64#Sets have a special encoding in just onecase:when a set is composed#ofjust strings that happens to be integers in radix10in the range#of64bitsignedintegers.#The following configuration setting sets the limit in the size of the#setin order to use this special memory saving encoding.set-max-intset-entries512#Similarly to hashes and lists,sorted sets are also specially encoded in#orderto save a lot of space.This encoding is only used when the length and#elementsof a sorted set are below the following limits:zset-max-ziplist-entries128zset-max-ziplist-value64#Active rehashing uses1millisecond every100milliseconds of CPU time in#orderto help rehashing the main Redis hashtable(the one mapping top-level#keysto values).The hash table implementation redisuses(see dict.c)#performsa lazy rehashing:the more operation you run into an hash table#thatis rhashing,the more rehashingstepsare performed,soifthe#serveris idle the rehashing is never complete and some more memory is used#bythe hash table.##Thedefaultis to use this millisecond10times every second in order to#activerehashing the main dictionaries,freeing memory when possible.##If unsure:#useactiverehashing noifyou have hard latency requirements and it is#nota good thing in your environment that Redis can reply form time to time#toqueries with2milliseconds delay.# 指定是否激活重置哈希默认为开启 activerehashing yes ################################## INCLUDES ################################### # 指定包含其他的配置文件可以在同一主机上多个Redis实例之间使用同一份配置文件而同时各实例又拥有自己的特定配置文件#include/path/to/local.conf#include/path/to/other.conf