LAP+mysql-主從+redis

來源:互聯網
上載者:User

標籤:down   global   arch   資料庫   bin   檔案   glob   pkill   bsp   

 

 

wget  http://download.redis.io/releases/redis-2.8.13.tar.gz 

cd redis-2.8.13

make PREFIX=/usr/local/redis install

cp redis.conf /usr/local/redis/

[[email protected] bin]# cd /usr/local/redis/
[[email protected] redis]# ls
bin redis.conf
[[email protected] redis]# cd bin/

[[email protected] bin]# nohup ./redis-server &

[email protected] bin]# ps -ef | grep redis

[[email protected] bin]# vim /usr/local/redis/redis.conf

[[email protected] bin]# vim /usr/local/redis/redis.conf   #我們可以採用開啟後台啟動redis命令;改為YES即可

[[email protected] bin]# pkill redis   #先殺死redis進程,再次啟動即可

[[email protected] bin]# /usr/local/redis/bin/redis-server /usr/local/redis/redis.conf    #我們可以發現redis監聽的預設連接埠6379

我們直接在redis端進入redis庫,redis預設就是16個資料庫,通過select [數字]進入相應的資料庫

我們可以通過help config的方式查看redis的配置資訊

127.0.0.1:6379> CONFIG GET *  #擷取redis伺服器所有配置資訊

127.0.0.1:6379> CONFIG SET loglevel "notice"     #擷取redis伺服器記錄層級

127.0.0.1:6379> CONFIG GET bind   #擷取redis監聽的連接埠
1) "bind"
2) ""

127.0.0.1:6379> CONFIG GET daemonize  #設定檔的後台啟動
1) "daemonize"
2) "yes"

127.0.0.1:6379> CONFIG SET requirepass "xiaoyupass"    #我們通過key設定redis一個密碼
OK
127.0.0.1:6379> KEYS *    #我們再次查看,報錯(因為沒有輸入秘密)
(error) NOAUTH Authentication required.

 

127.0.0.1:6379> AUTH xiaoyupass  #輸入密碼,即可查看
OK
127.0.0.1:6379> KEYS *
1) "xiaoyu"
2) "website"
127.0.0.1:6379>

[[email protected] ~]# /usr/local/redis/bin/redis-cli -a xiaoyupass   #在外部進行密碼驗證

###########將LAP與redis整合

一般情況下,web與redis整合需要開發出來的連接埠去串連,因為我們之前在LAP上面搭建了一個Discuiz論壇,存在這連接埠,

[[email protected] ~]# vim /usr/local/httpd/htdocs/config/config_global.php

添加PHPredis擴充驅動,使其串連

[[email protected] ~]#wget https://github.com/phpredis/phpredis/archive/3.1.2.tar.gz

[[email protected] ~]# tar zxf 3.1.2.tar.gz
[[email protected] ~]# /usr/local/php/bin/phize   #因為沒有 configure檔案,無法編譯,所以需要初始化一下

需要安裝autoconf軟體

[[email protected] phpredis-3.1.2]# yum install autoconf -y

[[email protected] phpredis-3.1.2]# /usr/local/php/bin/phpize    #再次初始化

[[email protected] ~]# tar zxf 3.1.2.tar.gz
[[email protected] ~]# /usr/local/php/bin/phize

[[email protected] phpredis-3.1.2]# ./configure -with-php-config=/usr/local/php/bin/php-config --enable-redis

 [[email protected] phpredis-3.1.2]# make 

[[email protected] phpredis-3.1.2]# make  test

[[email protected] phpredis-3.1.2]# make install

[[email protected] ~]# cp /usr/src/php-5.3.28/php.ini-development  /usr/local/php/lib/php.ini
[[email protected] ~]# vim /usr/local/php/php.ini

 [email protected] ~]# /usr/local/httpd/bin/apachectl restart 

[[email protected] ~]# vim /usr/local/httpd/htdocs/phpinfo.php

出現這種情況,表示redis與LAP的驅動串連上了!

 

[[email protected] ~]# /usr/local/redis/bin/redis-cli -a xiaoyupass

  

 

LAP+mysql-主從+redis

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.