jboss lnmp keepalived (HA)

本文介绍如何配置JBoss应用服务器与Nginx负载均衡器,包括环境变量设置、主机配置文件调整、安全设置及集群配置。此外还涉及PHP、Redis、Node.js等组件的安装与配置。

#########################################################################################################
#####################################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

#########################################################################################################
#####################################jboss###############################################################
#########################################################################################################
1、设置环境变量:
[root@wych-1 configuration]# vi /etc/profile
export JAVA_HOME=/usr/local/jdk
export JBOSS_HOME=/usr/local/jboss
PATH=$JAVA_HOME/bin:$PATH:$HOME/bin:$JBOSS_HOME/bin

[root@wych-1 bin]# vi /etc/hosts
127.0.0.1               localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6
10.10.42.211 master wych01
10.10.42.212 wych02
10.10.42.213 wych03

2、修改master的host.xml:
[root@wych-1 configuration]# cd /usr/local/jboss/domain/configuration
[root@wych-1 configuration]# cp host-master.xml host.xml
[root@wych-1 configuration]# vi /usr/local/jboss/domain/configuration/host.xml
......

            <subsystem xmlns="urn:jboss:domain:messaging:1.4">
                <hornetq-server>
                    <!--
                    <cluster-user>jms-user</cluster-user>
                    <cluster-password>simple-pass</cluster-password>
                    <cluster-password>${jboss.messaging.cluster.password:CHANGE ME!!}</cluster-password>
                    -->
                    <security-enabled>false</security-enabled>
                    <persistence-enabled>true</persistence-enabled>
......

            <subsystem xmlns="urn:jboss:domain:messaging:1.4">
                <hornetq-server>
                    <security-enabled>false</security-enabled>
                    <persistence-enabled>true</persistence-enabled>
                    <journal-type>NIO</journal-type>
                    <journal-min-files>2</journal-min-files>
......
    <interfaces>
        <interface name="management">
            <inet-address value="${jboss.bind.address.management:10.10.42.211}"/>
        </interface>
    </interfaces>

3、启动domain:
[root@wych-1 configuration]# nohup domain.sh &

4、登陆控制台:
http://10.10.42.211:9990/console

Welcome to EAP 6
The Enterprise Application Platform 6 is running.
However you have not yet added any users to be able to access the admin console.

To add a new user execute the add-user.sh script within the bin folder of your EAP 6 installation and enter the requested information.

By default the realm name used by EAP is "ManagementRealm" this is already selected by default.

After you have added the user follow this link to Try Again.

5、设置控制台密码:
[root@wych-1 bin]# cd /usr/local/jboss/bin/
[root@wych-1 bin]# ./add-user.sh
What type of user do you wish to add?
 a) Management User (mgmt-users.properties)
 b) Application User (application-users.properties)
(a): a
To represent the user add the following to the server-identities definition <secret value="VGVzdF8xMjM0" />     //很重要的东西,添加节点是要用的,一定要记录下来

6、重新登陆控制台:
http://10.10.42.211:9990/console

7、添加host control
7.1、创建用户
[root@wych-1 local]# add-user.sh wych02 Test_1234
Added user 'wych02' to file '/usr/local/jboss/standalone/configuration/mgmt-users.properties'
Added user 'wych02' to file '/usr/local/jboss/domain/configuration/mgmt-users.properties'
[root@wych-1 local]# add-user.sh wych03 Test_1234
Added user 'wych03' to file '/usr/local/jboss/standalone/configuration/mgmt-users.properties'
Added user 'wych03' to file '/usr/local/jboss/domain/configuration/mgmt-users.properties'
7.2、修改配置文件
[root@wych-2 configuration]# vi ./host.xml
<host name="wych02" xmlns="urn:jboss:domain:1.5">

    <management>
        <security-realms>
            <security-realm name="ManagementRealm">
                <server-identities>
                     <!-- Replace this with either a base64 password of your own, or use a vault with a vault expression -->
                     <secret value="VGVzdF8xMjM0"/>
                </server-identities>
......
    <domain-controller>
       <remote host="${jboss.domain.master.address:10.10.42.211}" port="${jboss.domain.master.port:9999}" security-realm="ManagementRealm"/>
    </domain-controller>
