快捷搜索:  

架设某大型网站服务器之全部过程(2)

客服端测试:

nslookup --type=a xxxx.com x.x.x.x(网通任意一个DNS服务器IP)

nslookup --type=a xxxx.com x.x.x.x(电信任意一个DNS服务器IP)

看到的为配置文件中对应ip则解析配置正常.

注意:

上面的xxxxx.com需要修改DNS解析服务器为

ns.xxxxx.com

对应IP为:网通IP.

备注:

1).在这里做了网通与非网通的访问控制,用于实现南北互通,如要国内外互通,需要在列出一个相应的访问控制列表ACL就可以实现了.

2).关于使用tar包编译安装请参看Linux how-to.

4.配置LAJO

软件:

            Apache2.0.58

            JBOSS.4.0.3SP1

            oracle9.2.0.4

            Mod-jk1.12

            配置:

            1)apache mod-jk

            #tar zxvf httpd-2.0.58.tar.gz

            #cd httpd-2.0.58

            #./configure --enable-MODULE=shared --enable-so --with-mpm=worker

            #make&&make install

            #tar zxvf jakarta-tomcat-connectors-1.2.14.1-src.tar.gz

            #cd /home/software/jakarta-tomcat-connectors-1.2.14.1-src/jk/native

            # ./configure --with-apxs=/usr/local/apache2/bin/apxs

            #make

            # cp ./apache-2.0/mod_jk.so /usr/local/apache2/modules

httpd.conf的修改

该文件的路径位于$APACHE-HOME/conf

上述编译过程中我们选用的worker模式,因此我们将修改worker模块的配置

<IfModule worker.c>

StartServers 4 #最初建立进程的数量

ServerLimit 24 #进程建立的最大数量,硬限制

ThreadLimit 128 #每一进程能创建线程的最大数量,硬限制,该参数建议#和ThreadsPerChild一致,如果ThreadLimit > ThreadsPerChild的话,会造成不##必要的内存消耗。

MaxClients 3072 #同时可以得到处理的客户端的最大数量

MinSpareThreads 100 #所有进程中空闲线程的总数最小数值

MaxSpareThreads 200 #所有进程中空闲线程的总数最大数值

ThreadsPerChild 128 #每个子进程可以建立的固定数量的线程

MaxRequestsPerChild 0 #用于控制服务器建立和结束进程的频率,为0表示没有#限制,但在solaris OS下该值可能会出错,可以设置为1000或2000。根据系统#的并发负载吧。

</IfModule>

同时修改与新增httpd.conf如下内容:



Include conf/mod_jk2.conf

User xxxx

Group 5dxc

DocumentRoot "/site"

<Directory "/site">

NameVirtualHost IP:80

<VirtualHost IP:80>

ServerAdmin foway@163.com

DocumentRoot /site

ServerName IP

ErrorLog logs/ip-error_log

CustomLog logs/ip-access_log common

</VirtualHost>

<VirtualHost IP:82>

ServerAdmin foway@163.com

DocumentRoot /var/www/html

ServerName admin.xxxx.com

ErrorLog logs/ip-error_log

CustomLog logs/ip-access_log common

</VirtualHost>

