2、使用方法
使用方法
目录
[toc]
案例:将小主机frp出去方法(可选)
==本人组网环境==
为什么要用这种方式呢?
因为穷哇啊啊啊,哈哈。😂(云服务器贼贵)
我目前只有1台2c2g的云服务器,已经部署了docusaurus,但是不能正常部署次ruyu-blog博客。刚好我有1台nuc(小体积电脑),于是我经nuc frp出去,经测试网络是能正常使用的哦,完美。😘
关于frp如何搭建,请看如下手把手教程:
https://onedayxyy.cn/docusaurus/docs/docker-install-frp 《实战:docker式部署frp内网穿透-2024.7.13(测试成功)》
- 本次涉及frp配置
##在公网服务器上执行。
cat >>/root/frps.ini <<EOF
[common]
# 监听端口
bind_port = 7000
# 面板端口
dashboard_port = 7500
# 登录面板账号设置
dashboard_user = admin
# 登录面板的密码
dashboard_pwd = "输入你的密码!!!"
# 身份验证,这里需要修改为自己的token
token = "输入你的密码!!!" #这里务必要和下面frpc的token保持一致
EOF
docker run --restart=always --network host -d -v /root/frps.ini:/etc/frp/frps.ini --name frps registry.cn-shenzhen.aliyuncs.com/mogublog_business/frps
##在本地nuc上陪追
cat > /root/frpc.ini << EOF
[common]
# server_addr为云服务器IP地址
server_addr = http://47.97.48.237:8080/
# server_port为服务端监听端口,bind_port
server_port = 7000
# 服务端设置的token,身份验证,这里需要修改为自己的token
token = "输入你的密码!!!" #这里务必要和上面的frps的token保持一致
[ruyu-blog]
type = tcp
local_ip = 127.0.0.1
local_port = 80
remote_port = 8080
[ruyu-blog-admin]
type = tcp
local_ip = 127.0.0.1
local_port = 81
remote_port = 8081
EOF
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 8022
EOF
docker run --restart=always --network host -d -v /root/frpc.ini:/etc/frp/frpc.ini --name frpc registry.cn-shenzhen.aliyuncs.com/mogublog_business/frpc
- 访问:
案例:ruyu-blog启动/关闭服务(已解决)
- 配置脚本
#一键启动涉及ruyu-blog所有容器:
cat > /root/upRuyuBlog.sh <<EOF
#!/bin/bash
cd /data/mysql
docker-compose up -d
cd /data/redis
docker-compose up -d
docker start rabbit
cd /data/minio
docker-compose up -d
docker start netease_cloud_music_api ruyu-blog-hd blog-qt blog-ht frpc
docker ps
EOF
#一键关闭涉及ruyu-blog所有容器:
cat > /root/downRuyuBlog.sh <<EOF
#!/bin/bash
cd /data/mysql
docker-compose down
cd /data/redis
docker-compose down
docker stop rabbit
cd /data/minio
docker-compose down
docker stop disable netease_cloud_music_api ruyu-blog-hd blog-qt blog-ht frpc
docker ps
EOF
- 配置开机自启
chmod +x /root/upRuyuBlog.sh
chmod +x /root/downRuyuBlog.sh
chmod +x /etc/rc.d/rc.local
echo "/root/upRuyuBlog.sh" >> /etc/rc.d/rc.local
- 测试
查看配置:
当前是无docke容器的:
重启机器:
reboot
验证:(符合预期)
- 如何使用(测试成功)
#启动ruyu-blog服务
sh /root/upRuyuBlog.sh
#关闭ruyu-blog服务
sh /root/downBlog.sh
案例:修改网站名称(已解决)
案例:修改mysql root密码(已解决)
docker ps|grep mysql
docker exec -it mysql bash
mysql -uroot -p123456
use mysql;
mysql -u root -p
USE mysql;
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '新密码';
修改完后记得测试下:
奇怪,修改了,怎么没生效?
再修改一次:
mysql -u root -p
USE mysql;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';
符合预期。
案例:导出本地所有镜像(已解决)
docker save `docker images | cut -f1 -d ' ' | sed -n '2,$p'` |gzip > ruyu-blog-install-all-images.tar.gz
范例:一键删除部署资源(已解决)
cd /data/mysql
docker-compose down
cd /data/redis
docker-compose down
cd /data/minio
docker-compose down
docker stop rabbit
docker stop netease_cloud_music_api
docker stop ruyu-blog-hd blog-qt blog-ht
##销毁数据
docker rm -f rabbit netease_cloud_music_api ruyu-blog-hd blog-qt blog-ht
docker rmi -f ruyu-blog-hd blog-qt blog-ht
rm -rf /data/mysql /data/redis /data/minio
rm -rf /root/ruyu-blog-v1.2.0
cd ~
##
范例:3个核心配置文件(已解决)
xxx