memcache搭建

Posted 开始认识

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了memcache搭建相关的知识,希望对你有一定的参考价值。

memcache搭建步骤:

个人原创,允许转载,请注明出处,作者,否则追究法律责任。


0.1 memcache的服务端
0.2 mysql的服务端
0.3 memcache 的客户端:lamp架构

1,环境搭建:
memcache的安装包
if地址
yum源
三关
yum - y install gcc*

2,先配置0.3上的lamp架构:

yum -y install httpd mysql-server mysql
82 service httpd restart
83 cd /root/桌面/
84 ls
85 cp memcache.zip /tmp
86 cd /tmp/
87 ls
88 unzip memcache.zip
89 ls
90 cd memcache
91 ls
94 cp memcache-2.2.7.tgz /usr/src/
95 scp memcached-1.4.22.tar.gz libevent-2.0.22-stable.tar.gz [email protected]:/tmp
96 ls
97 cd php/
98 ls
99 rm -rf php-devel-5.3.2-6.el6.x86_64.rpm
100 rm -rf php-devel-5.3.3-23.el6_4.x86_64.rpm
101 ls
102 cd /usr/src/
103 ls
108 tar fx memcache-2.2.7.tgz
109 ls
110 cd memcache-2.2.7
111 ls
112 cd -
113 ls
114 cd /tmp/memcache/php/
115 ls
117 yum -y localinstall ./*
118 yum -y localinstall --skip-broken ./*
119 cd /usr/src/
120 ls
121 cd memcache-2.2.7
122 phpize
123 ls
124 ./configure --enable-memcache --with-php-config=/usr/bin/php-config
125 make
126 make install
127 ls /usr/lib64/php/modules/
128 vim /etc/php.ini
末行添加:extension=memcache.so
129 php -m

3,配置0.1上的memcache的服务端

cd /tmp
54 ls
55 tar fx libevent-2.0.22-stable.tar.gz
56 ls
57 cd libevent-2.0.22-stable
58 ls
59 ./configure --prefix=/usr/local/libevent
81 make && make install
82 cd ..
83 ls
84 tar fx memcached-1.4.22.tar.gz
85 ls
86 cd memcached-1.4.22
87 ls
88 ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent
89 make
91 make install
92 /usr/local/memcached/bin/memcached -u root -p 11211 -l 10.0.0.1 -P /var/run/messagebus.pid -m 128m -c 2048 -d

[[email protected] memcached-1.4.22]# /usr/local/memcached/bin/memcached -u root -p 11211 -l 10.0.0.1 -P /var/run/messagebus.pid -m 128m -c 2048 -d
[[email protected]lhost memcached-1.4.22]# yum -y install lsof
已加载插件:product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
设置安装进程
包 lsof-4.82-5.el6.x86_64 已安装并且是最新版本
无须任何处理
[[email protected] memcached-1.4.22]# lsof -i :11211
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
memcached 14715 root 26u IPv4 43374 0t0 TCP 10.0.0.1:memcache (LISTEN)
memcached 14715 root 27u IPv4 43376 0t0 UDP 10.0.0.1:memcache
memcached 14715 root 28u IPv4 43376 0t0 UDP 10.0.0.1:memcache
memcached 14715 root 29u IPv4 43376 0t0 UDP 10.0.0.1:memcache
memcached 14715 root 30u IPv4 43376 0t0 UDP 10.0.0.1:memcache

[[email protected] memcached-1.4.22]# ps aux |grep memcache
root 14715 0.0 0.2 326916 1140 ? Ssl 14:59 0:00 /usr/local/memcached/bin/memcached -u root -p 11211 -l 10.0.0.1 -P /var/run/messagebus.pid -m 128m -c 2048 -d
root 14728 0.0 0.1 103324 876 pts/0 S+ 14:59 0:00 grep memcache
[[email protected] memcached-1.4.22]# yum -y install telnet
[[email protected] memcached-1.4.22]# telnet 10.0.0.3 80
Trying 10.0.0.3...
Connected to 10.0.0.3.
Escape character is ‘^]‘.
set name 0 60 5
vfast
STORED
get name

stats

 

 

 

4,0.2 安装MySQL服务端

yum -y intall mysql mysql-server
[[email protected] yum.repos.d]# service mysqld start

[[email protected] yum.repos.d]# mysql
...
mysql> grant all on *.* to [email protected]‘%‘ identified by ‘123‘;
Query OK, 0 rows affected (0.00 sec)

mysql> select user,password,host from mysql.user;
+------+-------------------------------------------+-----------------------+
| user | password | host |
+------+-------------------------------------------+-----------------------+
| root | | localhost |
| root | | localhost.localdomain |
| root | | 127.0.0.1 |
| | | localhost |
| | | localhost.localdomain |
| root | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 | % |
+------+-------------------------------------------+-----------------------+
6 rows in set (0.00 sec)

mysql> exit

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

memcache搭建步骤:
0.1 memcache的服务端
0.2 mysql的服务端
0.3 memcache 的客户端:lamp架构

1,环境搭建:
memcache的安装包
if地址
yum源
三关
yum - y install gcc*

2,先配置0.3上的lamp架构:

yum -y install httpd mysql-server mysql
82 service httpd restart
83 cd /root/桌面/
84 ls
85 cp memcache.zip /tmp
86 cd /tmp/
87 ls
88 unzip memcache.zip
89 ls
90 cd memcache
91 ls
94 cp memcache-2.2.7.tgz /usr/src/
95 scp memcached-1.4.22.tar.gz libevent-2.0.22-stable.tar.gz [email protected]:/tmp
96 ls
97 cd php/
98 ls
99 rm -rf php-devel-5.3.2-6.el6.x86_64.rpm
100 rm -rf php-devel-5.3.3-23.el6_4.x86_64.rpm
101 ls
102 cd /usr/src/
103 ls
108 tar fx memcache-2.2.7.tgz
109 ls
110 cd memcache-2.2.7
111 ls
112 cd -
113 ls
114 cd /tmp/memcache/php/
115 ls
117 yum -y localinstall ./*
118 yum -y localinstall --skip-broken ./*
119 cd /usr/src/
120 ls
121 cd memcache-2.2.7
122 phpize
123 ls
124 ./configure --enable-memcache --with-php-config=/usr/bin/php-config
125 make
126 make install
127 ls /usr/lib64/php/modules/
128 vim /etc/php.ini
末行添加:extension=memcache.so
129 php -m

3,配置0.1上的memcache的服务端

cd /tmp
54 ls
55 tar fx libevent-2.0.22-stable.tar.gz
56 ls
57 cd libevent-2.0.22-stable
58 ls
59 ./configure --prefix=/usr/local/libevent
81 make && make install
82 cd ..
83 ls
84 tar fx memcached-1.4.22.tar.gz
85 ls
86 cd memcached-1.4.22
87 ls
88 ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent
89 make
91 make install
92 /usr/local/memcached/bin/memcached -u root -p 11211 -l 10.0.0.1 -P /var/run/messagebus.pid -m 128m -c 2048 -d

[[email protected] memcached-1.4.22]# /usr/local/memcached/bin/memcached -u root -p 11211 -l 10.0.0.1 -P /var/run/messagebus.pid -m 128m -c 2048 -d
[[email protected] memcached-1.4.22]# yum -y install lsof
已加载插件:product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
设置安装进程
包 lsof-4.82-5.el6.x86_64 已安装并且是最新版本
无须任何处理
[[email protected] memcached-1.4.22]# lsof -i :11211
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
memcached 14715 root 26u IPv4 43374 0t0 TCP 10.0.0.1:memcache (LISTEN)
memcached 14715 root 27u IPv4 43376 0t0 UDP 10.0.0.1:memcache
memcached 14715 root 28u IPv4 43376 0t0 UDP 10.0.0.1:memcache
memcached 14715 root 29u IPv4 43376 0t0 UDP 10.0.0.1:memcache
memcached 14715 root 30u IPv4 43376 0t0 UDP 10.0.0.1:memcache

[[email protected] memcached-1.4.22]# ps aux |grep memcache
root 14715 0.0 0.2 326916 1140 ? Ssl 14:59 0:00 /usr/local/memcached/bin/memcached -u root -p 11211 -l 10.0.0.1 -P /var/run/messagebus.pid -m 128m -c 2048 -d
root 14728 0.0 0.1 103324 876 pts/0 S+ 14:59 0:00 grep memcache
[[email protected] memcached-1.4.22]# yum -y install telnet
[[email protected] memcached-1.4.22]# telnet 10.0.0.3 80
Trying 10.0.0.3...
Connected to 10.0.0.3.
Escape character is ‘^]‘.
set name 0 60 5
vfast
STORED
get name

stats

 

 

 

4,0.2 安装MySQL服务端

yum -y intall mysql mysql-server
[[email protected] yum.repos.d]# service mysqld start

[[email protected] yum.repos.d]# mysql
...
mysql> grant all on *.* to [email protected]‘%‘ identified by ‘123‘;
Query OK, 0 rows affected (0.00 sec)

mysql> select user,password,host from mysql.user;
+------+-------------------------------------------+-----------------------+
| user | password | host |
+------+-------------------------------------------+-----------------------+
| root | | localhost |
| root | | localhost.localdomain |
| root | | 127.0.0.1 |
| | | localhost |
| | | localhost.localdomain |
| root | *23AE809DDACAF96AF0FD78ED04B6A265E05AA257 | % |
+------+-------------------------------------------+-----------------------+
6 rows in set (0.00 sec)

mysql> exit

 





























































































































































































































以上是关于memcache搭建的主要内容,如果未能解决你的问题,请参考以下文章

Memcache服务搭建

Memcache服务搭建

memcache搭建

Memcached搭建

memcached 搭建

搭建LNAMP环境- PHP7源码安装Memcached和Memcache拓展