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

 

 

 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

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、twemproxy-0.4.0

yum remove autoconf*

wget http://ftp.gnu.org/gnu/automake/automake-1.12.5.tar.gz

wget ftp://ftp.gnu.org/gnu/libtool/libtool-2.4.2.tar.gz

wget https://codeload.github.com/twitter/twemproxy/zip/master

 

wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz

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

 

yum install perl

tar xzvf autoconf-2.69.tar.gz

cd ./autoconf-2.69

./configure

make && make install

 

tar xzvf automake-1.12.5.tar.gz

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

 

tar xzf libtool-2.4.2.tar.gz

cd ./libtool-2.4.2

./configure

ldconfig

./configure

make && make install

 

yum install unzip

unzip master

cd twemproxy-master/

autoreconf -fvi

./configure --prefix=/usr/local/twemproxy-04/

make && make install

3、redis

tar xzvf  redis-2.6.17.tar.gz

cd ./redis-2.6.17

make

make install

 

配置文件:
10.10.42.202
[root@mtop-n02 redis-1]# cat ./redis.conf.master | grep -v ^# | grep -v ^$
daemonize yes
pidfile /data/logs/rpid_redis16391.pid
port 16391
bind 10.10.42.202
unixsocket /data/logs/redis.sock
unixsocketperm 755
timeout 0
tcp-keepalive 120
loglevel verbose
logfile /data/logs/redis/stdout16391
databases 1
save ""
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename /data/logs/redis/dump16391.rdb
dir /data/logs/redis/16391/
slave-serve-stale-data yes
slave-read-only yes
repl-ping-slave-period 8
repl-timeout 30
repl-disable-tcp-nodelay yes
slave-priority 100
requirepass 12121313131241412412412
maxclients 20000
appendonly yes
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 64
zset-max-ziplist-value 32
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

[root@mtop-n02 redis-1]# cat ./redis.conf.rdb.slave | grep -v ^# | grep -v ^$
daemonize yes
pidfile /data/logs/rpid_redis16391.pid
port 16391
bind 10.10.42.202
unixsocket /data/logs/redis-16391.sock
unixsocketperm 755
timeout 0
tcp-keepalive 120
loglevel notice
logfile /data/mtopdata/redis/stdout16391
databases 1
save 900 1
save 300 10
save 60 3000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename /data/mtopdata/redis/dump16391.rdb
dir /data/mtopdata/redis/16391/
slaveof 10.10.42.201 16390
masterauth 12121313131241412412412
slave-serve-stale-data yes
slave-read-only yes
repl-ping-slave-period 8
repl-timeout 30
repl-disable-tcp-nodelay yes
slave-priority 100
requirepass 12121313131241412412412
maxclients 20000
appendonly no
appendfsync no
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 64
zset-max-ziplist-value 32
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

[root@mtop-n02 redis-1]# cat ./redis.conf.aof.slave | grep -v ^# | grep -v ^$
daemonize yes
pidfile /data/logs/rpid_redis16391.pid
port 16391
bind 10.10.42.202
unixsocket /data/logs/redis-16391.sock
unixsocketperm 755
timeout 0
tcp-keepalive 120
loglevel notice
logfile /data/mtopdata/redis/stdout16391
databases 1
save ""
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename /data/mtopdata/redis/dump16391.rdb
dir /data/mtopdata/redis/16391/
slaveof 10.10.42.201 16390
masterauth 12121313131241412412412
slave-serve-stale-data yes
slave-read-only yes
repl-ping-slave-period 8
repl-timeout 30
repl-disable-tcp-nodelay yes
slave-priority 100
requirepass 12121313131241412412412
maxclients 20000
appendonly yes
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 64
zset-max-ziplist-value 32
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

[root@mtop-n02 redis-1]# cat ./sentinel.conf | grep -v ^# | grep -v ^$
port 26391
sentinel monitor rbmaster 10.10.42.202 16391 1
sentinel auth-pass rbmaster 12121313131241412412412
sentinel down-after-milliseconds rbmaster 20000
sentinel can-failover rbmaster yes
sentinel parallel-syncs rbmaster 1
sentinel failover-timeout rbmaster 900000

 

 

10.10.42.201:
[root@mtop-n01 redis-4]# cat ./redis.conf.master | grep -v ^# | grep -v ^$
daemonize yes
pidfile /data/logs/rpid_redis16394.pid
port 16394
bind 10.10.42.201
unixsocket /data/logs/redis-16394.sock
unixsocketperm 755
timeout 0
tcp-keepalive 0
loglevel notice
logfile /data/mtopdata/redis/stdout16394
databases 1
save ""
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename /data/mtopdata/redis/dump16394.rdb
dir /data/mtopdata/redis/16394/
slave-serve-stale-data yes
slave-read-only yes
repl-ping-slave-period 8
repl-timeout 30
repl-disable-tcp-nodelay yes
slave-priority 10
requirepass 12121313131241412412412
maxclients 20000
appendonly no
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 128
set-max-intset-entries 512
zset-max-ziplist-entries 64
zset-max-ziplist-value 32
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

[root@mtop-n01 redis-4]# cat ./redis.conf.slave | grep -v ^# | grep -v ^$
daemonize yes
pidfile /data/logs/rpid_redis16394.pid
port 16394
bind 10.10.42.201
unixsocket /data/logs/redis-16394.sock
unixsocketperm 755
timeout 0
tcp-keepalive 0
loglevel notice
logfile /data/mtopdata/redis/stdout16394
databases 1
save ""
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename /data/mtopdata/redis/dump16394.rdb
dir /data/mtopdata/redis/16394/
slaveof 10.10.42.202 16395
masterauth 12121313131241412412412
slave-serve-stale-data yes
slave-read-only yes
repl-ping-slave-period 8
repl-timeout 30
repl-disable-tcp-nodelay yes
slave-priority 10
requirepass 12121313131241412412412
maxclients 20000
appendonly no
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 128
set-max-intset-entries 512
zset-max-ziplist-entries 64
zset-max-ziplist-value 32
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

[root@mtop-n01 redis-4]# cat ./sentinel.conf | grep -v ^# | grep -v ^$               
port 26390
sentinel monitor rbmaster 10.10.42.201 16394 1
sentinel auth-pass rbmaster 12121313131241412412412
sentinel down-after-milliseconds rbmaster 20000
sentinel can-failover rbmaster yes
sentinel parallel-syncs rbmaster 1
sentinel failover-timeout rbmaster 900000

 

你可能感兴趣的:(twemproxy redis ttserver phpadmin memcache)