<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ## 1. Redis簡介 Redis:REmote DIctionary Server(遠程字典服務器) ### 1.1 Redis是什么? 是完全開源免費的,用C語言編寫的,遵守BSD協議, 是一個高性能的(key/value)分布式內存數據庫,基于內存運行 并支持持久化的NoSQL數據庫,是當前最熱門的NoSql數據庫之一 ,也被人們稱為數據結構服務器 Redis支持數據的備份,即master-slave模式的數據備份 Redis不僅僅支持簡單的key-value類型的數據,同時還提供list,set,zset,hash等數據結構的存儲 Redis支持數據的持久化,可以將內存中的數據保持在磁盤中,重啟的時候可以再次加載進行使用 ### 1.2 能做什么? 定時器、計數器 發布、訂閱消息系統(消息中間件) 模擬類似于HttpSession這種需要設定過期時間的功能 取最新N個數據的操作,如:可以將最新的10條評論的ID放在Redis的List里面 內存存儲和持久化:redis支持異步將內存中的數據寫到硬盤上,同時不影響繼續服務 ### 1.3 官方網站 * 官網 http://redis.io/download * 中文網: http://www.redis.net.cn/ http://www.redis.cn/ ## 2.Redis安裝 ### 2.1 安裝過程 * 安裝環境 ubuntu14.04 server ``` wget http://download.redis.io/releases/redis-3.2.5.tar.gz tar -xzvf ./redis-3.2.5.tar.gz cd redis-3.2.5/ ~/redis-3.2.5$ sudo apt-get install gcc ~/redis-3.2.5$ sudo apt-get install make ~/redis-3.2.5$ make MALLOC=libc ``` * 將可執行文件導入/usr/local/bin 目錄 ``` ~/redis-3.2.5$ sudo make install cd src && make install make[1]: 正在進入目錄 `/home/hanxt/redis-3.2.5/src' Hint: It's a good idea to run 'make test' ;) INSTALL install INSTALL install INSTALL install INSTALL install INSTALL install make[1]:正在離開目錄 `/home/hanxt/redis-3.2.5/src' ``` 在執行了make install之后,查看默認安裝目錄:/usr/local/bin,包含如下文件: 1. redis-benchmark:性能測試工具,可以在自己本子運行,看看自己本子性能如何 服務啟動起來后執行 2. redis-check-aof:修復有問題的AOF文件 3. redis-check-dump:修復有問題的dump.rdb文件 4. redis-cli:客戶端,操作入口 5. redis-sentinel:redis集群使用 6. redis-server:Redis服務器啟動命令 * 修改redis.conf的配置 ``` bind 192.168.1.152 127.0.0.1 #綁定ip,原始只有127.0.0.1 port 6379 daemonize yes #是否常駐進程運行,原始是no dir /home/aexit1/data/redis/6379 #數據文件持久化存儲路徑,原始是./ logfile /var/log/redis/redis.log requirepass <改為你自己的登陸密碼> ``` * linux系統下面redis常用初始化腳本 ``` #!/bin/bash REDIS_PORT=6379 REDIS_ETC=/etc/redis REDIS_INITD=/etc/init.d sudo mkdir $REDIS_ETC sudo mkdir -p ~/data/redis/$REDIS_PORT sudo mkdir -p /var/log/redis sudo cp ./redis-3.2.5/utils/redis_init_script ${REDIS_INITD}/redis_${REDIS_PORT} sudo cp ./redis-3.2.5/redis.conf ${REDIS_ETC}/${REDIS_PORT}.conf ``` * 執行啟動命令,守護進程 ``` sudo /etc/init.d/redis_6379 start (還可以stop) #redis-server ./redis.conf (這種啟動方式,不是生產規范) ``` * 測試一下基礎命令: ``` redis-cli -h 192.168.1.152 -p 6379 redis> set foo bar OK redis> get foo "bar" ``` ### 2.2.安裝之后需要知道的基礎知識 * redis是單進程工作,利用IO多路復用技術 * 默認16個數據庫,類似數組下表從零開始,初始默認使用零號庫,使用select命令切換數據庫,如select 2 * Redis索引都是從零開始 * redis初始沒有密碼,可以使用統一密碼管理,16個庫都是同樣密碼,要么都OK要么一個也連接不上 * 默認端口是6379 ## 4.Redis常用命令 > 更多命令請參考 http://redisdoc.com/ ## 5.操作系統內核參數優化 ### Redis的啟動過程日志 > 可以看到啟動過程中,有許多的警告 ``` 22034:M 28 Nov 11:21:07.123 * Increased maximum number of open files to 10032 (it was originally set to 1024). _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 3.2.5 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 22034 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' 22034:M 28 Nov 11:21:07.124 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 22034:M 28 Nov 11:21:07.125 # Server started, Redis version 3.2.5 22034:M 28 Nov 11:21:07.125 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect. 22034:M 28 Nov 11:21:07.125 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled. 22034:M 28 Nov 11:21:07.125 * DB loaded from disk: 0.000 seconds 22034:M 28 Nov 11:21:07.125 * The server is now ready to accept connections on port 6379 ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看