-- mysql 账号密码:root/root 端口:3306
-- 创建目录
mkdir -p /opt/mysql/data
mkdir -p /opt/mysql/conf.d
-- 配置文件更新
# cat mysqld.cnf |grep -v "#"
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
symbolic-links=0
character_set_server=utf8mb4
-- 启动
docker run -d --privileged=true -v /opt/mysql/data/:/var/lib/mysql -v /opt/mysql/conf.d/:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=root -p 3306:3306 --name mysql-vava mysql:5.7
-- 数据同步
-- 导出
mysqldump --opt -h 27.174.233.112 -u root -proot all_in_one >d:\all_in_one.sql
mysqldump --opt -h 27.174.233.112 -u root -proot vava_track >d:\vava_track.sql
mysqldump --opt -h 27.174.233.112 -u root -proot purchase_express >d:\purchase_express.sql
mysqldump --opt -h 27.174.233.112 -u root -proot purchase_message>d:\purchase_message.sql
mysqldump --opt -h 27.174.233.112 -u root -proot trade_vava>d:\trade_vava.sql
-- 恢复
mysql -h 147.9.186.133 -u root -proot
source d:\all_in_one.sql
source d:\vava_track.sql
source d:\purchase_express.sql
source d:\purchase_message.sql
source d:\trade_vava.sql
-- mongo 账号密码:admin/admin 端口:27017
-- 创建目录
mkdir -p /opt/mongodb/data
-- 启动 --auth参数用于启用密码认证
docker run -d --name mongo -p 27017:27017 -v /opt/mongodb/data:/data/db mongo:3.4 --auth
-- 启动容器交互命令行
docker exec -it mongo /bin/bash
-- 登录数据库并创建用户
mongo
db.createUser(
{
user: "admin",
pwd: "admin",
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
}
)
mongo 147.9.186.133:27017/admin -u admin -p admin
use vava_product
db.createUser({user:"a",pwd:"a",roles:[{role:"dbAdmin",db:"vava_product"}]})
use vava_admin
db.createUser({user:"a",pwd:"a",roles:[{role:"dbAdmin",db:"vava_admin"}]})
use vava_log
db.createUser({user:"a",pwd:"a",roles:[{role:"dbAdmin",db:"vava_log"}]})
-- 数据同步
-- 导出
mongodump -h 27.174.233.112:7017 -d vava_product -o d:\mongo_dump -u a -p a
mongodump -h 27.174.233.112:7017 -d vava_admin -o mongo_dump -u a -p a
mongodump -h 27.174.233.112:7017 -d vava_log -o mongo_dump -u a -p a
-- 数据恢复
-- 导入
mongorestore -h 147.9.186.133:27017 -d vava_product -u admin -p admin d:\mongo_dump\vava_product
mongorestore -h 147.9.186.133:27017 -d vava_admin -u admin -p admin d:\mongo_dump\vava_admin
mongorestore -h 147.9.186.133:27017 -d vava_log -u admin -p admin d:\mongo_dump\vava_log
-- elasticsearch 端口:9200 9300
-- 创建目录,从容器或其他es库copy一份elasticsearch.yml文件并修改参数
mkdir /opt/es/config/
cat /opt/es/config/elasticsearch.yml |grep -v "#"
cluster.name: "docker-cluster"
network.host: 0.0.0.0
network.publish_host: 147.9.186.133
discovery.zen.minimum_master_nodes: 1
-- 启动
docker run -d --name es -v /opt/es/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -p 9200:9200 -p 9300:9300 elasticsearch:6.4.2
-- redis 端口:6379
-- 创建目录
mkdir -p /opt/redis/redis.conf
mkdir -p /opt/redis/data
docker run -d -v /opt/redis/redis.conf:/usr/local/etc/redis/redis.conf -v /opt/redis/data:/data -p 6379:6379 --name redis redis:4.0 redis-server /usr/local/etc/redis/redis.conf
# cat redis.conf
port 6379
appendonly yes