OpenSuse下安装jdk\mysql\tomcat\nginx\mysql-proxy


1.安装 jdk
a.去http://java.sun.com下载jdk(j2se)1.6.0_19.bin
b.#chkmod 777 ./jdkxxx.bin
c.#./jdkxxx.bin
d.#vi /etc/profile
在文件最后加上: (假如安装在/usr/local/jdk目录 下)
export JAVA_HOME=/usr/local/jdk
export JRE_HOME=/usr/local/jdk/jre
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
e.在终端上初如化环境变量
#source /etc/profile
f.测试是否安装成功
#java
有显示 表示 成功

2.安装 mysql
a.去http://dev.mysql.com下载mysql-server,mysql-client的rpm包
b.#rpm -ivh mysql-server-xxx.rpm
c.#rpm -ivh mysql-client-xxx.rpm
d.安装服务
#chkconfig --list
查看是否有mysql的服务,如果没有请执行
#chkconfig --add mysql
e.开启服务
#service mysql start
f.测试
#netstat -nat
查看是否开启了3306端口
#mysql
进入表示已成功安装

3.安装 tomcat
a.去http://tomcat.apache.org下载最新版(tar.gz)
b.解压到/usr/local/目录 下
c.加权限
#chmod a+x /usr/local/tomcat/bin/startup.sh
#chmod a+x /usr/local/tomcat/bin/shutdown.sh
#chmod a+x /usr/local/tomcat/bin/catalina.sh
#chmod a+x /usr/local/tomcat/bin/setclasspath.sh
d.测试
#/usr/local/tomcat/bin/startup.sh
用浏览器访问http://127.0.0.1:8080,如果能看到tomcat主界面表示成功
f.编写tomcat服务
#vi /etc/init.d/tomcat
#!/bin/bash
# Comments to support LSB init script conventions
### BEGIN INIT INFO
# Provides: tomcat
# Required-Start: $ALL
# Required-Stop: $ALL
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop ORS
# Description: tomcat ORS SERVER
### END INIT INFO
export JAVA_HOME=/usr/local/jdk
case $1 in
    'start')
       echo -n "Starting tomcat..."
        /usr/local/tomcat/bin/startup.sh
      echo " done"
       ;;
    'stop')
       echo -n "Stopping tomcat..."
        /usr/local/tomcat/bin/shutdown.sh
        echo " done"
       ;;
    'restart')
        /usr/local/tomcat/bin/shutdown.sh
        sleep 5
        /usr/local/tomcat/bin/startup.sh
       ;;
    *)
        echo -n "Usage: $0 {start|restart|stop}"
       ;;
   
esac
:quit
g.添加服务
#chkconfig --add tomcat

4.安装 nginx
a.去http://www.nginxcn.com下载linux版本的源代码包
b.解压下载的包
c.查看系统有无gcc包,如果没有请安装gcc
d.安装pcre组件及其依赖包
e.安装openssl组件及其依赖包
f.安装make组件及其依赖包
g.编译nginx
#./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
没有错误提示表示编译成功
h.安装
#make
#make install
i.测试
#/usr/local/nginx/sbin/nginx
用浏览器访问http://127.0.0.1,出现欢迎界面表示成功

j.修改配置文件,添加负载

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

用下面的内容替换


#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

worker_rlimit_nofile 65535;
events {
    use epoll;
    worker_connections  65535;
}


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

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    #设定请求缓冲
    client_header_buffer_size    1k;
    large_client_header_buffers 4 4k;
    #开启gzip模块
    gzip on;
    gzip_min_length 1100;
    gzip_buffers    4 8k;
    gzip_types      text/plain;
    output_buffers 1 32k;
    postpone_output 1460;
    #设定access log
    access_log logs/access.log main;
    client_header_timeout 3m;
    client_body_timeout    3m;
    send_timeout          3m;
    sendfile                on;
    tcp_nopush              on;
    tcp_nodelay            on;
    keepalive_timeout 65;
   
    #设定负载均衡的服务器列表
    upstream mysvr {
        #weigth参数表示权值,权值越高被分配到的几率越大
        server 127.0.0.1:8080 weight=1;
    }
    server {
        listen       80;
        server_name  localhost;
            root /usr/local/tomcat/webapps/ROOT;
          index index.jsp;
        #charset utf-8;

        #access_log  logs/host.access.log  main;

        location / {       
           proxy_pass      http://mysvr;
            proxy_redirect          off;
            proxy_set_header        Host $host;
            proxy_set_header        X-Real-IP $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            client_max_body_size    10m;
            client_body_buffer_size 128k;
            proxy_connect_timeout 90;
            proxy_send_timeout      90;
            proxy_read_timeout      90;
            proxy_buffer_size      4k;
            proxy_buffers          4 32k;
            proxy_busy_buffers_size 64k;
            proxy_temp_file_write_size 64k;
        }
        }
    #error_page  404              /404.html;
}

5.安装mysql-proxy
系统要求:
glib2.16及其以上
libevent1.3及其以上
pkg-config
libtool1.5及其以上
lua5.1
a.安装lua5.1.4及其依赖包
b.去http://dev.mysql.com下载mysql-proxy组件包
c.解压到/usr/local/目录下
d.测试
#/usr/local/mysql-proxy/bin/mysql-proxy --version
查看并显示当前的版本信息
执行
#/usr/local/mysql-proxy/bin/mysql-proxy --pid-file /var/run/mysql-proxy.pid -r 192.168.1.87 -b 192.168.1.80 -s /usr/local/mysql-proxy/share/doc/mysql-proxy/rw-splitting.lua --keepalive
e.安装mysql-proxy服务
#vi /etc/init.d/mysql-proxy
#!/bin/bash
# Comments to support LSB init script conventions
### BEGIN INIT INFO
# Provides: mysql-proxy
# Required-Start: $ALL
# Required-Stop: $ALL
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop ORS
# Description: mysql-proxy
### END INIT INFO

# See how we were called.
case "$1" in
  'start')
        # Start daemon.
        echo "Start mysql-proxy..."
      /usr/local/mysql-proxy/bin/mysql-proxy --pid-file /var/run/mysql-proxy.pid -r 192.168.1.87 -b 192.168.1.80 -s /usr/local/mysql-proxy/share/doc/mysql-proxy/rw-splitting.lua --keepalive --daemon
        echo "done"
        RETVAL=$?
       ;;
  'stop')
      # Stop daemons.
      echo "Stopping..."
          killproc mysql-proxy
        echo "done"
        RETVAL=$?
       ;;
  'restart')
        $0 stop
        sleep 3
        $0 start
       ;;
  *)
        echo "Usage: $0 {start|stop|restart}"
       ;;
esac
exit $RETVAL
:quit
f.添加服务
#chmod 777 /etc/init.d/mysql-proxy
#chkconfig --add mysql-proxy
#service mysql-proxy start

你可能感兴趣的:(jdk,tomcat,mysql,nginx,lua)