4

springAlibaba实践(一)

 2 years ago
source link: http://www.blogjava.net/zzsuje/archive/2022/04/20/450721.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
springAlibaba实践(一) - zzsuje - BlogJava
第⼀章 搭建项⽬环境
1.1VirtualBox虚拟机安装CentOS7
    1.1.1 下载&安装VirtualBox虚拟机.
             下载地址: https://www.virtualbox.org/, 开开启CPU虚拟化
    1.1.2 下载&安装Vagrant              第⼀步: 下载地址: https://www.vagrantup.com/
              第⼆步: 命令⾏键⼊: vagrant
              测试安装是否成功,
             第三步: vagrant init centos/7   初始化

 第四步: vagrant up 下载启动镜像

vagrant up
有下载过慢的问题,可以复制链接到网页上下载

或者:
一、进入vagrant官网 https://www.vagrantup.com/
二、点击findbox【寻找box】,进入有很多box的列表 https://app.vagrantup.com/boxes/search
三、下载链接:https://cloud.centos.org/centos/7/vagrant/x86_64/images/CentOS-7-x86_64-Vagrant-2004_01.VirtualBox.box
这里的2004_01可以修改成自己想要的版本
四 加载下载的镜像

添加镜像语法

vagrant box add [名称] [源路径]
添加 centos/7 镜像

已经下载好的 源文件路径: E:\cenos\CentOS-7-x86_64-Vagrant-2004_01.VirtualBox.box

 第五步 :重新加载镜像
vagrant up

第五步:vagrant ssh

 虚拟机网络配置

C:\Users\Medimpact(peking)\Vagrantfile

  config.vm.network "private_network", ip: "192.168.56.100"

 配置保存后 需重启虚拟机

 或者命令行

ping 192.168.56.100

另:
      为什么使用56.100  
      ipconfig本机


       虚拟机的ip 为56段的
       设置virtualBox的网络链接方式为 仅主机(Host-Only)网络

下载FinalShell链接192.168.56.100

用户名 root

密码 vagrant

连接不成功

说明没有开启远程连接

sudo vi  ect/ssh/sshd_config

查看文件 点I

Insert

改动两个选项

PermitRootLogin yes

passwordAuthentication yes

修改成功后

systemctl  restart sshd

按insert 编辑 

:wq 保存退出

用final shell 连接  192.168.56.100 用户 root 密码 vagrant

docker 安装

 $sudo yum remove docker \                   docker-client \                   docker-client-latest \                   docker-common \                   docker-latest \                   docker-latest-logrotate \                   docker-logrotate \                   docker-engine

 sudo yum install -y yum-utils

 sudo yum-config-manager \

  --add-repo \   https://download.docker.com/linux/centos/docker-ce.repo
 sudo yum install docker-ce docker-ce-cli containerd.io

安装完成后

docker -v  查看docker版本

docker images   查看docker 已有镜像 (未启动)

 启动docker

设置docker 开机启动

使用阿里云的镜像加速器   在阿里云的控制台中 找产品和服务 ---容器镜像服务---镜像加速器

 https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors

1.sudo mkdir -p /etc/docker 2.sudo tee /etc/docker/daemon.json <<-'EOF' {   "registry-mirrors": ["https://d6gqzuc3.mirror.aliyuncs.com"] } EOF 3.sudo systemctl daemon-reload 4.sudo systemctl restart docker  安装mysql 
https://hub.docker.com/_/mysql?tab=tags&page=1&ordering=last_updated 

   docker pull mysql:5.7

安装成功后 查看镜像

docker images

 设置端口映射

sudo docker run -p 3306:3306 --name mysql \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=root \
-d mysql:5.7

 docker ps 查看已启用的容器

修改配日志文件

 [client]

default-character-set=utf8

[mysql]
default-character-set=utf8
[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve

保存后 重启 设置 启动docker时 即运行mysql

docker pull redis

配置Redis服务
# 创建配置⽂件存储路径
mkdir -p /mydata/redis/conf
# 创建配置⽂件
touch /mydata/redis/conf/redis.conf
# 填写配置信息【数据持久化AOF】
echo "appendonly yes" >> /mydata/redis/conf/redis.conf
启动redis镜像
docker run -p 6379:6379 --name redis -v /mydata/redis/data:/data \
-v /mydata/redis/conf/redis.conf:/etc/redis/redis.conf \
-d redis redis-server /etc/redis/redis.conf
测试redis
# 进⼊redis容器,并且执⾏redis-cli的命令
docker exec -it redis redis-cli
设置redis容器在Docker启动的时候启动
docker update redis --restart=always

https://docs.spring.io/spring-boot/docs/2.1.18.RELEASE/reference/html/

https://docs.spring.io/spring-boot/docs/2.1.18.RELEASE/reference/html/getting-started-installing-spring-boot.html#getting-started-maven-installation

 替换自己的pom文件

Greenwich.SR3


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK