一、设置服务器安全与SSH互信
改SSH默认端口、允许访问的IP /etc/hosts.allow deny两个文件控制
[root@localhost ~]# cat /etc/hosts.deny # # hosts.deny This file contains access rules which are used to # deny connections to network services that either use # the tcp_wrappers library or that have been # started through a tcp_wrappers-enabled xinetd. # # The rules in this file can also be set up in # /etc/hosts.allow with a 'deny' option instead. # # See 'man 5 hosts_options' and 'man 5 hosts_access' # for information on rule syntax. # See 'man tcpd' for information on tcp_wrapper sshd:ALL # [root@localhost ~]# cat /etc/hosts.allow # # hosts.allow This file contains access rules which are used to # allow or deny connections to network services that # either use the tcp_wrappers library or that have been # started through a tcp_wrappers-enabled xinetd. # # See 'man 5 hosts_options' and 'man 5 hosts_access' # for information on rule syntax. # See 'man tcpd' for information on tcp_wrappers sshd:111.111.219.111:allow sshd:111.124.171.16:allow
2.设置SSH互信,两台机器相互做,最后一步是确认是否成功(不出密码表示成功)。
yum install openssh-clients /usr/bin/ssh-keygen -d scp -P 8022 /root/.ssh/id_dsa.pub 111.124.171.16:/root/.ssh/authorized_keys ssh -p 8022 [email protected] ifconfig
3.修改yum源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo yum clean all yum makecache 4.初始化硬盘 df -h fdisk -l 查看硬盘情况 fdisk /dev/sdb 格式化这块硬盘 n-p-w mkfs -t ext4 /dev/sdb1 mkdir /wqdata vim /etc/fstab 添加下句 /dev/sdb1 /wqdata ext4 defaults 1 2
二、安装jdk+tomcat+nginx环境
rpm -ivh jdk-7u79-linux-x64.rpm
解压tomcat rc.local加入
JAVA_HOME=/usr/java/jdk1.7.0_79
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
/wqdata/tomcat02/bin/startup.sh
tar zxvf nginx-1.6.2.tar.gz
149 cd nginx-1.6.2
150 yum install gcc openssl-devel pcre-devel -y
151 ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module
152 make && make install
worker_processes 8; worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000; pid /usr/local/nginx/nginx.pid; worker_rlimit_nofile 102400; events { use epoll; worker_connections 102400; } http { include mime.types; default_type application/octet-stream; fastcgi_intercept_errors on; charset utf-8; server_names_hash_bucket_size 128; client_header_buffer_size 4k; large_client_header_buffers 4 32k; client_max_body_size 300m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; client_body_buffer_size 512k; proxy_connect_timeout 5; proxy_read_timeout 60; proxy_send_timeout 5; proxy_buffer_size 16k; proxy_buffers 4 64k; proxy_busy_buffers_size 128k; proxy_temp_file_write_size 128k; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.1; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /usr/local/nginx/logs/access.log; upstream cluster_tomcat { ip_hash; server 127.0.0.1:9180 weight=1 max_fails=2 fail_timeout=30s; } #limit_conn_zone $binary_remote_addr zone=perip:10m; server { listen 80; server_name mofi.10086yun.cn; index index.html index.htm index.jsp login.html index.do default.do; root /wqdata/mofi; #limit_conn perip 10; location / { proxy_next_upstream http_502 http_504 error timeout invalid_header; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://cluster_tomcat; # expires 3d; expires -1; } location ~ .*\.(jsp|do)?$ { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://cluster_tomcat; } location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$ { root /wqdata/mofi; # expires 3d; expires -1; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
三、安装MYSQL数据库
yum install -y gcc gcc-c++ ncurses-devel perl cmake
cmake . -DCMAKE_INSTALL_PREFIX=/wqdata/mysql -DMYSQL_DATADIR=/wqdata/mydata/data -DSYSCONFDIR=/wqdata/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
149 make && make install
150 make install
151 groupadd -r mysql
152 useradd -g mysql -r -d /wqdata/mydata/data/ mysql
153 mkdir -p /wqdata/mydata/data
154 chown -R mysql:mysql /wqdata/mysql
155 cp support-files/my-large.cnf /wqdata/mysql/my.cnf
156 vim /wqdata/mysql/my.cnf
datadir= /wqdata/mydata/data
157 chmod +x /etc/rc.d/init.d/mysqld
158 cp support-files/mysql.server /etc/rc.d/init.d/mysqld
159 chmod +x /etc/rc.d/init.d/mysqld
160 cd /wqdata/mysql/
161 ./scripts/mysql_install_db --user=mysql --datadir=/wqdata/mydata/data/
162 vi /etc/profile.d/mysql.sh
export PATH=/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin:/wqdata/mysql/bin/ 163 source /etc/profile.d/mysql.sh
164 service mysqld start
165 mysql
四、导入数据 测试
本文出自 “MJ为的笔记和总结” 博客,转载请与作者联系!