应用服务器(原服务器)172.1.1.1 | |
---|---|
硬盘大小 | 1673.46G |
内存 | 128G |
处理器 | Intel(R)Xeon® CPU E5-2650 [email protected] |
系统类型 | 64位 |
系统类型 | 64位 |
使用端口 | 8081(tomcat),7777(远程),8881(tomcat),1521,80,6379(redis) |
备份计划 | 无 |
备份路径 | 无 |
使用软件 | 版本 |
tomcat | 7 |
jdk | 1.8 |
redis | 3.2 |
pl/sqldeveloper | 9 |
Navicat | 12.1 |
Nginx | 1.24.0 |
数据库服务器(原服务器)172.1.1.2 | |
---|---|
配置 | |
硬盘大小 | 3.27T |
内存 | 128G |
处理器 | Intel(R)Xeon® CPU E5-2650 [email protected] |
系统类型 | 64位 |
使用端口 | 7777端口,1521 |
备份计划 | D:backup\script\orabackup.bat(区平台数据库每周一次) |
E:bak\bak2.bat(每天)越秀移动采集数据库 | |
备份路径 | D:\backup |
E:\bak\data | |
使用软件 | 版本 |
oracle | 11.2.0.4 |
192.168.1.1(预设配置为新移动采集应用服务器) | ||
---|---|---|
配置 | ||
硬盘大小 | 600G | |
内存 | 32G | |
处理器 | intel® Xeno® Gold 5120 [email protected] | |
系统类型 | centos7.6(64位) | |
申请端口 | :80,8081,443 | |
应用 | ||
软件 | 版本 | 安装路径 |
tomcat | 9.0.71 | |
jdk | 1.8.0_351 | |
redis | 3.2 | |
nginx | 1.22-1 |
192.168.1.3(预设配置为新数据库服务器) | ||
---|---|---|
配置 | ||
硬盘大小 | 3.9TB | |
内存 | 128G | |
处理器 | intel® Xeno® CPU E5-2630 [email protected] x2 | |
系统类型 | centos7.6(64位) | |
HBA卡:LPe12000-M8 8Gb x2 千兆网卡 | ||
申请端口 | :1521 | |
应用 | ||
软件 | 版本 | 安装路径 |
Oracle | 11.2.0.4 |
192.168.1.2(预设配置为新区来穗平台服务器) | ||
---|---|---|
配置 | ||
硬盘大小 | 600G | |
内存 | 32G | |
处理器 | intel® Xeno® Gold 5120 [email protected] | |
系统类型 | centos7.6(64位) | |
申请端口 | :80,8080,443 | |
应用 | ||
软件 | 版本 | 安装路径 |
tomcat | 9.0.71 | |
jdk | 1.8.0_351 | |
redis | 3.2 |
将tomcat另存为压缩包,除开日志
oracle11g安装介质已经下载且上传完成
# 输入以下命令,查看依赖是否安装
rpm -q binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc-2.17 glibc-common glibc-devel glibc-headers ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel unzip
#安装依赖文件
yum install -y binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc-2.17 glibc-common glibc-devel glibc-headers ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel unzip
#新增用户和组
groupadd oinstall
groupadd dba
useradd -g oinstall -G dba oracle
passwd oracle
#输入密码
##linux内核
# 备份
cp /etc/sysctl.conf /etc/sysctl.conf.bak
# 修改linux内核
cat >> /etc/sysctl.conf << EOF
# 内核参数
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 8388608
kernel.shmmax = 34359738368
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
EOF
# 使参数生效
sysctl -p
1.3.2 关闭selinux
# 备份
cp /etc/selinux/config /etc/selinux/config.bak
# 查看
grep ^SELINUX= /etc/selinux/config
# 关闭selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
# 临时关闭
setenforce 0
# 查看状态
getenforce
# 关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
cp /etc/security/limits.conf /etc/security/limits.conf.bak
cat >> /etc/security/limits.conf << EOF
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
EOF
cp /etc/pam.d/login /etc/pam.d/login.bak
cat >> /etc/pam.d/login << EOF
session required /lib64/security/pam_limits.so
session required pam_limits.so
EOF
cp /etc/profile /etc/profile.bak
cat >> /etc/profile << EOF
if [ \$USER = "oracle" ]; then
if [ \$SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
EOF
source /etc/profile
#创建数据库相关目录并授权
mkdir -p /opt/app/oracle/product/11.2.0 &&
mkdir /opt/app/oracle/oradata &&
mkdir /opt/app/oracle/inventory &&
mkdir /opt/app/oracle/fast_recovery_area &&
chown -R oracle:oinstall /opt/app/oracle &&
chmod -R 775 /opt/app/oracle
#添加/etc/oraInst.loc文件
cat > /etc/oraInst.loc << EOF
inventory_loc=/opt/app/oracle/oraInventory
inst_group=oinstall
EOF
# 授权
chown oracle:oinstall /etc/oraInst.loc
chmod 664 /etc/oraInst.loc
#修改oracle环境变量
su - oracle
cp ~/.bash_profile ~/.bash_profile.bak
cat >> ~/.bash_profile << EOF
ORACLE_BASE=/opt/app/oracle
ORACLE_HOME=\$ORACLE_BASE/product/11.2.0
ORACLE_SID=orcl
PATH=\$PATH:\$ORACLE_HOME/bin
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
EOF
source ~/.bash_profile
安装包配置 注意:这里选择的解压路径在:/tmp路径下
# 上传并解压文件 linux.x64_11gR2_database_1of2.zip linux.x64_11gR2_database_2of2.zip
cd /tmp
unzip linux.x64_11gR2_database_1of2.zip && unzip linux.x64_11gR2_database_2of2.zip
# 复制配置文件,修改权限,这里主要修改oracle相关存放的路径即可
cd /home/oracle/
cp -R /database/response/ .
cd response/
# 修改db_install.rsp内容
sed -i 's/^oracle.install.option.*$/oracle.install.option=INSTALL_DB_SWONLY/g' db_install.rsp && \
sed -i 's/^UNIX_GROUP_NAME=/UNIX_GROUP_NAME=oinstall/g' db_install.rsp && \
sed -i 's/INVENTORY_LOCATION=/INVENTORY_LOCATION=\/opt\/app\/oracle\/inventory/g' db_install.rsp && \
sed -i 's/SELECTED_LANGUAGES=/SELECTED_LANGUAGES=en,zh_CN/g' db_install.rsp && \
sed -i 's/ORACLE_HOME=/ORACLE_HOME=\/opt\/app\/oracle\/product\/11.2.0/g' db_install.rsp && \
sed -i 's/ORACLE_BASE=/ORACLE_BASE=\/opt\/app\/oracle/g' db_install.rsp && \
sed -i 's/oracle\.install\.db\.InstallEdition=/oracle\.install\.db\.InstallEdition=EE/g' db_install.rsp && \
sed -i 's/oracle\.install\.db\.DBA_GROUP=/oracle\.install\.db\.DBA_GROUP=dba/g' db_install.rsp && \
sed -i 's/oracle\.install\.db\.OPER_GROUP=/oracle\.install\.db\.OPER_GROUP=dba/g' db_install.rsp && \
sed -i 's/DECLINE_SECURITY_UPDATES=/DECLINE_SECURITY_UPDATES=true/g' db_install.rsp
cd /home/database/
./runInstaller -silent -responseFile /opt/app/oracle/response/db_install.rsp -ignorePrereq
# 安装完后使用root用户执行
su root
sh /opt/app/oracle/inventory/orainstRoot.sh
sh /opt/app/oracle/product/11.2.0/root.sh
# 切换到oracle用户【配置监听】
netca /silent /responsefile /home/oracle/response/netca.rsp
#成功运行后,在/opt/app/oracle/product/11.2.0/network/admin/中生成listener.ora和sqlnet.ora
#配置监听后,可以查看1521端口是否启动
netstat -ntlp | grep 1521
以静默方式建立新库,同时也建立一个对应的实例,注意在设置密码时,不能使用特殊符号
#文件位置/home/oracle/response/dbca.rsp
# 修改以下配置【查找出每一条后修改】这里依照旧数据库字符集更改字符集为ZHS16GBK
sed -i 's/GDBNAME = \"orcl11\.us\.oracle\.com\"/GDBNAME = \"yxrorcl\"/g' /home/oracle/response/dbca.rsp && \
sed -i 's/GDBNAME = \"orcl11g\.us\.oracle\.com\"/GDBNAME = \"yxrorcl\"/g' /home/oracle/response/dbca.rsp && \
sed -i 's/SID = \"orcl11g\"/SID = \"yxrorcl\"/g' /home/oracle/response/dbca.rsp && \
sed -i 's/#SYSPASSWORD = \"password\"/SYSPASSWORD = "Toonan12#$"/g' /home/oracle/response/dbca.rsp && \
sed -i 's/#SYSTEMPASSWORD = \"password\"/SYSTEMPASSWORD = "Toonan12#$"/g' /home/oracle/response/dbca.rsp && \
sed -i 's/#SYSMANPASSWORD = \"password\"/SYSMANPASSWORD = "Toonan12#$"/g' /home/oracle/response/dbca.rsp && \
sed -i 's/#DBSNMPPASSWORD = \"password\"/DBSNMPPASSWORD = "Toonan12#$"/g' /home/oracle/response/dbca.rsp && \
sed -i 's/#DATAFILEDESTINATION =/DATAFILEDESTINATION =\/opt\/app\/oracle\/oradata/g' /home/oracle/response/dbca.rsp && \
sed -i 's/#RECOVERYAREADESTINATION=/RECOVERYAREADESTINATION=\/opt\/qpt\/oracle\/fast_recovery_area/g'/home/oracle/response/dbca.rsp && \
sed -i 's/#CHARACTERSET = \"US7ASCII\"/CHARACTERSET = \"ZHS16GBK\"/g' /home/oracle/response/dbca.rsp && \
sed -i 's/#TOTALMEMORY = "800"/TOTALMEMORY = \"102400\"/g' /home/oracle/response/dbca.rsp
# 其中TOTALMEMORY = "102400" 为102400MB,物理内存128G。
切换到oracle用户终端
dbca -silent -responseFile /home/oracle/response/dbca.rsp
完成后检查进程
ps -ef | grep ora_ | grep -v grep
查看监听状态
lsnrctl status
登录查看实例状态
sqlplus / as sysdba
select status from v$instance;
# 切换到root用户
vim /opt/app/oracle/product/11.2.0/bin/dbstart
# 将 ORACLE_HOME_LISTNER=$1 修改为
ORACLE_HOME_LISTNER=$ORACLE_HOME
vim /etc/oratab
# 将 orcl:/opt/app/oracle/product/11.2.0:N 中最后的 N 改为 Y
# 切换到oracle用户
# 使用dbshut 和 dbstart 测试
dbshut
dbstart
8.配置开机自启
# 切换root用户
chmod 755 /etc/rc.d/rc.local
vim /etc/rc.d/rc.local
# 在rc.local中添加
su - oracle -lc "/opt/app/oracle/product/11.2.0/bin/lsnrctl start"
su - oracle -lc /opt/app/oracle/product/11.2.0/bin/dbstart
JDK、Tomcat需要在192-1、192-2两台服务器部署,此处只记录一次部署方式
在本家下载好jdk版本 java version “1.8.0_351”
在本地主机下载好再用xftp将文件传送到linux中的/usr/local/src/路径里
tar -zxvf jdk-8u101-linux-x64.tar.gz
cp -p jdk1.8.0_101 /usr/local/java
vim /etc/profile
#加入下面内容
export JAVA_HOME=/usr/local/java/jdk1.8.0_351/
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
#然后
sourcejava -version
java -version
java
安装tomcat
先在官网下载9.0.71.tar包,并传输到服务器中
完成后如下操作
tar zxvf apache-tomcat-9.0.71.tar.gz
mv apache-tomcat-9.0.71 /home/yxls/apache-tomcat-9/
cp -p /home/yxls/apache-tomcat-9/bin/catalina.sh /etc/init.d/tomcat
vim /etc/init.d/tomcat
JAVA_HOME=/usr/local/java/jdk1.8.0_351/
CATALINA_HOME=/home/yxls/apache-tomcat-9
#保存文件后
chmod 755 /etc/init.d/tomcat
chkconfig --add tomcat
chkconfig tomcat on
#启动tomcat
service tomcat start
ps aux |grep tomcat
配置防火墙
firewall-cmd --permanent --zone=public --add-port=8080/tcp
firewall-cmd --reload
firewall-cmd --zone=public --query-port=8080/tcp
#在官网找到redis-3.2.1.tar.gz包,下载并传输到192-2
#解压
tar -zvxf redis-3.2.1.tar.gz
mv redis-3.2.1 /home/redis-3.2.1
cd /home/redis-3.2.1
make
make PREFIX=/home/redis-3.2.1 install
#启动
./bin/redis-server& ./redis.conf
vim redis.conf
# 关闭保护模式,允许远程连接
protected-mode no
# 持久化
appendonly yes
# 密码
requirepass toonan123
#创建系统用户nginx
[root@stream2 ~]# useradd -r -M -s /sbin/nologin nginx
#安装依赖
[root@stream2 ~]# yum -y install pcre-devel openssl openssl-devel gd-devel gcc gcc-c++ wget make
[root@stream2 ~]# yum -y groups mark install 'Development Tools'
#存放目录创建
[root@stream2 ~]# mkdir -p /var/log/nginx
[root@stream2 ~]# chown -R nginx.nginx /var/log/nginx
#下载源码包
[root@stream2 src]# pwd
/usr/src
[root@stream2 src]# wget https://nginx.org/download/nginx-1.22.1.tar.gz
[root@stream2 src]# ls
debug kernels nginx-1.22.1.tar.gz
#编译安装
[root@stream2 src]# tar xf nginx-1.22.1.tar.gz
[root@stream2 src]# cd nginx-1.22.1/
[root@stream2 nginx-1.22.1]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-debug --with-http_ssl_module --with-http_realip_module --with-http_image_filter_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log
#nginx配置,服务控制方式,使用nginx命令
[root@stream2 nginx-1.22.1]# make -j $(grep 'processor' /proc/cpuinfo | wc -l) && make install
#配置环境变量
[root@stream2 nginx-1.22.1]# echo 'export PATH=/usr/local/nginx/sbin:$PATH' > /etc/profile.d/nginx.sh
[root@stream2 nginx-1.22.1]# source /etc/profile.d/nginx.sh
[root@stream2 nginx-1.22.1]# which nginx
/usr/local/nginx/sbin/nginx
#使用 nginx -t 检查配置文件语法
[root@stream2 nginx-1.22.1]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@stream2 nginx-1.22.1]# nginx -v
nginx version: nginx/1.22.1
#写service文件
[root@stream2 nginx-1.22.1]# vim /usr/lib/systemd/system/nginx.service
[root@stream2 nginx-1.22.1]# cat /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx server daemon
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecStop=/usr/local/nginx/sbin/nginx -s stop
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
[root@stream2 nginx-1.22.1]# systemctl daemon-reload
[root@stream2 nginx-1.22.1]# systemctl restart nginx.service
[root@stream2 nginx-1.22.1]# systemctl enable nginx.service
--
[root@stream2 nginx-1.22.1]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:80 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
#分别修改192-1、192-2两台服务器的server.xml文件
#修改内容如下
#192-1监听8080端口段
-<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8" />
#192-2改成8081
-<Connector port="8081" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8" />
#替换操作
#删除位于192-1/opt/app/apache-tomcat-9/webapps/下的文件,将rental传输到此文件夹内
vim /opt/app/apache-tomcat-9/webapps/rental/WEB-INF/classes/application-development.yml
url: "jdbc:oracle:thin:@192.168.1.3:1521:yxorcl"
driverClassName: oracle.jdbc.driver.OracleDriver
username: rental
password: rental
vim /opt/app/apache-tomcat-9/webapps/rental/WEB-INF/classes/redis.properties
#删除位于192-2/home/yxls/apache-tomcat-9/webapps/下的文件,将yxls传输到此文件夹内
#修改文件内容
vim /home/yxls/apache-tomcat-9/webapps/yxls/WEB-INF/classes/application.yml
url: "jdbc:oracle:thin:@192.168.1.3:1521:yxorcl"
driverClassName: oracle.jdbc.driver.OracleDriver
username: rental
password: rental
redis:
serverList: 127.0.0.1:6379
password: toonan123
timeout: 300
maxTotal: 50
#192-2
vim /etc/nginx/conf.d/default.conf
server {
listen 8080;
server_name localhost;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
proxy_pass http://127.0.0.1:8081/rental/login.jsp; # 转发规则
proxy_set_header Host $proxy_host; # 修改转发请求头,让8081端口的应用可以受到真实的请求
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#192-1
vim /etc/nginx/conf/nginx.conf
server {
listen 8081;
server_name localhost;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
proxy_pass http://127.0.0.1:8080/yxls/login.jsp; # 转发规则
proxy_set_header Host $proxy_host; # 修改转发请求头,让8080端口的应用可以受到真实的请求
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
创建用户、表空间
--建立表空间
CREATE TABLESPACE RENTAL_SPACE --创建名为"RENTAL_SPACE"的表空间
LOGGING
DATAFILE '/opt/app/oracle/oracle_tablespace'
SIZE 1024M -- 其初始大小为1024M
AUTOEXTEND ON -- 支持自动扩展
NEXT 1024M -- 每次增量为1024M
EXTENT MANAGEMENT LOCAL
CREATE TABLESPACE YXLS --创建名为"YXLS"的表空间
LOGGING
DATAFILE '/opt/app/oracle/oracle_tablespace_YXLS'
SIZE 1024M -- 其初始大小为1024M
AUTOEXTEND ON -- 支持自动扩展
NEXT 1024M -- 每次增量为1024M
EXTENT MANAGEMENT LOCAL
#创建YXLS和rental用户
CREATE USER YXLS IDENTIFIED BY YXLS
DEFAULT TABLESPACE YXLS;
CREATE USER rental IDENTIFIED BY rental
DEFAULT TABLESPACE RENTAL_SPACE;
恢复数据
#导整个数据库
expdp YXLS/YXLS DIRECTORY=dpdata DUMPFILE=full.dmp FULL=y logfile=expdlog.log;
#导出文件,然后传输至新数据库服务器
#导入数据库
impdb YXLS/YXLS DIRECTORY=dump_dir DUMPFILE=full.dmp FULL=y logfile=impdlog.log;
启动tomcat、nginx
#192-1
[root@localhost redis-3.2.1]# systemctl restart nginx
[root@localhost redis-3.2.1]# sh /opt/app/apache-tomcat-9/bin/startup.sh
[root@localhost redis-3.2.1]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:6379 *:*
LISTEN 0 128 *:8081 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 *:10050 *:*
LISTEN 0 128 :::6379 :::*
LISTEN 0 100 :::8080 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 128 :::10050 :::*
LISTEN 0 1 ::ffff:127.0.0.1:8005 :::*
#192-2
[root@localhost ~]# systemctl restart nginx
[root@localhost ~]# sh /home/yxls/apache-tomcat-9/bin/startup.sh
[root@localhost ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 127.0.0.1:6379 *:*
LISTEN 0 128 *:8080 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 *:10050 *:*
LISTEN 0 100 :::8081 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 128 :::10050 :::*
页面保密