......
    <interfaces>
        <interface name="management">
            <inet-address value="${jboss.bind.address.management:10.10.42.212}"/>
        </interface>
        <interface name="public">
           <inet-address value="${jboss.bind.address:10.10.42.212}"/>
        </interface>
        <interface name="unsecure">
            <!-- Used for IIOP sockets in the standard configuration.
                 To secure JacORB you need to setup SSL -->
            <inet-address value="${jboss.bind.address.unsecure:10.10.42.212}"/>
        </interface>
    </interfaces>

 

 


[dom ain@ localhost:9999 /] EAP_HOME/bin/jboss-cli.sh
[dom ain@ localhost:9999 /] /host=master:shutdown
[dom ain@ localhost:9999 /] /server-group=main-server-group:start-servers
[dom ain@ localhost:9999 /] /server-group=main-server-group:stop-servers
[dom ain@ localhost:9999 /] /host=master/server-config=server-one:start
[dom ain@ localhost:9999 /] /host=master/server-config=server-one:stop
[dom ain@ localhost:9999 /] quit
[disconnected /] connect
$ EAP_HOME/bin/jbo ss-cli .sh --connect
$ EAP_HOME/bin/jbo ss-cli .sh --connect --controller= 192.168.0.1:9999
[standalone@ localhost:9999 /] deploy --help
[standalone@ localhost:9999 /] history
[standalone@ localhost:9999 /] history --clear

#########################################################################################################
#####################################nginx###############################################################
#########################################################################################################
//查看nginx编译参数:/usr/local/nginx/sbin/nginx -V
//查看apache编译参数:cat /usr/local/apache2/build/config.nice
//查看mysql编译参数:cat /usr/local/mysql/bin/mysqlbug | grep CONFIGURE_LINE
//查看php编译参数:/usr/local/php/bin/php -i | grep configure
//[root@localhost sbin]# ./nginx -V
//nginx version: nginx/0.8.55
//built by gcc 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC)
//configure arguments: --prefix=/usr/local/nginx --with-pcre=/opt/pcre-8.35 --with-http_realip_module --without-http-cache
tar xzvf pcre-8.35.tar.gz
cd ./pcre-8.35
make && make install
tar xzvf nginx-0.8.55.tar.gz
cd ./nginx-0.8.55
./configure --prefix=/usr/local/nginx --with-pcre=/opt/pcre-8.35 --with-http_realip_module --without-http-cache
make && make install

vi /usr/local/nginx/conf/nginx.conf

http {
    include       mime.types;
    default_type  application/octet-stream;

    upstream  myapp {
       # server 10.10.42.6:9000 weight=1;
        server 10.10.7.60:9002 weight=1;
        server 10.10.7.60:9003 weight=1;
        }

  # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        location ~ \.php$ {
            root           html;   ################修改为绝对路径时表示在php环境下绝对路径
            #fastcgi_pass   10.10.7.60:9001;
            fastcgi_pass   myapp;
            fastcgi_index  index.php;
            #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;      #####$document_root 为root定义路径
            include        fastcgi_params;
        }


#########################################################################################################
#####################################php#################################################################
#########################################################################################################
## Mysql 开发库
yum install libxml2
yum install libxml2-devel -y
yum install mysql-devel

######安装PHP的mcrypt扩展需提前安装mcrypt库,下载Libmcrypt,mhash,mcrypt安装包#####
源码编译安装
1、先安装Libmcrypt
[root@php1 opt]# tar xvf libmcrypt-2.5.8.tar.bz2
#cd libmcrypt-2.5.8
#./configure
#make
#make install 说明:libmcript默认安装在/usr/local
2、安装mhash
#tar -zxvf mhash-0.9.9.9.tar.gz
#cd mhash-0.9.9.9
#./configure
#make
#make install
3、安装mcrypt
#tar -zxvf mcrypt-2.6.8.tar.gz
#cd mcrypt-2.6.8
#LD_LIBRARY_PATH=/usr/local/lib ./configure
#make
#make install

