Debian
语言设置
LANG=zh_CN.UTF-8
硬盘分区
分区 | 分区名称 | 大小(G) | 说明 |
---|---|---|---|
1 | system | 50 | 用来存储Debian的系统文件 |
2 | usr/local | 270 | 用来存储Eclipse/JDK/Resin等应用软件 |
3 | data | 150 | 用来存储Boss项目/Upload文件等 |
4 | backup | 150 | 数据备份等。 |
5 | swap | 20 | Linux交换文件。 |
账号
除了系统root外,建立如下账号
编号 | 账号名称 | 用途 |
---|---|---|
1 | bossadmin | 用来运行Boss Web的账号 |
2 | bossshare | 用来共享Upload目录的账号 |
3 | bossftp | 用来让ftp上传文件等。 |
网络配置
/etc/network/infterfaces 具体如下
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface #allow-hotplug eth0 eth0:1 eth1 auto eth0 eth0:1 eth0:2 #auto eth0 eth0:1 iface eth0 inet static address 172.16.88.199 netmask 255.255.250.0 iface eth0:1 inet static address 192.168.61.199 netmask 255.255.248.0 gateway 192.168.60.1 iface eth0:2 inet static address 192.168.60.119 netmask 255.255.248.0 gateway 192.168.60.1 #static route for 192.168.20.0/ up route add -net 192.168.20.0/24 gw 192.168.60.129 dev eth0 auto eth1 iface eth1 inet static address 192.168.50.119 netmask 255.255.248.0
Java sdk
/usr/local/java/jdk1.5.0_09 目前在用
需要copy simsun.ttc 到 /data/java/jdk1.5.0_09/jre/lib/fonts, 用来支持Java graphic中文输出
在/etc/profile 中设置JDK,增加如下内容.
export PATH export JAVA_HOME="/usr/local/java/jdk1.5.0_09" export PATH=$JAVA_HOME/bin:$PATH
Resin
/usr/local/resin-pro-3.0.22-bl
httpd.sh 增加了
1 args="-J-Dclient.encoding.override=GBK -J-Dfile.encoding=GBK -J-Duser.language=zh -J-Duser.region=CN -J-Xms312M -J-Xmx512M"
指定JVM的参数,-J-Dclient.encoding.override=GBK -J-Dfile.encoding=GBK -J-Duser.language=zh -J-Duser.region=CN 用来解决linux 默认utf-8下的resin编译报错问题,-J-Xms312M -J-Xmx512M解决内存溢出异常
web-a.sh的内容如下
./bin/httpd.sh -conf ./conf/WebA.conf -server web-a -Xmn100M -Xms312M -Xmx512M -XX:PermSize=64M -XX:MaxNewSize=256m -XX:MaxPermSize=128m -Djava.awt.headless=true
app-[abcde].sh的内容如下
./bin/httpd.sh -conf ./conf/APP-tier_log.conf -server app-[abcde] -Xmn100M -Xms312M -Xmx512M -XX:PermSize=64M -XX:MaxNewSize=256m -XX:MaxPermSize=128m -Djava.awt.headless=true
用Resin 3.0.22 pro 作为负载平衡时访问量大时会抛出异常,如下
IllegalStateException: sendError() forbidden after buffer has been committed
这是Resin 3.0.x的一个bug,详细请参考:http://bugs.caucho.com/view.php?id=1684
Nginx
使用的版本 nginx-0.8.53
安装于 /usr/local/nginx
修改 /usr/local/nginx/nginx.conf,使得如下内容。
#user nobody; worker_processes 2; #设置Nginx启动2个线程 #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 2048; } http { include mime.types; default_type application/octet-stream; #设置log的格式 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; #设置log保存的位置 access_log /usr/local/boss_log/nginx_log/access.log main; #sendfile on; #tcp_nopush on; #keepalive_timeout 0; #keepalive_timeout 65; #gzip on; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 1 128k; client_max_body_size 8m; # resolve nginx 502/504 error ---allen 2010/12/7 sendfile on; send_timeout 120; tcp_nopush on; keepalive_timeout 120; #60 tcp_nodelay on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 128k; fastcgi_buffers 8 128k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; fastcgi_intercept_errors on; # resolve nginx 502/504 error end ---allen 2010/12/7 # 将请求分发到5个Resin web 服务,其对应的IP:端口为 127.0.0.1:808[0~4] upstream 192.168.60.119{ ip_hash; #设置请求的IP来分发web 服务,来保证Session 正常工作 server 127.0.0.1:8080 max_fails=0; #max_fails=0 发现错误立即切换 server 127.0.0.1:8081 max_fails=0; server 127.0.0.1:8082 max_fails=0; server 127.0.0.1:8083 max_fails=0; server 127.0.0.1:8084 max_fails=0; } server { client_max_body_size 30M; listen 80; server_name 127.0.0.1; #charset koi8-r; #access_log logs/host.access.log main; location / { #root html; index index.jsp; proxy_pass http://192.168.60.119; proxy_set_header X_REAL_IP $remote_addr; proxy_set_header X_HOST $host; proxy_set_header X_FORWARDED_FOR $proxy_add_x_forwarded_for; } location ~ ^/NginxStatus/* { stub_status on; access_log off; } #设置图片等直接用nginx的服务,不转发到 Resin web location ~ .*/.(gif|jpg|jpeg|png|bmp|swf)$ { root /mnt/webFiles/bossSite_Common; expires 1d; } location ~ .*/.(gif|jpg|jpeg|png|bmp|swf)$ { root /usr/local/boss_workspace/boss; expires 1d; } #设置js,css直接用nginx的服务,不转发到 Resin web #location ~ .*/.(js|css)?$ { # root /usr/local/boss_workspace/boss; # expires 1h; #} }
启动nginx的命令
cd /usr/local/nginx ./nginx
停止nginx的命令 ./nginx -s stop
nginx 没有自动截取log的方法,用如下命令来替代。
1 建立脚本 /usr/local/nginx/sbin/cut_nginx_log.sh
#!/bin/bash # This script run at 00:00 # The Nginx logs path logs_path="/usr/local/boss_log/nginx_log/" mkdir -p ${logs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/ mv ${logs_path}access.log ${logs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/access_$(date -d "yesterday" +"%Y%m%d").log kill -USR1 `cat /usr/local/nginx/logs/nginx.pid`
2 设置crontab,每天凌晨00:00切割nginx访问日志
crontab -e
输入以下内容
00 00 * * * /bin/bash /usr/local/nginx/sbin/cut_nginx_log.sh
主进程可以处理以下的信号:
TERM, INT | 快速关闭 |
QUIT | 从容关闭 |
HUP | 重载配置 用新的配置开始新的工作进程 从容关闭旧的工作进程 |
USR1 | 重新打开日志文件 |
USR2 | 平滑升级可执行程序。 |
WINCH | 从容关闭工作进程 |
nginx+resin 工作,resin作如下设置
1 建立resin_nginx.conf, 放在 {RESIN_HOME}/conf下,除了以下内容,其余配置和原来resin.conf的内容相同。
<!-- The http port --> <http server-id="web-a" host="*" port="8080"/> <http server-id="web-b" host="*" port="8081"/> <http server-id="web-c" host="*" port="8082"/> <http server-id="web-d" host="*" port="8083"/> <http server-id="web-e" host="*" port="8084"/> <cluster> <srun server-id="web-a" host="127.0.0.1" port="6802"/> <srun server-id="web-b" host="127.0.0.1" port="6803"/> <srun server-id="web-c" host="127.0.0.1" port="6804"/> <srun server-id="web-d" host="127.0.0.1" port="6805"/> <srun server-id="web-e" host="127.0.0.1" port="6806"/> </cluster>
2 建立 resin-nginx-[a-e].sh, 放在 {RESIN_HOME},内容如下
./bin/httpd.sh -conf ./conf/resin_nginx.conf -server web-[a-e] -Xmn256m
3 依次执行resin-nginx-a.sh,resin-nginx-b.sh...resin-nginx-e.sh,启动resin web服务
vnc
ftp
Eclipse
version: Eclipse Java EE IDE For Web Developers.
安装于 /usr/local/app/eclipse
安装svn插件: http://subclipse.tigris.org/update_1.6.x
samba
用来共享目录,让windows可以访问
svn
切换需要更改的地方
UpLoadFilePath.java 需要更改路径
static{ String user_Home = System.getProperty("os.name"); if(user_Home != null && user_Home.contains("Windows")){ AbsolutePath="D:/webFiles/bossSite_Common/"; //替换成Linux的共享目录 }else{ AbsolutePath="/data1/webFiles/bossSite_Common/"; //替环成所指定的路径 } }
用修改WEB/Config/system.properties的方法来实现上述更改。
com.boss.tools.file.UpLoadFilePath.AbsolutePath=<指定的路径>
mount 118 Server 上的Upload 目录到Linux服务器
118 Server 上的Upload目录:D:\webFiles\bossSite_Common, Linux Web 服务器Upload目录通过mount的方式也指向118的这个目录。
用下面的命令 mount
mount -o user=bossshare,password={PASSWORD} //192.168.60.118/bossSite_Common /mnt/webFiles/bossSite_Common
118上的bulletin目录 互相同步到Linux的对应目录
用FastCopy来同步,目前放在118服务器上,9分钟同步一次。
一些模块根据数据库纪录的文件名字来重命名文件名字,解决大小写文件名的问题
尚建红已经写了一个工具类,来处理这类工作
mount 合同方案
合同方案目录://192.168.60.120/jobcnplan
挂载到 /mnt/192.168.60.120
挂载的命令放在 /usr/local/boss_sh/mount_jobcnplan.sh,执行即可
mount_jobcnplan.sh内容
mount -o user=<user>,password=<password> //192.168.60.120/jobcnplan /mnt/192.168.60.120
更改鼠标右健核对功能,让其指向linux 服务器
更改 web/include/RegQueryCus_BOSS.jsp 即可。
Schedule
放置在 /usr/local/boss_schedule/schedule
启动方式,运行方法,进入Console,执行下面命令
cd /usr/local/boss_schedule/schedule ./schedule.sh
更新linux内核
由于安装的Debian是32位系统,不能将8G的内存完全识别出来,所以必须升级内核!
1. apt-get update 2. apt-cache search linux bigmem 3. apt-get install linux-image-2.6.26-2-686-bigmem (根据查询出来的版本不同,install的也不一样) 4. update-grub (之后直接reboot重启即可)
开机启动 nginx,resin服务
1 在/etc/init.d/目录下建立文件nginx, 内容如下
#!/bin/sh nginx_path="/usr/local/nginx/sbin/" case $1 in start) echo "Start Nginx..." $nginx_path/nginx ;; stop) echo "Stop Nginx..." $nginx_path/nginx -s stop ;; restart) echo "Restart Nginx..." $nginx_path/nginx -s reopen ;; *) echo "Usage:$0 {start|stop|restart}" exit 1 ;; esac exit 0
2 在/etc/init.d/目录下建立文件resin, 内容如下
#!/bin/sh export JAVA_HOME=/usr/local/java/jdk1.5.0_09/ export PATH=$JAVA_HOME/bin:$PATH RESIN_PATH=/usr/local/app/resin-3.0.28 function_startAll(){ $RESIN_PATH/resin-nginx.sh start web-a $RESIN_PATH/resin-nginx.sh start web-b $RESIN_PATH/resin-nginx.sh start web-c $RESIN_PATH/resin-nginx.sh start web-d $RESIN_PATH/resin-nginx.sh start web-e } function_stopAll(){ $RESIN_PATH/resin-nginx.sh stop web-a $RESIN_PATH/resin-nginx.sh stop web-b $RESIN_PATH/resin-nginx.sh stop web-c $RESIN_PATH/resin-nginx.sh stop web-d $RESIN_PATH/resin-nginx.sh stop web-e } function_restartAll(){ $RESIN_PATH/resin-nginx.sh restart web-a $RESIN_PATH/resin-nginx.sh restart web-b $RESIN_PATH/resin-nginx.sh restart web-c $RESIN_PATH/resin-nginx.sh restart web-d $RESIN_PATH/resin-nginx.sh restart web-e } case $1 in start) if [ -n "$2" -a -f $RESIN_PATH/resin-nginx.sh ]; then $RESIN_PATH/resin-nginx.sh start $2 else function_startAll fi exit 1 ;; stop) if [ -n "$2" -a -f $RESIN_PATH/resin-nginx.sh ]; then $RESIN_PATH/resin-nginx.sh stop $2 else function_stopAll fi exit 1 ;; restart) if [ -n "$2" -a -f $RESIN_PATH/resin-nginx.sh ]; then $RESIN_PATH/resin-nginx.sh restart $2 else function_restartAll fi exit 1 ;; *) echo $"Usage:$0 {start|stop|restart} [webname]" exit 1 ;; esac exit 0
3 在/usr/local/resin-pro-3.0.28/目录下建立文件resin-nginx.sh, 内容如下,该文件被/etc/init.d/resin服务调用
#!/bin/sh curdir=`dirname "$0"` conf=$curdir/conf/resin_nginx.conf jvm_args="-Xmn256M" case $1 in start) echo "Start Server $2" server=`cat $conf|grep "server-id=\"$2\""` if [ "$?" = 0 -a -n "$server" ]; then info=`$curdir/bin/httpd.sh -conf $conf -server $2 start $jvm_args` echo "$info" else echo "Server $2 has not found in the $conf" fi exit 1 ;; stop) echo "Stop Server $2" info=`$curdir/bin/httpd.sh -conf $conf -server $2 stop` echo "$info" ;; restart) server=`cat $conf|grep "server-id=\"$2\""` if [ "$?" = 0 -a -n "$server" ]; then echo "Restart Server $2" info=`$curdir/bin/httpd.sh -conf $conf -server $2 restart $jvm_args` else echo "Server $2 has not found in the $conf" fi echo "$info" exit 1 ;; *) echo $"Usage:0{start|stop|restart}" exit 1 ;; esac exit 0
4 运行rcconf命令,把nginx和resin加入启动服务
开机加挂相关共享文件
在/etc/rc.local 增加下述内容
# mount the folder boss web used. /usr/local/boss_sh/mount_jobcnplan.sh & /usr/local/boss_sh/mount_sitecommon.sh &