Docker部署服务

nacos部署

docker pull nacos/nacos-server:2.0.3
docker run --name nacos -d -p 8848:8848 -p 9848:9848 -p 9849:9849 --privileged=true --restart=always -e MODE=standalone -e PREFER_HOST_MODE=hostname -e NACOS_SERVER_IP=123.56.122.89 nacos/nacos-server:2.0.3

seata部署

简单部署:

存储模式与注册方式使用file

docker pull seataio/seata-server:1.4.2
docker run --name seata-server -p 8091:8091 seataio/seata-server:1.4.2

高可用部署:

依赖于注册中心、配置中心和数据库来实现。

存储模式:redis、注册中心:nacos、配置中心:nacos

1、自定义配置文件:

创建registry.conf

registry {
  # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
  type = "nacos"
  nacos {
    application = "seata-server"
    serverAddr = "nacos:8848"
    group = "SEATA_GROUP"
    namespace = "SEATA"
    cluster = "default"
    username = ""
    password = ""
  }
}
config {
  # file、nacos 、apollo、zk、consul、etcd3
  type = "nacos"
  nacos {
    serverAddr = "nacos:8848"
    namespace = "SEATA"
    group = "SEATA_GROUP"
    username = ""
    password = ""
    dataId = "seataServer.properties"
  }
}

修改nacos的地址,而命名空间、分组、配置文件dataId使用默认即可。

上传 registry.conf 到服务器到自定义路径 如 /opt/seata/config

2、nacos中添加配置文件

  • nacos中添加命名 seata
  • 添加配置文件seataServer.properties

使用新建的seata命名空间,分组为SEATA_GROUP。

service.vgroupMapping.my_tx_group=default
store.mode=redis
-----db-----
store.db.datasource=druid
store.db.dbType=mysql
store.db.driverClassName=com.mysql.jdbc.Driver
store.db.url=jdbc:mysql://127.0.0.1:3306/seata?useUnicode=true
store.db.user=root
store.db.password=root
----redis----
store.redis.host=redis
store.redis.port=6379
store.redis.maxConn=10
store.redis.minConn=1
store.redis.database=0
store.redis.password=root
store.redis.queryLimit=100
----client----
client.undo.logTable=undo_log 

修改redis/db的地址、密码等参数

3、启动seata

自定义配置文件需要通过挂载文件的方式实现,将宿主机上的 registry.conf 和 file.conf 挂载到容器中相应的目录

使用自定义配置文件时必须指定环境变量 SEATA_CONFIG_NAME, 并且值需要以file:开始, 如: file:/root/seata-config/registry

指定seata-server IP 为服务器IP,若服务器外部网络无法穿透服务器访问docker,将seata-server IP指定为服务器IP。该IP用于向注册中心注册时使用, 如nacos等

docker run -d --name seata-server \
        -p 8091:8091 \
		--link nacos:nacos \
		--link redis:redis \
        -e SEATA_CONFIG_NAME=file:/root/seata-config/registry \
		-e SEATA_IP=192.168.127.48 \
        -v /root/seata/config:/root/seata-config  \
        seataio/seata-server:1.4.2

其中 -e 用于配置环境变量, -v 用于挂载宿主机的目录

4、创建回滚日志表

在项目数据源需要连接的个每个数据库中创建回滚日志表"undo_log"

CREATE TABLE `undo_log` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `branch_id` bigint(20) NOT NULL,
  `xid` varchar(100) NOT NULL,
  `context` varchar(128) NOT NULL,
  `rollback_info` longblob NOT NULL,
  `log_status` int(11) NOT NULL,
  `log_created` datetime NOT NULL,
  `log_modified` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

springboot YML文件配置

seata:
    enabled: true
    enable-auto-data-source-proxy: false
    application-id: ${spring.application.name}
    tx-service-group: my_tx_group  
    service:
        vgroup-mapping:
            my_tx_group: default
    config:
        type: nacos
        nacos:
            server-addr: 127.0.0.1:8848
            group: "SEATA_GROUP"
            namespace: "seata"
            dataId: "seataServer.properties"
            username: ""
            password: ""
    registry:
        type: nacos
        nacos:
            application: seata-server
            server-addr: 127.0.0.1:8848
            group: "SEATA_GROUP"
            namespace: "seata"
            username: ""
            password: ""

Oracle11g

1. 开始拉取镜像 - 执行命令:

docker pull registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g

2. 创建容器

docker run -d -p 1521:1521 --name oracle11g registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g

3. 启动容器

docker start oracle11g

进入镜像进行配置

docker exec -it oracle11g bash

切换到 root 用户下

su root
密码:helowin

4. 编辑 profile 文件配置 ORACLE 环境变量

在 docker 中查找并编辑 profile 文件 vi /etc/profile

export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
export ORACLE_SID=helowin
export PATH=$ORACLE_HOME/bin:$PAT

在最后加上

保存并退出 :wq

5. oracle 的配置

1. 创建软连接
ln -s $ORACLE_HOME/bin/sqlplus /usr/bin
2. 切换到 oracle 用户

这里还要说一下,一定要写中间的 - 必须要,否则软连接无效

6. oracle 数据库的操作

1. 登录 sqlplus 并修改 sys、system 用户密码
sqlplus /nolog
conn /as sysdba
2. 修改和创建用户

接着执行下面命令

alter user system identified by system;

alter user sys identified by sys;

也可以创建用户  create user test identified by test;

并给用户赋予权限  grant connect,resource,dba to test;
3. scott 用户的开启
--解锁scott用户(安装时若使用默认情况没有解锁和设置密码进行下列操作,要超级管理员操作)
alter user scott account unlock;

--解锁scott用户的密码【此句也可以用来重置密码】
alter user scott identified by tiger;

7. navicat 连接

打开 navicat 后(navicat12 不用配置 oci.dll 文件了)

直接新建连接

MongoDB

1、取最新版的 MongoDB 镜像

这里我们拉取官方的最新版本的镜像:

docker pull mongo:latest

3、查看本地镜像

使用以下命令来查看是否已安装了 mongo:

docker images

在上图中可以看到我们已经安装了最新版本(latest)的 mongo 镜像。

4、运行容器

安装完成后,我们可以使用以下命令来运行 mongo 容器:

docker run -itd --name mongo -p 27017:27017 mongo --auth

参数说明:

  • -p 27017:27017 :映射容器服务的 27017 端口到宿主机的 27017 端口。外部可以直接通过 宿主机 ip:27017 访问到 mongo 的服务。
  • –auth:需要密码才能访问容器服务。

5、安装成功

最后我们可以通过 docker ps 命令查看容器的运行信息:

接着使用以下命令添加用户和设置密码,并且尝试连接。

$ docker exec -it mongo mongo admin
# 创建一个名为 admin,密码为 root 的用户。
>  db.createUser({ user:'admin',pwd:'root',roles:[ { role:'userAdminAnyDatabase', db: 'admin'},"readWriteAnyDatabase"]});
# 尝试使用上面创建的用户信息进行连接。
> db.auth('admin', 'root')

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值