살며사랑하며

centos tomcat redis3 clustering connect 본문

OS/LINUX

centos tomcat redis3 clustering connect

drawhan 2016. 7. 20. 10:11

tomcat - redis culster - session - replication


1. redis cluster


install centos 7


yum update -y


sudo systemctl set-default multi-user.target


#selinux off


sudo vi /etc/sysconfig/selinux

#SELINUX=enforcing 을 SELINUX=disabled 로 변경후 저장한다.

SELINUX=disabled



sudo yum install -y gcc epel-release java-1.8.0-openjdk lrzsz telnet htop wget  automake cronie network-tools ruby g++ make automake autoconf curl-devel openssl-devel zlib-devel

sudo yum install -y  ruby-rdoc ruby-devel rubygems tcl

gem install redis


sudo firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4"  source address="10.0.0.0/24"  accept"


sudo firewall-cmd --reload

sudo firewall-cmd --list-all


sudo hostnamectl set-hostname drawhanredis1


hostname


sudo vi /etc/hosts

10.0.0.151    drawhanredis1

10.0.0.152    drawhanredis2

10.0.0.153    drawhanredis3


10.0.0.161    drawhanweb1

10.0.0.162    drawhanweb2

10.0.0.163    drawhanwas1

10.0.0.164    drawhanwas2

10.0.0.165    drawhanmobile1

10.0.0.166    drawhanmobile2

10.0.0.167    drawhanmobile3

10.0.0.168    drawhanwcms1

10.0.0.169    drawhanwcms2


mkdir ~/src ; cd ~/src; wget hdrawhan://download.redis.io/releases/redis-3.2.1.tar.gz ; tar xvzf redis-3.2.1.tar.gz

make test; make ; make install;


~/src/redis-3.2.1/utils/install_server.sh


src/redis-trib.rb create --replicas 1 172.16.0.151:7000 172.16.0.152:7001 172.16.0.153:7000 172.16.0.151:7001 172.16.0.152:7000 172.16.0.153:7001



2. apache 설치


install centos 7


yum update -y


sudo yum install -y gcc epel-release java-1.8.0-openjdk lrzsz telnet htop wget automake cronie network-tools g++ make automake autoconf curl-devel openssl-devel zlib-devel


sudo systemctl set-default multi-user.target


#selinux off


sudo vi /etc/sysconfig/selinux

#SELINUX=enforcing 을 SELINUX=disabled 로 변경후 저장한다.

SELINUX=disabled


sudo yum install -y hdrawhand hdrawhand-devel


#mod_ajp_proxy balancer configure

sudo vi /etc/hdrawhand/conf.d/virtual.conf


nameVirtualHost *:80

<Proxy balancer://drawhanCluster>

        Order deny,allow

        Allow from all


        BalancerMember ajp://drawhanwas1:9002

        BalancerMember ajp://drawhanwas2:9002

        ProxySet lbmethod=bytraffic

</Proxy>


<VirtualHost *:80>

        ServerName drawhanwas1


        #ProxyPreserveHost On


        ProxyPass / balancer://drawhanCluster/

        ProxyPassReverse / balancer://drawhanCluster/


        #ProxyPass / ajp://drawhanwas1:9002/

        #ProxyPassReverse / ajp://drawhanwas1:9002/

</VirtualHost>



3.tomcat 설치


install centos 7


yum update -y


sudo yum install -y gcc epel-release java-1.8.0-openjdk lrzsz telnet htop wget automake cronie network-tools g++ make automake autoconf curl-devel openssl-devel zlib-devel


sudo systemctl set-default multi-user.target


#selinux off


sudo vi /etc/sysconfig/selinux

#SELINUX=enforcing 을 SELINUX=disabled 로 변경후 저장한다.

SELINUX=disabled


#tomcat download

wget hdrawhan://apache.tt.co.kr/tomcat/tomcat-8/v8.0.36/bin/apache-tomcat-8.0.36.zip

unzip apache-tomcat-8.0.36.zip

mv apache-tomcat-8.0.36 tomcat8

sudo mv tomcat8 /usr/share

sudo chown -R drawhan.drawhan /usr/share/tomcat8


vi /usr/share/tomcat8/conf/context.xml


<!-- 주석처리 -->

<!-- <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" /> -->

<!-- 추가 -->

<Valve className="com.r.tomcat.session.management.RequestSessionHandlerValve" />

<Manager className="com.r.tomcat.session.management.RequestSessionManager" />


#redis config 추가

vi /usr/share/tomcat8/conf/RedisDataCache.properties


# redis hosts ex: 127.0.0.1:6379, 127.0.0.2:6379, 127.0.0.2:6380, ....

redis.hosts=drawhanredis1:7000, drawhanredis2:7001, drawhanredis3:7000

# Redis Password

redis.password=

# set true to enable redis cluster mode

redis.cluster.enabled=true


#lib 추가 ( hdrawhans://github.com/ran-jit/TomcatClusterRedisSessionManager )

cp TomcatClusterEnabledRedisSessionManager-1.0.jar  /usr/share/tomcat8/lib