linux搭建memcached
- 首先我们的服务器上安装好memcached,下面是安装步骤
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65一. 安装步骤
1.1 安装libevent,当前最新版本为2.1.8,官网:http://libevent.org/
wget https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz
1.2 解压
tar -xvf libevent-2.1.8-stable.tar.gz
1.3 进入目录
cd libevent-2.1.8-stable
1.4 安装
./configure
make
sudo make install
1.5 /usr/local/lib目录下就会有如下文件
二. Memcached安装
2.1 当前最新版本:memcached-1.5.8.tar.gz,官网:http://memcached.org/
wget http://www.memcached.org/files/memcached-1.5.8.tar.gz
2.2 解压
tar -xvf memcached-1.5.8.tar.gz
2.3 进入目录
cd memcached-1.5.8
2.4 配置、编译和安装
./configure --prefix=/usr/local/memcached
make & make test
sudo make install
2.5 安装目录
/usr/local/memcached/bin/memcached
2.6 设置环境变量
vim ~/.bashrc
2.7 光标移植篇末,按下字母"i"进入编辑模式,输入如下命令.
注:=前后不能有空格,否则设置无效。
2.8 按Esc后,输入":wq"保存退出,然后更新设置的环境变量
source ~/.bashrc
2.9 运行
memcached -p 11211 -m 64M -u root -d
三. 安装及运行过程问题
3.1 can't run as root without the -u switch
解决方法:需要指定用户,-u root
/usr/local/memcached/bin/memcached -p 11211 -m 64M -u root -d
3.2 /usr/local/memcached/bin/memcached: error while loading shared libraries: libevent-2.1.so.6: cannot open shared object file: No such file or directory
解决方法:
Unbuntu下执行:ln -s /usr/local/lib/libevent-2.1.so.6 /usr/lib/libevent-2.1.so.6
CentOS下执行:ln -s /usr/local/lib/libevent-2.1.so.6 /usr/lib64/libevent-2.1.so.6
memcached如何查看memcached服务是否启动
1 | telnet 127.0.0.1 11211 |
memcached如何开启远程访问并修改端口号
1 | 博主在/etc/init.d/memcached下有对于memcached的配置文件 |
memcached启动后本地进行telnet访问失败
1 | 原因一:机器没有安装telnet服务。 |