###编译安装PHP###
###--prefix=/usr/local/php 设置安装路径,本案例安装在/usr/local/webserver/php
###--with-config-file-path=/usr/local/php/etc 指定配置文件php.ini地址
###--with-mysql=/usr/local/mysql 启用mysql支持
cd /opt/php-5.3.28  (执行PHP编译的过程可能出现找不到mysql模块文件)
cp /usr/lib64/mysql/libmysqlclient.so* /usr/lib/

#tar -zxvf php-5.3.28.tar.gz
#cd php-5.3.28
#./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/bin/mysql --with-mysqli=/usr/bin/mysql_config --with-iconv-dir \
--with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml \
--disable-rpath --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop \
--enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex  --enable-fpm  \
--enable-mbstring  --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip \
--enable-soap --without-pear --with-gettext --with-mcrypt
#make
#make install

vi /usr/local/php/etc/php-fpm.conf
listen = 10.10.7.60:9000
/usr/local/php/sbin/php-fpm

#########################################################################################################
#####################################rhongx##############################################################
#########################################################################################################

http://10.10.16.88/data/mango/SoftManage/CodeGroup/source/TOPGroup/SOURCE/service/rhongx-src
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

cd pcre-8.10
./configure
make && make install
cd lua-5.1.5
make install
wget http://luarocks.org/releases/luarocks-2.1.1.tar.gz
tar xzvf luarocks-2.1.1.tar.gz
cd luarocks-2.1.1
./configure
make && make install

luarocks list
luarocks install md5
luarocks install lbase64
luarocks install lua-cjson
luarocks install lua-iconv
luarocks install luacrypto
[root@wych00 ~]#  yum install expat-devel    
[root@wych00 ~]#  luarocks install luaexpat
luarocks install lluasoap
luarocks install luasocket
luarocks install luaxml
[root@wych00 ~]# yum install libzip-devel.x86_64
[root@wych00 ~]# luarocks install lzlib ZLIB_INCDIR=/usr/include/ ZLIB_LIBDIR=/usr/lib64/
[root@wych00 ~]# yum install mysql-devel mysql
[root@wych00 ~]# luarocks install luasql-mysql MYSQL_INCDIR=/usr/include/mysql MYSQL_LIBDIR=/usr/lib64/mysql
[root@wych00 ~]# luarocks list
cd rhongx-src/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
cd /usr/local/webserver/rhongx/
/usr/local/webserver/rhongx/sbin/nginx -t -c /data/sgcore/ngx/cfg/sg.ngx.conf
/usr/local/webserver/rhongx/sbin/nginx  -c /data/sgcore/ngx/cfg/sg.ngx.conf
ps -ef | grep "nginx: master process" | grep -v "grep" | awk -F ' ' '{print $2}'|xargs kill -HUP

 

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

#########################################################################################################
#####################################redis安装###########################################################
#########################################################################################################
wget http://download.redis.io/releases/redis-2.6.17.tar.gz
[root@wych00 redis-2.6.17]# cd /opt/ ; tar xzvf redis-2.6.17.tar.gz
[root@wych00 redis-2.6.17]# cd /opt/redis-2.6.17
[root@wych00 redis-2.6.17]# make && make install
[root@wych00 redis-2.6.17]# mkdir /data/logs/redis/6399 -p
[root@wych00 redis-2.6.17]# /opt/redis-2.6.17/src/redis-server /data/sgcore/ngx/cfg/sg.aof.conf
[root@wych00 redis-2.6.17]# /opt/redis-2.6.17/src/redis-cli -p 6399
[root@wych00 redis-2.6.17]# /opt/redis-2.6.17/src/redis-cli -p 6399 -a 142ffb5bfa1-cn-jijilu-dg-a75
[root@wych00 redis-2.6.17]# redis 127.0.0.1:6399> set foo bar
OK
[root@wych00 redis-2.6.17]# redis 127.0.0.1:6399> get foo
"bar"

