-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wugenqiang
committed
Sep 18, 2022
1 parent
2e42f8c
commit 7b52207
Showing
43 changed files
with
465 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# Mac安装docker | ||
|
||
> docker官网:https://hub.docker.com/ | ||
## docker简介 | ||
|
||
docker是一个开源的应用容器引擎,基于Go语言并遵从Apache2.0协议开源。 | ||
|
||
docker可以让开发者打包他们的应用以及依赖包到一个轻量级、可移植的容器中,然后发布到任何流行的Linux机器上,也可以实现虚拟化。 | ||
|
||
容器是完全使用沙箱机制,相互之间不会有任何接口,更重要的是容器性能开销极低。 | ||
|
||
## 安装步骤 | ||
|
||
1、下载docker | ||
|
||
进入docker官网,点击图中按钮即可下载docker, | ||
|
||
![](../../../../images/20220820-01-docker.png) | ||
|
||
或者使用以下链接下载docker | ||
[Intel Chip的Mac](https://desktop.docker.com/mac/main/amd64/Docker.dmg?utm_source=docker&utm_medium=webreferral&utm_campaign=dd-smartbutton&utm_location=module) | ||
[Apple Chip的Mac](https://desktop.docker.com/mac/main/arm64/Docker.dmg?utm_source=docker&utm_medium=webreferral&utm_campaign=dd-smartbutton&utm_location=module) | ||
|
||
2、安装docker | ||
|
||
直接点击下载好的`Docker.dmg`即可。 | ||
|
||
安装成功后,可在终端检查docker版本,显示版本后,表示安装成功。 | ||
|
||
```shell | ||
docker --version | ||
``` | ||
|
||
如图所示: | ||
|
||
![](../../../../images/20220820-02-docker.png) | ||
|
||
3、镜像加速 | ||
|
||
如果因为网络问题拉取Docker镜像缓慢的话, 可以配置加速器。目前我是使用网易的。 | ||
|
||
```shell | ||
http://hub-mirror.c.163.com | ||
``` | ||
|
||
打开docker软件,点击设置图标进入,会出现下图所示的界面: | ||
|
||
![](../../../../images/20220820-03-docker.png) | ||
|
||
在红框处进行添加以下代码后,点击Apply & Restart 按钮: | ||
|
||
```shell | ||
{ | ||
"builder": { | ||
"gc": { | ||
"enabled": true, | ||
"defaultKeepStorage": "20GB" | ||
} | ||
}, | ||
"experimental": false, | ||
"features": { | ||
"buildkit": true | ||
}, | ||
"registry-mirrors":[ | ||
"http://hub-mirror.c.163.com" | ||
] | ||
} | ||
``` | ||
|
||
查看是否应用镜像成功,红框内容就是上面配置的国内镜像: | ||
|
||
```shell | ||
docker info | ||
``` | ||
|
||
![](../../../../images/20220820-04-docker.png) | ||
|
||
|
||
|
||
> 附docker国内常用镜像: | ||
> | ||
> 1、中科大: https://docker.mirrors.ustc.edu.cn | ||
> | ||
> 2、网易: http://hub-mirror.c.163.com | ||
> | ||
> 3、Docker 官方中国区: https://registry.docker-cn.com | ||
> | ||
> 4、七牛云: https://reg-mirror.qiniu.com | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Mac安装Navicat | ||
|
||
> Navicat官网:http://www.navicat.com.cn/ | ||
申请许可证,学生可以申请学术伙伴计划,申请链接:http://www.navicat.com.cn/sponsorship/education/student | ||
|
||
![](../../../../images/20220820-05-navicat.png) | ||
|
||
下载Navicat | ||
|
||
官网下载即可,输入申请的许可证,即可免费使用一年 | ||
|
||
![](../../../../images/20220820-06-navicat.png) | ||
|
||
隔了两天就收到了填写信息的邮件: | ||
|
||
![](../../../../images/20220822-03-任何来源.png) | ||
|
||
填写教育版申请信息表,按照操作完成即可 | ||
|
94 changes: 94 additions & 0 deletions
94
Java/Java_Web/中小型软件项目开发实战/00-环境准备/03-在Mac上如何使用Sql Server.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# 在Mac上如何使用SQL Server | ||
|
||
> SQL Server一般是在Windows上使用,要是在mac中使用,需要借助`docker`来完成,接下来介绍如何通过docker来部署SQL Server。 | ||
## 1、拉取SQL Server 2019镜像 | ||
|
||
官方文档:https://docs.microsoft.com/zh-cn/sql/linux/quickstart-install-connect-docker?view=sql-server-linux-ver15&pivots=cs1-bash | ||
|
||
从 Microsoft 容器注册表中请求 SQL Server 2019 (15.x) Linux 容器映像 | ||
|
||
```shell | ||
sudo docker pull mcr.microsoft.com/mssql/server:2019-latest | ||
``` | ||
|
||
![](../../../../images/20220823-01-sql.png) | ||
|
||
查看下载的镜像 | ||
|
||
```shell | ||
sudo docker images | ||
``` | ||
|
||
![](../../../../images/20220823-02-sql.png) | ||
|
||
就可以看到刚刚下载的SQL Server镜像了 | ||
|
||
## 2、使用docker运行SQL Server容器 | ||
|
||
```shell | ||
sudo docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=<YourStrong@Passw0rd>" -p 1433:1433 --name sql20220823 -d mcr.microsoft.com/mssql/server:2019-latest | ||
``` | ||
|
||
> 注:密码应符合 SQL Server 默认密码策略,否则容器无法设置 SQL Server,将停止工作。 默认情况下,密码的长度必须至少为 8 个字符,并且必须包含以下四种字符中的三种:大写字母、小写字母、十进制数字和符号。 你可以通过执行 docker logs 命令检查错误日志。 | ||
下表对前一个 `docker run` 示例中的参数进行了说明: | ||
|
||
![](../../../../images/20220823-03-sql.png) | ||
|
||
要查看 Docker 容器,请使用 `docker ps` 命令 | ||
|
||
```shell | ||
docker ps -a | ||
``` | ||
|
||
![](../../../../images/20220823-04-sql.png) | ||
|
||
更改SA密码: | ||
|
||
SA 帐户是安装过程中在 SQL Server 实例上创建的系统管理员。 创建 SQL Server 容器后,通过在容器中运行 echo $SA_PASSWORD,可发现指定的 SA_PASSWORD 环境变量。 出于安全考虑,请考虑更改 SA 密码。 | ||
|
||
选择 SA 用户要使用的强密码。 | ||
使用 docker exec 运行sqlcmd ,以使用 Transact-SQL 更改密码。 在下面的示例中,将旧密码 `<YourStrong@Passw0rd>`和新密码 `<YourNewStrong@Passw0rd>` 替换为你自己的密码值。 | ||
|
||
```shell | ||
sudo docker exec -it sql20220823 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "<YourStrong@Passw0rd>" -Q 'ALTER LOGIN SA WITH PASSWORD="<YourNewStrong@Passw0rd>"' | ||
``` | ||
|
||
## 3、进入容器,连接到SQL Server | ||
|
||
> 下列步骤在容器内部使用SQL Server命令行工具sqlcmd来连接SQL Server | ||
进入容器: | ||
|
||
```shell | ||
sudo docker exec -it sql20220823 "bash" | ||
``` | ||
|
||
> 使用 `docker exec -it` 命令在运行的容器内部启动交互式 Bash Shell | ||
在容器内部使用 sqlcmd 进行本地连接。 默认情况下,sqlcmd 不在路径之中,因此需要指定完整路径。 | ||
|
||
```shell | ||
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "输入你的密码" | ||
``` | ||
|
||
如果成功,应会显示 sqlcmd 命令提示符:1> | ||
|
||
在容器中退出交互式命令提示,请键入 `exit`。 退出交互式 Bash Shell 后,容器将继续运行。 | ||
|
||
![](../../../../images/20220823-05-sql.png) | ||
|
||
## 4、使用Navicat连接 | ||
|
||
> Navicat是一套可创建多个连接的数据库管理工具,用以方便管理 [MySQL](https://baike.baidu.com/item/MySQL/471251)、[Oracle](https://baike.baidu.com/item/Oracle/301207)、[PostgreSQL](https://baike.baidu.com/item/PostgreSQL/530240)、[SQLite](https://baike.baidu.com/item/SQLite/375020)、[SQL Server](https://baike.baidu.com/item/SQL Server/245994)、[MariaDB](https://baike.baidu.com/item/MariaDB/6466119) 和 [MongoDB](https://baike.baidu.com/item/MongoDB/60411) 等不同类型的数据库 | ||
百度云链接: https://pan.baidu.com/s/1ZA4wibPZXTjuZ2Ra3XC3Rw?pwd=aa2h 提取码: aa2h | ||
|
||
下载好后添加Sql Server数据库连接: | ||
|
||
![](../../../../images/20220823-06-sql.png) | ||
|
||
最后,连接成功!就可以进行数据库设计了,真棒!☘️ | ||
|
||
![](../../../../images/20220823-07-sql.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# 开启允许“任何来源”选项 | ||
|
||
> Mac从macOS Sierra 10.12开始,已经去除了允许“任何来源”的选项,如果不开启“任何来源”选项,会直接影响到无法运行第三方应用。比如出现这个问题: | ||
![](../../../../images/20220822-01-任何来源.png) | ||
|
||
开启方法如下: | ||
|
||
1、打开终端,输入命令 | ||
|
||
```shell | ||
sudo spctl --master-disable | ||
``` | ||
|
||
2、打开系统偏好设置,进入安全性和隐私,会发现已经选定“任何来源” | ||
|
||
![](../../../../images/20220822-02-任何来源.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# 安装Tomcat | ||
|
||
> Tomcat服务器是一个免费的开放源代码的Web应用服务器,属于轻量级应用服务器,在中小型系统和并发访问用户不是很多的场合下被普遍使用,是开发和调试JSP程序的首选。 | ||
## 1、下载Tomcat | ||
|
||
首先,进Tomcat官网(https://tomcat.apache.org/),选择所需要的Tomcat版本,这里我选择的是Tomcat9。 | ||
|
||
![](../../../../images/20220824-01-tomcat.png) | ||
|
||
点击进去,选择zip(pgp, sha512)下载。 | ||
|
||
![](../../../../images/20220824-02-tomcat.png) | ||
|
||
## 2、解压 | ||
|
||
下载完成后,使用解压缩软件进行解压,并将文件放入/Library(资源库)中。 | ||
|
||
![](../../../../images/20220824-03-tomcat.png) | ||
|
||
> 将上图的文件拷贝放在/Library(资源库中):找到Tomcat文件并拷贝,然后按`shift+command+g` 弹出下面的窗口,在此窗口输入:~/Library,点击前往 | ||
![](../../../../images/20220824-04-tomcat.png) | ||
|
||
把Tomcat文件粘贴到此目录下,如图所示: | ||
|
||
![](../../../../images/20220824-05-tomcat.png) | ||
|
||
## 3、配置Tomcat | ||
|
||
打开终端,先给tomcat文件bin目录下的所有.sh文件赋予执行权限,输入命令: | ||
|
||
```shell | ||
sudo chmod 755 /Users/wugenqiang/Library/apache-tomcat-9.0.65/bin/*.sh | ||
``` | ||
|
||
> chmod:改变一个或多个文件的存取模式 | ||
> | ||
> 755:代表用户对该文件拥有读、写、执行的权限,同组的其他人员拥有执行和读的权限,没有写的权限,其他用户的权限和同组人员一样。 | ||
> | ||
> 777:代表user, group,others,都具有读、写、执行的权限。 | ||
在终端中继续输入下面命令,进入bin目录下: | ||
|
||
```shell | ||
cd /Users/wugenqiang/Library/apache-tomcat-9.0.65/bin | ||
``` | ||
|
||
## 4、启动Tomcat | ||
|
||
```shell | ||
./startup.sh | ||
``` | ||
|
||
Tomcat顺利启动成功,终端操作过程如图所示: | ||
|
||
![](../../../../images/20220824-06-tomcat.png) | ||
|
||
在浏览器中输入:http://localhost:8080/,出现下面界面,表示Tomcat真正启动成功。 | ||
|
||
![](../../../../images/20220824-07-tomcat.png) | ||
|
||
## 5、关闭Tomcat | ||
|
||
终端中输入`./shutdown.sh`就可以关闭Tomcat服务器了。 | ||
|
||
```shell | ||
./shutdown.sh | ||
``` | ||
|
||
注意:启动Tomcat或关闭Tomcat都要在`bin`目录下进行。 |
70 changes: 70 additions & 0 deletions
70
Java/Java_Web/中小型软件项目开发实战/00-环境准备/06-Mac Docker SQL Server导入.mdf.ldf文件.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Mac Docker SQL Server导入.mdf/.ldf文件 | ||
|
||
> 难受哇,之前用Navicat连接上了Docker SQL Server容器,但是导入不了`.mdf`和`.ldf`文件,今天搜集了好几个小时的资料,终于解决了这个问题: | ||
1、创建带有数据卷的SQL Server容器 | ||
|
||
```shell | ||
docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=Wgq520lmf' -p 1433:1433 --name sql20220825 -v sqlvolume:/var/opt/mssql -d mcr.microsoft.com/mssql/server:2019-latest | ||
``` | ||
|
||
2、使用 `docker volume ls` 查看是否创建成功,成功的话会显示如图所示: | ||
|
||
![](../../../../images/20220825-01-sql.png) | ||
|
||
3、修改SA密码: | ||
|
||
SA 帐户是安装过程中在 SQL Server 实例上创建的系统管理员。 创建 SQL Server 容器后,通过在容器中运行 echo $SA_PASSWORD,可发现指定的 SA_PASSWORD 环境变量。 出于安全考虑,需要更改 SA 密码。 | ||
|
||
```shell | ||
sudo docker exec -it sql20220825 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "Wgq520lmf" -Q 'ALTER LOGIN SA WITH PASSWORD="Wgq520lmf"' | ||
``` | ||
|
||
4、在docker容器中创建文件夹并把`.mdf`和`.ldf`文件复制进去: | ||
|
||
```shell | ||
docker exec -it sql20220825 mkdir /var/opt/mssql/data | ||
docker cp /Users/wugenqiang/Desktop/sql/xx.mdf sql20220825:/var/opt/mssql/data/xx.mdf | ||
docker cp /Users/wugenqiang/Desktop/sql/xx.ldf sql20220825:/var/opt/mssql/data/xx.ldf | ||
``` | ||
|
||
4、然后修改`.mdf`和`.ldf`文件的权限!会发现,复制进去的文件没有写权限!这一步一定要用root用户访问,不然没有修改权限! | ||
|
||
![](../../../../images/20220825-02-sql.png) | ||
|
||
使用root用户启动docker容器: | ||
|
||
```shell | ||
docker exec -it -u root sql20220825 "bash" | ||
``` | ||
|
||
改权限可以用: | ||
|
||
```shell | ||
chmod 666 xx.ldf | ||
chown -R root:root xx.ldf | ||
``` | ||
|
||
5、接下来用Navicat Premium导入。 | ||
|
||
(1)先连接sql-server,然后新建数据库。 | ||
|
||
(2)双击数据库打开(变绿色),然后点击左上方的新建查询,输入下面代码(dbname无所谓): | ||
|
||
```shell | ||
EXEC sp_attach_db @dbname = 'db_mediaBlog', | ||
@filename1 = '/var/opt/mssql/data/db_mediaBlog_Data.mdf', | ||
@filename2 = '/var/opt/mssql/data/db_mediaBlog_Log.ldf' | ||
``` | ||
|
||
结果如下: | ||
|
||
![](../../../../images/20220825-03-sql.png) | ||
|
||
需要重启Navicat Premium才能看见,重启。 | ||
|
||
导入成功! | ||
|
||
![](../../../../images/20220825-04-sql.png) | ||
|
||
这一路太不容易了,还是要继续加油! |
Oops, something went wrong.