首页 > 代码库 > ??twemproxy redis ttserver phpadmin memcache

??twemproxy redis ttserver phpadmin memcache

1.system update

LANG=C

yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers


2. pcre install
//path:pcre-8.10

./configure

make && make install


3. Lua install
//path:lua-5.1.5

make install

4.luarocks install
//path:luarocks-2.1.0

./configure
make && make install

5.lua extension install
yum install expat-devel

luarocks install lbase64
luarocks install lua-cjson
luarocks install lua-iconv
luarocks install luacrypto
luarocks install luaexpat
luarocks install luasocket
luarocks install luasql-mysql
luarocks install luaxml

//download zlib and install
luarocks install lzlib
luarocks install md5


//more see:http://rhomobi.com/topics/186

# library for connectting to mysql
yum install mysql-devel
luarocks install luasql-mysql MYSQL_INCDIR=/usr/include/mysql MYSQL_LIBDIR=/usr/lib64/mysql

6.rhongx install
//path:src
useradd www
./configure --user=www --group=www --prefix=/usr/local/webserver/rhongx --with-http_stub_status_module --with-http_ssl_module --with-debug --with-http_gzip_static_module --without-mail_pop3_module --without-mail_imap_module --without-http_uwsgi_module --without-http_scgi_module --without-http_ssi_module --add-module=../lua-nginx-module-0.6.10 --add-module=../ngx_devel_kit-0.2.17 --add-module=../memc-nginx-module --add-module=../srcache-nginx-module --add-module=../echo-nginx-module --add-module=../ngx_cache_purge-1.6 --add-module=../evanmiller-nginx_upstream_hash-2580b21 --add-module=../nginx-gridfs --add-module=../nginx_upload_module-2.2.0 --add-module=../masterzen-nginx-upload-progress-module-82b35fc --add-module=../nginx-accesskey-2.0.3 --add-module=../set-misc-nginx-module --add-module=../iconv-nginx-module

make && make install
7.update /etc/sysctl.conf

# Disable netfilter on bridges.
#net.bridge.bridge-nf-call-ip6tables = 0
#net.bridge.bridge-nf-call-iptables = 0
#net.bridge.bridge-nf-call-arptables = 0

# Add
net.ipv4.tcp_max_syn_backlog = 65536
net.core.netdev_max_backlog =  32768
net.core.somaxconn = 32768

net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216

net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2

net.ipv4.tcp_tw_recycle = 1
#net.ipv4.tcp_tw_len = 1
net.ipv4.tcp_tw_reuse = 1

net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_max_orphans = 3276800
#
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 120
net.ipv4.ip_local_port_range = 1024  65535

#Redis2.6.17need
vm.overcommit_memory = 1

# End

8. start Redis
mkdir /data/logs/redis/6399 -p
/opt/redis-2.6.17/src/redis-server /data/sgcore/ngx/cfg/sg.aof.conf

9. start rhongx
/usr/local/webserver/rhongx/sbin/nginx -t -c /data/sgcore/ngx/cfg/ly.ngx.conf
/usr/local/webserver/rhongx/sbin/nginx  -c /data/sgcore/ngx/cfg/ly.ngx.conf

#access  http://sg1.mangocity.com/api/pdb/SceneryDetail/321/  405 Not Allowed

10. restart rhongx
ps -ef | grep "nginx: master process" | grep -v "grep" | awk -F ‘ ‘ ‘{print $2}‘
kill -HUP ‘pid number‘

11、twemproxy-0.4.0
yum remove autoconf*
autoconf-2.69.tar.gz
automake-1.12.5.tar
libtool-2.4.2.tar.xz
twemproxy-0.4.0.tar.gz
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
tar xzvf autoconf-2.69.tar.gz
cd ./autoconf-2.69
./configure
make
make install
tar xzvf automake-1.12.5.tar.xz
xz -d automake-1.12.5.tar.xz
tar xf automake-1.12.5.tar
cd ./automake-1.12.5
./configure
make
make install
xz -d libtool-2.4.2.tar.xz
tar xf libtool-2.4.2.tar
cd ./libtool-2.4.2
./configure
make
make install
cd ../twemproxy-0.4.0
autoreconf -fvi
./configure --prefix=/usr/src/twemproxy4
make
make install

