欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

Redis安裝與(php-redis)擴(kuò)展-創(chuàng)新互聯(lián)

一、redis簡(jiǎn)介

我們提供的服務(wù)有:網(wǎng)站制作、成都網(wǎng)站制作、微信公眾號(hào)開(kāi)發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、密山ssl等。為近千家企事業(yè)單位解決了網(wǎng)站和推廣的問(wèn)題。提供周到的售前咨詢(xún)和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的密山網(wǎng)站制作公司

Redis是一種高級(jí)key-value數(shù)據(jù)庫(kù)。它跟memcached類(lèi)似不過(guò)數(shù)據(jù)可以持久化而且支持的數(shù)據(jù)類(lèi)型很豐富。有字符串鏈表集 合和有序集合。支持在服務(wù)器端計(jì)算集合的并交和補(bǔ)集(difference)等還支持多種排序功能。所以Redis也可以被看成是一個(gè)數(shù)據(jù)結(jié)構(gòu)服務(wù)器。

Redis的所有數(shù)據(jù)都是保存在內(nèi)存中然后不定期的通過(guò)異步方式保存到磁盤(pán)上(這稱(chēng)為“半持久化模式”)也可以把每一次數(shù)據(jù)變化都寫(xiě)入到一個(gè)append only file(aof)里面(這稱(chēng)為“全持久化模式”)

二、安裝部署

mkdir /soft  cd /soft

安裝插件

wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz  tar zxvf tcl8.6.1-src.tar.gz  cd tcl8.6.1 ./configure make && make install

安裝redis

wget http://redis.googlecode.com/files/redis-2.6.14.tar.gz tar zxvf redis-2.6.14.tar.gz  cd redis-2.6.14 make test make --prefix=/storage/redisdb make intsall

三、安裝完成后在src目錄下生成5個(gè)可執(zhí)行文件redis-server、redis-cli、redis-benchmark、redis-check-aof、redis-check-dump它們的作用如下redis-serverRedis服務(wù)器的daemon啟動(dòng)程序redis-cliRedis命令行操作工具。當(dāng)然你也可以用telnet根據(jù)其純文本協(xié)議來(lái)操作redis-benchmarkRedis性能測(cè)試工具測(cè)試Redis在你的系統(tǒng)及你的配置下的讀寫(xiě)性能redis-check-aof更新日志檢查

redis-check-dump用于本地?cái)?shù)據(jù)庫(kù)檢查

redis啟動(dòng)

cd src ./redis-server [5056] 04 Apr 03:33:50.744 # 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. [5056] 04 Apr 03:33:50.744 * The server is now ready to accept connections on port 6379

四、設(shè)置內(nèi)存分配策略

可選值0、1、2。0 表示內(nèi)核將檢查是否有足夠的可用內(nèi)存供應(yīng)用進(jìn)程使用如果有足夠的可用內(nèi)存內(nèi)存申請(qǐng)?jiān)试S否則內(nèi)存申請(qǐng)失敗并把錯(cuò)誤返回給應(yīng)用進(jìn)程。1 表示內(nèi)核允許分配所有的物理內(nèi)存而不管當(dāng)前的內(nèi)存狀態(tài)如何。2 表示內(nèi)核允許分配超過(guò)所有物理內(nèi)存和交換空間總和的內(nèi)存值得注意的一點(diǎn)是redis在dump數(shù)據(jù)的時(shí)候會(huì)fork出一個(gè)子進(jìn)程理論上child進(jìn)程所占用的內(nèi)存和parent是一樣的比如parent占用的內(nèi)存為8G這個(gè)時(shí)候也要同樣分配8G的內(nèi)存給child,如果內(nèi)存無(wú)法負(fù)擔(dān)往往會(huì)造成redis服務(wù)器的down機(jī)或者IO負(fù)載過(guò)高效率下降。所以這里比較優(yōu)化的內(nèi)存分配策略應(yīng)該設(shè)置為 1表示內(nèi)核允許分配所有的物理內(nèi)存而不管當(dāng)前的內(nèi)存狀態(tài)如何

echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf sysctl -p

驗(yàn)證

src/redis-cli  redis> set foo bar  OK  redis> get foo  bar shutdown

Redis遠(yuǎn)程連接

telnet 127.0.0.1 6379

安全設(shè)置

關(guān)閉掉selinux

/usr/sbin/setenforce 0 立刻關(guān)閉 SELINUX #/sbin/iptables -I INPUT -p tcp --dport 6379 -j ACCEPT #/etc/rc.d/init.d/iptables save

五、配置自啟動(dòng)

cp redis.conf /etc

mkdir -p /storage/redis db文件放在這里要修改redis.conf

mkdir -p /var/log/redislog log文件放在這里要修改redis.conf

修改redis.conf db文件位置

cp redis.conf /etc/ vim /etc/redis # The working directory. # The DB will be written inside this directory, with the filename specified # above using the 'dbfilename' configuration directive. # Also the Append Only File will be created inside this directory # daemonize yes  //改為后臺(tái)啟動(dòng) # Note that you must specify a directory here, not a file name. dir /storage/redis  // db文件位置 logfile=/var/log/redislog   //修改redis.conf log文件位置

配置自啟動(dòng):vi /etc/init.d/redis

startup腳本代碼如下所示將其建立為/etc/init.d/redis文件

#!/bin/bash  #  # Init file for redis  #  # chkconfig: - 80 12  # description: redis daemon  #  # processname: redis  # config: /etc/redis.conf  # pidfile: /var/run/redis.pid  source /etc/init.d/functions  #BIN="/usr/local/bin"  BIN="/usr/local/bin"  CONFIG="/etc/redis.conf"  PIDFILE="/var/run/redis.pid"  ### Read configuration  [ -r "$SYSCONFIG" ] && source "$SYSCONFIG"  RETVAL=0  prog="redis-server"  desc="Redis Server"  start() {          if [ -e $PIDFILE ];then               echo "$desc already running...."               exit 1          fi          echo -n $"Starting $desc: "daemon $BIN/$prog $CONFIG          RETVAL=$?          echo          [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog          return $RETVAL  }  stop() {          echo -n $"Stop $desc: "          killproc $prog          RETVAL=$?          echo          [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog $PIDFILE          return $RETVAL  }  restart() {          stop          start  }  case "$1" in    start)          start          ;;    stop)          stop          ;;    restart)          restart          ;;    condrestart)          [ -e /var/lock/subsys/$prog ] && restart    RETVAL=$?          ;;    status)          status $prog          RETVAL=$?          ;;     *)          echo $"Usage: $0 {start|stop|restart|condrestart|status}"          RETVAL=1  esac  exit $RETVAL chmod +x /etc/init.d/redis

重新啟動(dòng)

/etc/init.d/redis restart Stop Redis Server:                                         [  OK  ] Starting Redis Server:                                     [  OK  ]

六、配置php擴(kuò)展支持redis

1、下載php-redis zip安裝包

https://github.com/nicolasff/phpredis

2、找到PHP安裝路徑

命令whereis phpize和whereis php-config 找到phpize和php-config路徑

3、生成configure

# /usr/bin/phpize

4、編譯安裝

# ./configure --with-php-config=/usr/bin/php-config# make && make install

5、加入安裝的redis.so模塊

# vim /etc/php.ini extension=redis.so

6、重啟apache或nginx

7、測(cè)試

<?php $redis = new Redis(); $redis->connect('127.0.0.1',6379); $redis->set('test','hello world!'); echo $redis->get('test'); ?>

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性?xún)r(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿足用戶(hù)豐富、多元化的應(yīng)用場(chǎng)景需求。

網(wǎng)頁(yè)名稱(chēng):Redis安裝與(php-redis)擴(kuò)展-創(chuàng)新互聯(lián)
標(biāo)題URL:http://chinadenli.net/article4/dissoe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站、域名注冊(cè)服務(wù)器托管、動(dòng)態(tài)網(wǎng)站、網(wǎng)頁(yè)設(shè)計(jì)公司Google

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

綿陽(yáng)服務(wù)器托管