#vi $APACHE-HOME/conf/mod_jk2.conf

            ////////////////////////文件内容开始///////////////////

            LoadModule jk_module modules/mod_jk.so

            JkWorkersFile conf/workers2.properties

            JkLogFile logs/mod_jk.log

            # Set the jk log level [debug/error/info]

            JkLogLevel info

            # Select the log format

            JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

            # JkOptions indicate to send SSL KEY SIZE,

            JkOptions  ForwardKeySize  ForwardURICompat -ForwardDirectories

            # JkRequestLogFormat set the request format

            JkRequestLogFormat "%w %V %T"

            JkMount /* loadbalancer

            #apache will serve the static picture.

            #以下命令意味着所有的图片与htm,css,js页面将由APACHE解析其它交由jboss处理

            JkUnMount /*.jpg loadbalancer

            JkUnMount /*.gif loadbalancer

            JkUnMount /*.swf loadbalancer

            JkUnMount /*.bmp loadbalancer

            JkUnMount /*.png loadbalancer

            JkUnMount /*.js loadbalancer

            JkUnMount /*.css loadbalancer

            JkUnMount /*.htm loadbalancer

            ////////////////////////文件内容结束///////////////////

            #vi $APACHE-HOME/conf/ uriworkermap.properties

            ////////////////////////文件内容开始///////////////////

            /jmx-console=loadbalancer

            /jmx-console/*=loadbalancer

            /web-console=loadbalancer

            /web-console/*=loadbalancer

            ////////////////////////文件内容结束///////////////////

            #vi $APACHE-HOME/conf/uriworkermap.properties

            ////////////////////////文件内容开始///////////////////

            worker.list=loadbalancer,status

            worker.node1.port=8009

            worker.node1.host=192.168.0.192(请填写服务器的IP)

            worker.node1.type=ajp13

            worder.node1.lbfactor=1

            worker.node1.cachesize=10

            worker.node2.port=8009

            worker.node1.host=localhost

            worker.node1.type=ajp13

            worder.node1.lbfactor=1

            worker.node1.cachesize=10

            worker.loadbalancer.type=lb

            worker.loadbalancer.balance_workers=node1,node2

            worker.loadbalancer.sticky_session=1

            worker.status.type=status

            ////////////////////////文件内容结束///////////////////

            注意:如果需要负载:修改

            worker.node2.port=8009

            worker.node1.host=localhost

            worker.node1.type=ajp13

            worder.node1.lbfactor=1

            worker.node1.cachesize=10

            为:

            worker.node2.port=8009

            worker.node2.host=IP(进行负载的IP地址)

            worker.node2.type=ajp13

            worder.node2.lbfactor=1

            worker.node2.cachesize=10

            备注:如果要进行更多的负载….

            修改:

            worker.noden.port=8009

            worker.noden.host=IP(进行负载的IP地址)

            worker.noden.type=ajp13

            worder.noden.lbfactor=1

            worker.noden.cachesize=10

            worker.loadbalancer.balance_workers=node1,node2,noden
2)jboss安装.

Jboss4.0.3sp1 解压到/site/jboss目录下….

            …./ deploy/jbossweb-tomcat55.sar/server.xml中,找8080,修改为8088

            Jdk环境变量设定:

            Jdk安装:

            #chmod 755 jdk-1_5_0_06-linux-i586.bin

            #./jdk-1_5_0_06-linux-i586.bin

            Java参数设置:

            #ln –s /usr/local/jdk1.5.0_06 /usr/local/jdk

            如果你下载的是rpm包请如下操作

            #./jdk-1_5_0_06-linux-i586.rpm.bin

            #rpm jdk-1_5_0_06-linux-i586.rpm

            # ln –s /usr/ jdk1.5.0_06 /usr/local/jdk

            #vi /etc/profile.d/java.sh

            ////////////////////////文件内容///////////////////

            JAVA_HOME=/usr/local/jdk

            PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$CATALINA_HOME/bin

            export JAVA_HOME PATH

            ////////////////////////文件内容///////////////////


3) apache jboos服务启动问题

apache jboss整合配置已完毕.下面是启动这些服务了.

            ..用户与权限分配

            groupadd –g 5500 xxxx

            adduser -u 5500 -s /bin/false -d /bin/null -c "proftpd user" -g xxxx xxxx

            修改/etc/passwd文件中的xxxx用户中的”/bin/false”为”/bin/bash”,以便于以后jboss使用.当然你也可以这样做:

            adduser -u 5500 -s /bin/bash -d /bin/null -c "proftpd user" -g xxxx xxxx

            chown xxxx /site/* –R

            chgrp xxxx /site/* -R

            chmod 755 /site/* -R

            ..服务启动

            添加如下内容到/etc/rc.local

            /usr/local/apache2/bin/apachectl start

            /etc/init.d/jboss start

            #vi /etc/init.d/jboss

            ////////////////////////文件内容开始///////////////////

            #/etc/init.d/jboss

            /etc/rc.d/init.d/functions

            JBOSS_HOME=/site/jboss

            export JBOSS_HOME

            JAVA_HOME=/usr/local/jdk

            export JAVA_HOME

            PATH=$PATH:$JAVA_HOME/bin

            export PATH

            CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

            export CLASSPATH

            prog="jboss"

            start()

            {

            #Input the jbos Service log into jboss.log

            echo "Jboss4.0.3SP1 Service Starting........" >>/var/log/xxxx/jboss.log

            echo "-----------------------------------------------" >>/var/log/xxxx/jboss.log

            date " %Y-%m-%d %A %T :Jboss Service start" >>/var/log/xxxx/jboss.log

            echo "-----------------------------------------------" >>/var/log/xxxx/jboss.log

            su - xxxx -c $JBOSS_HOME/bin/run.sh & >>/var/log/xxxx/jboss.log

            touch /var/log/xxxx/jboss.log

            }

            #Function stop,Stop the Jboss Service auto

            #when the Linux Halt

            stop()

            {

            #Input the jboss Service log into jboss.log

            echo "jboss Service Stopping........" >>/var/log/xxxx/jboss.log

            echo "------------------------------" >>/var/log/xxxx/jboss.log

            date " %Y-%m-%d %A %T :jboss Service Stop">>/var/log/xxxx/jboss.log

            echo "----------------------------" >>/var/log/xxxx/jboss.log

            su - xxxx -c “$JBOSS_HOME/bin/shutdown.sh –S”>>/var/log/xxxx/jboss.log

            }

            case $1 in

            start)

            start

            ;;

            stop)

            stop

            ;;

            restart|reload)

            stop

            start

            ;;

            status)

            status $prog

            ;;

            *)

            echo "Please Input start|stop|restart|reload|status"

            return 1

            esac

            ////////////////////////文件内容结束///////////////////

注意:

请赋予jboos的执行权限:chmod 755 /etc/init.d/jboss

请注意xxxx用户是没有设置密码的,确保使用xxxx用户是无法登录的,只有root可以切换到该用户环境中去的:#su – xxxx…..

4)oracle安装与启动

创建相关安装目录和环境变量

            1,创建user/group;

            #groupadd dba

            #groupadd oinstall

            #useradd oracle -g oinstall -G dba

            #passwd oracle

            2,建立oracle安装文件夹;

            # mkdir -p /opt/ora9/product/9.2.0.4

            # mkdir /var/opt/oracle

            # chmod oracle.dba /var/opt/oracle

            # chown -R oracle.dba /opt/ora9
3,配置环境变量;

以root用户登录,设置root用户的环境打开.bash_profile文件,将如下内容加入:
export orACLE_BASE=/opt/ora9

            export orACLE_HOME=/opt/ora9/product/9.2.0.4

            export PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin

            export orACLE_OWNER=oracle

            export orACLE_SID=oradb //此处为你的sid

             使用Oracle用户登陆:

             #su – oracle

             $vi .bash_profile

             以下是配置文件的内容

             # .bash_profile

             # Get the aliases and functions

             if [ -f ~/.bashrc ]; then

            . ~/.bashrc

             fi

             # User specific environment and startup programs

             PATH=$PATH:$HOME/bin

             export orACLE_BASE=/opt/ora9

             export orACLE_HOME=/opt/ora9/product/9.2.0.4

             export PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/Apache/Apache/bin

             export orACLE_OWNER=oracle

             export orACLE_SID=oradb

             export orACLE_TERM=xterm

             export LD_ASSUME_KERNEL=2.4.19

             export THREADS_FLAG=native

             export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib

             export NLS_LANG=”American_america.utf8”

             export orA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data

             export PATH

             unset USERNAME

             4,设置系统参数;

            #su – root切换到root用户

            a) 修改#vi /etc/sysctl.conf, 以下是配置文件的内容:

            # Kernel sysctl configuration file for Red Hat Linux

            #

            # For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and

            # sysctl.conf(5) for more details.

            # Controls IP packet forwarding

            net.ipv4.ip_forward = 0

            # Controls source route verification

            net.ipv4.conf.default.rp_filter = 1

            # Controls the System Request debugging functionality of the kernel

            kernel.sysrq = 0

            # Controls whether core dumps will append the PID to the core filename.

            # Useful for debugging multi-threaded applications.

            kernel.core_uses_pid = 1

            kernel.shmmax = 536870912

            kernel.shmmni = 4096

            kernel.shmall = 2097152

            kernel.sem = 250 32000 100 128

            fs.file-max = 65536

            net.ipv4.ip_local_port_range = 1024 65000

            修改后运行

            #sysctl –p

            命令使得内核改变立即生效;
顶(0)
踩(0)

您可能还会对下面的文章感兴趣:

最新评论