[root@slave1 twemproxy-0.4.0]# cd /usr/src/twemproxy4/
[root@slave1 twemproxy4]# ll
total 8
drwxr-xr-x 2 root root 4096 Dec 19 13:25 sbin
drwxr-xr-x 3 root root 4096 Dec 19 11:38 share
[root@slave1 twemproxy4]# mkdir run conf
[root@slave1 twemproxy4]# cd ./conf/
[root@slave1 conf]# vim nutcracker.yml  

alpha:
  listen: 10.10.130.93:61390
  hash: fnv1a_64
  distribution: ketama
  auto_eject_hosts: true
  redis: true
  redis_auth: redispassword
  server_retry_timeout: 2000
  server_failure_limit: 1
  servers:
   - 10.10.42.93:6390:1
   - 10.10.42.93:6392:1
   - 10.10.42.93:6394:1


gamma:
  listen: 10.10.130.93:61978
  hash: fnv1a_64
  distribution: ketama
  backlog: 1024
  auto_eject_hosts: true
  server_retry_timeout: 3000
  server_failure_limit: 3
  servers:
   - 10.10.42.93:1978:1
   - 10.10.42.93:2978:1
   - 10.10.42.93:3978:1
   - 10.10.42.93:4978:1

 启动twemproxy服务

nutcracker -t 测试配置文件nutcracker -d -c /usr/src/twemproxy/conf/nutcracker.yml -p /usr/src/twemproxy/run/redisproxy.pid -o /usr/src/twemproxy/run/redisproxy.log

nutcracker用法与命令选项

Usage: nutcracker [-?hVdDt] [-v verbosity level] [-o output file][-c conf file] [-s stats port] [-a stats addr][-i stats interval] [-p pid file] [-m mbuf size]

Options:
-h, –help                        : 查看帮助文档,显示命令选项
-V, –version                   : 查看nutcracker版本
-t, –test-conf                  : 测试配置脚本的正确性
-d, –daemonize              : 以守护进程运行
-D, –describe-stats         : 打印状态描述
-v, –verbosity=N            : 设置日志级别 (default: 5, min: 0, max: 11)
-o, –output=S                 : 设置日志输出路径,默认为标准错误输出 (default: stderr)
-c, –conf-file=S               : 指定配置文件路径 (default: conf/nutcracker.yml)
-s, –stats-port=N            : 设置状态监控端口,默认22222 (default: 22222)
-a, –stats-addr=S            : 设置状态监控IP,默认0.0.0.0 (default: 0.0.0.0)
-i, –stats-interval=N       : 设置状态聚合间隔 (default: 30000 msec)
-p, –pid-file=S                 : 指定进程pid文件路径,默认关闭 (default: off)
-m, –mbuf-size=N          : 设置mbuf块大小,以bytes单位 (default: 16384 bytes)

 

12、ttserver
wget http://fallabs.com/tokyocabinet/tokyocabinet-1.4.46.tar.gz
wget http://jaist.dl.sourceforge.net/project/tokyocabinet/tokyotyrant/1.1.33/tokyotyrant-1.1.33.tar.gz 
tar zxvf tokyocabinet-1.4.46.tar.gz
cd tokyocabinet-1.4.46 
./configure --prefix=/usr/local/tokyocabinet
make
make install
tar zxvf tokyotyrant-1.1.33.tar.gz
cd tokyotyrant-1.1.33
./configure  --prefix=/usr/local/ttserver/ --with-tc=/usr/local/tokyocabinet/ 
make  
make install
/usr/src/ttserver/bin/ttserver -host 10.10.42.201 -port 42201 -thnum 8 -dmn -pid /data/ttserver/ttserver42201.pid -log /data/ttserver/log/ttserver42201.log -le -ulog /data/ttserver/ulog/ -ulim 128m -sid 42201 -mhost 10.10.42.202 -mport 42202 -rcc -rts /data/ttserver/data/ttserver.rts /data/ttserver/data/database.tch#bnum=10000
/usr/src/ttserver/bin/ttserver -host 10.10.42.202 -port 42202 -thnum 8 -dmn -pid /data/ttserver/ttserver42202.pid -log /data/ttserver/log/ttserver42202.log -le -ulog /data/ttserver/ulog/ -ulim 128m -sid 42202 -mhost 10.10.42.201 -mport 42201 -rcc -rts /data/ttserver/data/ttserver.rts /data/ttserver/data/database.tch#bnum=10000

13、redis
wget https://github.com/antirez/redis/archive/3.0.0-rc1.tar.gz
tar xzvf 3.0.0-rc1.tar.gz
mv redis-3.0.0-rc1 /usr/src/redis3-0

 

 

??twemproxy redis ttserver phpadmin memcache