Centos8部署环境(nginx+docker+sql+redis+mongo+mq)

引言

2021.09月,由于我在扩容服务器硬盘,挂载硬盘时的错误操作.导致环境丢失,万幸数据已备份.当天重新部署环境时,记录部署笔记

nginx

部署

下载nginx
1
https://nginx.org/download/
配置pcre
1
2
yum -y install pcre-devel

配置ssl
1
2
yum -y install openssl openssl-devel

gd
1
2
3
--with-http_image_filter_module

yum -y install gd-devel
编译
1
./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --with-http_ssl_module  --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-http_v2_module --with-stream_ssl_module --with-http_image_filter_module --with-http_mp4_module
安装
1
make && make install

建议不要将解压目录与sbin生成目录放在一起 conf 会出问题

nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
http {
include mime.types;
default_type application/octet-stream;

gzip on;
gzip_comp_level 4;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css;
gzip_vary on;
sendfile on;
keepalive_timeout 65;
proxy_read_timeout 1200s;
proxy_send_timeout 1200s;

client_body_timeout 1200s;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

}

#######################################################################################
############## 请按域名分文件分别归档,降低 nginx.conf 配置文件的维护难度 #############
#######################################################################################


##############################################
################# API ###################
##############################################
include conf.d/domain.api.ysctest.conf;
################## 短链 #####################
include conf.d/domain.u.ysctest.conf;

################# git hook ###################
include conf.d/domain.****.****.conf;
}

domain.u.ysctest.conf

1
2
3
4
5
6
7
server {
listen 80;
server_name u.ysctest.cn;
location ~ "^/(.*)+/(.*)+$"{
rewrite /(.*)/(.*) 'http://api.ysctest.cn/v1.1/tc/url/shorted/jump?params={"shortSubDomain":"$1","shortCode":"$2"}' break;
}
}
软连接
1
2
ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/nginx

命令

检查
1
nginx -t
启动
1
nginx
重载
1
nginx -s relaod
停止
1
nginx -s stop

docker

引言

参考菜鸟教程<CentOS Docker 安装> https://www.runoob.com/docker/centos-docker-install.html

安装

安装yum管理
1
2
3
sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
设置源地址
1
2
3
sudo yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
安装
1
sudo yum install docker-ce docker-ce-cli containerd.io

命令

启动
1
sudo systemctl start docker
停止
1
sudo systemctl stop docker
查看images 存储位置
1
2
3
4
5
6
7
8
docker info | grep "Docker Root Dir"

查看实际大小

du -sh *

# 排序
du -sh * | sort -h

mysql(docker)

安装

创建映射文件夹
1
mkdir -p /usr/local/dockerSpace/mysql/{conf,data}
拉取镜像
1
2
docker pull mysql:5.7.26

运行
1
2
3
4
5
docker run -p 3306:3306 \
--name mysql1 \
-v /usr/local/dockerSpace/mysql/conf:/etc/mysql \
-v /usr/local/dockerSpace/mysql/data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7.26

redis

安装

参考链接
1
2
https://www.runoob.com/redis/redis-install.html
https://www.runoob.com/redis/redis-conf.html
下载
1
https://download.redis.io/releases/redis-6.2.5.tar.gz
解压
1
tar -zxvf redis-6.2.5.tar.gz
移动
1
mv redis-6.2.5 /usr/local/redis
安装
1
make
软连接
1
2
3
ln -s /usr/local/redis/src/redis-server /usr/local/bin/redis-server

ln -s /usr/local/redis/src/redis-cli /usr/local/bin/redis-cli
修改配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
vim redis.conf

https://www.runoob.com/redis/redis-conf.html


# 守护进程
# daemonize no
daemonize yes

# bind 127.0.0.1
bind 0.0.0.0

# 密码
# requirepass foobared
requirepass 123456

启动

1
redis-server redis.conf

mongodb(docker)

创建映射文件夹

1
mkdir -p /usr/local/dockerSpace/mongodb/{data,conf}

安装

拉取镜像
1
2
docker pull mongo:latest

运行
1
2
3
4
5
6
docker run -it --name mongodb1 --privileged=true \
-e MONGO_INITDB_ROOT_USERNAME=admin \
-e MONGO_INITDB_ROOT_PASSWORD=123456 \
-v /usr/local/dockerSpace/mongodb/data:/data/db \
-v /usr/local/dockerSpace/mongodb/conf:/data/configdb \
-p 27017:27017 -d mongo

rabbit mq

参考链接 https://www.cnblogs.com/fengyumeng/p/11133924.html

1
yum -y install gcc glibc-devel make ncurses-devel openssl-devel xmlto perl wget gtk2-devel binutils-devel

opt_src

下载opt_src
1
https://erlang.org/download/otp_src_24.0.tar.gz
解压
1
tar -zxvf otp_src_24.0.tar.gz
移走
1
mv otp_src_24.0 /usr/local/
切换目录
1
cd /usr/local/otp_src_24.0/
创建即将安装的目录
1
mkdir ../erlang
配置安装路径
1
./configure --prefix=/usr/local/erlang
问题1
1
2
3
4
问题日志:
configure: error: No curses library functions found
ERROR: /data/app/otp_src_23.2.5/erts/configure failed!
Killed
解决方案
1
yum -y install ncurses-devel
安装
1
make && make install
配置
1
2
3
echo 'export PATH=$PATH:/usr/local/erlang/bin' >> /etc/profile
source /etc/profile

rabbitmq

下载
1
https://www.rabbitmq.com/install-generic-unix.html
解压
1
tar -xvf rabbitmq-server-generic-unix-3.9.5.tar.xz
移动
1
mv rabbitmq_server-3.9.5/ /usr/local/rabbitmq
1
2
echo 'export PATH=$PATH:/usr/local/rabbitmq/sbin' >> /etc/profile
source /etc/profile
启动
1
rabbitmq-server -detached
停止
1
rabbitmqctl stop
状态
1
rabbitmqctl status
web插件
1
rabbitmq-plugins enable rabbitmq_management
查看所有用户
1
rabbitmqctl list_users
添加一个用户
1
rabbitmqctl add_user admin 123456
配置权限
1
rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"
查看用户权限
1
rabbitmqctl list_user_permissions admin
设置tag
1
rabbitmqctl set_user_tags admin administrator
删除用户(安全起见,删除默认用户)
1
2
rabbitmqctl delete_user guest
切记重新启动 刷新权限

centos 8.4 ssl认证错误

问题

Centos8访问本机mysql出现如下错误:

1
2026, 'SSL connection error: error:1425F102:SSL routines:ssl_choose_client_versi

解决

1
2
3
4
vim /etc/crypto-policies/back-ends/opensslcnf.config
# MinProtocol = TLSv1.2
# 这里把1.2改成1.1
MinProtocol = TLSv1.1
  • 本文作者: Ysc Test
  • 本文链接: https://ysctest.cn/posts/b5fe61bb.html
  • 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
  • 法律声明: 本博客提供的所有包括但不限于(文章和API)等服务,仅用于学习,技术分享、交流。不得用于违法犯罪、损害国家利益。非法使用者本站不承担任何法律责任,并且本站保留追究其法律责任的权力!!!