#########################################################################################################
#####################################node.js安装#################################################################
#########################################################################################################
使用  yum install gcc gcc-c++ autoconf automake 来安装编译环境;
先检查是否安装python,并且python的版本需要在2.6以上
运行命令python –V查看当前python版本如果没安装运行以下步骤:
(A) 在以下网址下载(http://www.python.org/ftp/python/)对应的python的安装包;
(B) 下载完成后,解压python(命令:tar xzf Python-2.X.X.tgz),进入python安装程序目录(命令:cd Python-2.X.X);
(C) 编译安装python,按顺序执行以下命令:
 ./configure --prefix=/usr/local/python2.X;
make;
make install;
 安装node
(A)下载nodejs到本地并解压缩
wget http://nodejs.org/dist/v0.10.21/node-v0.10.21.tar.gz
tar zxvf node-v0.10.21.tar.gz
(B)进入到该目录编译和安装
cd node-v0.10.21
./configure --prefix=/usr/local/node/0.10.21
这样指定安装在/usr/local/node/0.10.21目录下
make
make install

3).配置NODE_HOME
[root@node-v0.9.0]# vi /etc/profile
在export PATH USER 。。。一行的上面添加如下内容,并将NODE_HOME/bin设置到系统path中
#set for nodejs
export NODE_HOME=/usr/local/node/0.9.0
export PATH=$NODE_HOME/bin:$PATH
保存退出后执行如下命令,使刚才的配置生效
[root@node-v0.9.0]# source /etc/profile

2、环境安装
 修改程序包中的config/BaseConfig.js中的数据库连接;
 在程序包根目录下运行npm install,安装必需的包;
 安装包完成后,运行node run.js运行程序。

 

 


#########################################################################################################
#####################################常用配置文件及启动方法##############################################
#########################################################################################################
服务网关(HA)机器常用配置及启动命令:
[root@rhong1 ~]# vi /data/sgcore/ngx/src/usgateway/core.lua    (服务网管超时时间设置点)
[root@rhong1 ~]# vi /data/sgcore/ngx/src/usgateway/init.lua    (服务网管连接读数据设置)
[root@rhong1 ~]# vi /data/sgcore/ngx/cfg/sg.ngx.conf    (rhongx配置文件)
[root@rhong1 ~]# vi /data/sgcore/ngx/cfg/sg.aof.conf    (redis配置文件)
[root@rhong1 ~]# vi /etc/keepalived/keepalived.conf     (keepalived配置文件)
[root@rhong1 ~]# /opt/redis-2.6.17/src/redis-server /data/sgcore/ngx/cfg/sg.aof.conf  (默认只在130.58上启动)
[root@rhong2 ~]# /usr/local/webserver/rhongx/sbin/nginx -c /data/sgcore/ngx/cfg/sg.ngx.conf
[root@rhong2 ~]# service keepalived start

业务网关(HA)机器常用配置及启动命令:
[root@rhong1 ~]# vi /etc/keepalived/keepalived.conf     (keepalived配置文件)
[root@ngx2 ~]# vi /usr/local/nginx/conf/nginx.conf      
[root@rhong2 ~]# service keepalived start
[root@ngx2 ~]# /usr/local/nginx/sbin/nginx
[root@ngx2 ~]# /usr/local/nginx/sbin/nginx -s stop

PHP(AA)机器常用配置及启动命令:
[root@php1 ~]# vi /usr/local/php/etc/php-fpm.conf
[root@php1 ~]# /usr/local/php/sbin/php-fpm

PHP(AA)发布:
[root@php1 scripts]# vi /scripts/config/database.php  (php连接数据库配置文件)
[root@php1 ~]# cd /scripts/    (发布php文件)

[root@php1 scripts]# cd /nodejs/spider/    (nodejs部署文件路径)
[root@php1 scripts]# vi /nodejs/spider/ticket/config/BaseConfig.js (连接读数据)
[root@php1 scripts]# vi /nodejs/spider/tour/config/BaseConfig.js   (连接写数据)

 

#########################################################################################################
#####################################Memcache##############################################
#########################################################################################################

Memcache的安装、配置如下:
/usr/local/webserver/php/ 这个php的安装路径要根据服务器的安装路径做修改。

wget http://pecl.php.net/get/memcache-2.2.7.tgz
./configure --enable-memcache --with-php-config=/usr/local/webserver/php/bin/php-config -with-zlib-dir
make
make install

在 php.ini 文件添加
[memcache]
extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/"
extension=memcache.so

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值