之前在北京工作的时候,技术开发与运维的工作是分开的,有专门的DBA、搞网络的、做服务器的等,而现在回到老家这边工作,没有单独专门做运维的,开发运维都是开发来做,其实我所说的运维也就限于部署层面的运维,真正的运维工作是很复杂繁琐的。
话不多说,操作系统Centos7,spring boot jar包单体应用部署(jdk1.8),MInio文件存储,Redis5.0,Nginx1.20、Oracle12C(Linux部署Oracle真的有些恶心,如果可以建议将Oracle数据库安装在Windows上面,本文介绍Oracle12C的静默安装步骤)。
1. JDK配置
export JAVA_HOME=/usr/local/jdk/jdk1.8.0_202
export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/
export PATH=$PATH:$JAVA_HOME/bin
2. Nginx安装配置
[root@localhost local]# tar -zxvf nginx-1.20.2.tar.gz
[root@localhost]# cd nginx-1.20.2
[root@localhost nginx-1.20.2]# ./configure --prefix=/usr/local/nginx/ --with-http_stub_status_module --with-http_ssl_module
[root@localhost nginx-1.20.2]# make && make install
[root@localhost nginx-1.20.2]# vim /etc/profile.d/nginx.sh
nginx.sh ⽂件内容如下:export PATH=“/usr/local/nginx/sbin:${PATH}”,source /etc/profile使环境变量生效。
[root@localhost /]# nginx
[root@localhost /]# nginx -s stop
[root@localhost /]# nginx -s reload
以上为nginx安装配置的常用操作。
3. Redis安装配置
[root@localhost local]# yum install -y gcc
[root@localhost local]# wget http://download.redis.io/releases/redis-5.0.3.tar.gz
[root@localhost local]# tar -zxvf redis-5.0.3.tar.gz
[root@localhost local]# cd redis-5.0.3
[root@localhost redis-5.0.3]# make
[root@localhost redis-5.0.3]# make install PREFIX=/usr/local/redis
[root@localhost redis-5.0.3]# cd /usr/local/redis/bin/
[root@localhost bin]# ./redis-server
后台启动:
从 redis 的源码目录中复制 redis.conf 到 redis 的安装目录
[root@localhost bin]# cp /usr/local/redis-5.0.3/redis.conf /usr/local/redis/bin/
修改 redis.conf 文件,把 daemonize no 改为 daemonize yes
[root@localhost bin]# vi redis.conf
执行命令,后台启动
[root@localhost bin]# ./redis-server redis.conf
[root@localhost bin]# vi /etc/systemd/system/redis.service
添加以下内容:
[Unit]
Description=redis-server
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.target
设置开机启动
[root@localhost bin]# systemctl daemon-reload
[root@localhost bin]# systemctl start redis.service
[root@localhost bin]# systemctl enable redis.service
创建 redis 命令软链接
[root@localhost ~]# ln -s /usr/local/redis/bin/redis-cli /usr/bin/redis
redis服务操作命令:
systemctl start redis.service #启动redis服务
systemctl stop redis.service #停止redis服务
systemctl restart redis.service #重新启动服务
systemctl status redis.service #查看服务当前状态
systemctl enable redis.service #设置开机自启动
systemctl disable redis.service #停止开机自启动
特别说明:
1 appendonly no
2 dbfilename dump.rdb
3 dir /usr/local/redis/bin
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install docker-ce
sudo systemctl enable docker
sudo systemctl start docker
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version #查看compose版本
5. Minio安装
我采用的是docker安装,前提需要安装docker及docker-compose,具体安装步骤在上一节有说明。
version: '3.7'
# starts 4 docker containers running minio server instances.
# using nginx reverse proxy, load balancing, you can access
# it through port 9000.
services:
minio1:
image: minio/minio:RELEASE.2021-03-26T00-00-41Z
container_name: minio1
volumes:
- /home/miniodata/minio1-1:/data1 #设置为自己的挂载目录,挂载到数据盘
- /home/miniodata/minio1-2:/data2 #设置为自己的挂载目录,挂载到数据盘
expose:
- "9000"
environment:
MINIO_ROOT_USER: test #设置为自己的
MINIO_ROOT_PASSWORD: test123 #设置为自己的
command: server http://minio{1...2}/data{1...2}
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
minio2:
image: minio/minio:RELEASE.2021-03-26T00-00-41Z
container_name: minio2
volumes:
- /home/miniodata/minio2-1:/data1 #设置为自己的挂载目录,挂载到数据盘
- /home/miniodata/minio2-2:/data2 #设置为自己的挂载目录,挂载到数据盘
expose:
- "9000"
environment:
MINIO_ROOT_USER: test #设置为自己的
MINIO_ROOT_PASSWORD: test123 #设置为自己的
command: server http://minio{1...2}/data{1...2}
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
nginx:
image: nginx:1.19.2-alpine
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- "9000:9000"
depends_on:
- minio1
- minio2
## By default this config uses default local driver,
## For custom volumes replace with volume driver configuration.
volumes:
data1-1:
data1-2:
data2-1:
data2-2:
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
# include /etc/nginx/conf.d/*.conf;
upstream minio {
server minio1:9000;
server minio2:9000;
}
server {
listen 9000;
listen [::]:9000;
server_name localhost;
# To allow special characters in headers
ignore_invalid_headers off;
# Allow any size file to be uploaded.
# Set to a value such as 1000m; to restrict file size to a specific value
client_max_body_size 0;
# To disable buffering
proxy_buffering off;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 300;
# Default is HTTP/1, keepalive is only enabled in HTTP/1.1
proxy_http_version 1.1;
proxy_set_header Connection "";
chunked_transfer_encoding off;
proxy_pass http://minio;
}
}
}
6. Oracle12C安装配置
实际开发过程中,如果项目不是非得用Oracle及Centos的话,还是建议可以使用MySQL或者是数据库申请Windows服务器,因为在centos上面安装Oracle比MySQL要复杂的多。之前用过图形化安装Oracle,我感觉还是有些复杂,所以本篇介绍Oracle的静默安装步骤(我以后反正是能不用centos安装Oracle就不用)。