关于一些基本的环境构建

一.安装Docker
第一步:安装工具包

$ sudo yum install -y yum-utils         #安装工具包,缺少这些依赖将无法完成

1.1.1.2第二步:设置远程仓库

$sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

1.1.1.3第三步:安装

$ sudo yum install docker-ce

1.1.1.4第四步:启动

$ sudo systemctl start docker

第五步:查看版本

$ sudo docker version

二.安装mysql

下载mysql最新镜像:

     docker pull mysql

在/usr/local/mysql下创建挂载数据源及配置文件

mkdir /usr/local/mysql/data

touch /usr/local/mysql/my.cnf

----------------------------------------------一些写好的mysql配置-----------------------------------------------------

# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA

#
# The MySQL  Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

[mysqld]
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
datadir         = /var/lib/mysql
secure-file-priv= NULL
lower_case_table_names=1
default-time_zone='+8:00'
max_connections=10000
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
#binlog setting
log-bin=/var/lib/mysql/mysql-bin
server-id=17220137255
# Custom config should go here
!includedir /etc/mysql/conf.d/
 

启动

docker run -di --name=mysql \
-v /usr/local/mysql/data:/var/lib/mysql \
-v /usr/local/mysql/my.cnf:/etc/mysql/my.cnf \
--privileged=true \
-p 3306:3306 \
-e MYSQL_ROOT_PASSWORD=Root_123 mysql \
--lower_case_table_names=1

三.安装redis

下载redis最新镜像:

     docker pull redis

在/usr/local/redis下创建挂载数据源及配置文件

mkdir /usr/local/redis/data

touch /usr/local/redis/redis.conf

-------------------------------------------一些写好的redis配置-----------------------------------------------

protected-mode no
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize no
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile ""
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
rdb-del-sync-files no
dir ./
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-diskless-load disabled
repl-disable-tcp-nodelay no
replica-priority 100
acllog-max-len 128
requirepass Root_123
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
lazyfree-lazy-user-del no
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes
lua-time-limit 5000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
stream-node-max-bytes 4096
stream-node-max-entries 100
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes

启动

docker run -p 6379:6379 --name redis -it -m 50M --memory-swap=50M -v /usr/local/redis/redis.conf:/etc/redis/redis.conf -v /usr/local/redis/data:/data -d redis redis-server /etc/redis/redis.conf --appendonly yes

四.安装rabbitmq

下载rabbitmq最新镜像

docker pull rabbitmq

启动

docker run -d --hostname my-rabbit --name rabbit -p 15672:15672 -p 5672:5672 rabbitmq

安装可视化管理后台插件

docker ps -a  查看镜像id

docker exec -it 镜像id /bin/bash   进入镜像

rabbitmq-plugins enable rabbitmq_management   安装

ps:Stats in management UI are disabled on this node

在镜像中修改配置文件为false即可

vi /etc/rabbitmq/conf.d/management_agent.disable_metrics_collector.conf

四.安装mongodb

下载mongodb最新镜像

docker pull mongo

挂载数据源到磁盘

mkdir -p /usr/local/mongo/conf && mkdir -p /usr/local/mongo/data

启动

docker run --name mongo \

-it -m 400M --memory-swap=400M \

-p 27017:27017 \

--mount type=bind,src=/usr/local/mongo/conf,dst=/data/configdb \

--mount type=bind,src=/usr/local/mongo/data,dst=/data/db \

--restart=on-failure:3 \

-d mongo

授权

docker ps -a   查看镜像
docker exec -it mongo mongo admin
# 创建一个名为 root,密码为 Root_123的用户。
>  db.createUser({ user:'root',pwd:'Root_123',roles:[ { role:'userAdminAnyDatabase', db: 'admin'},"readWriteAnyDatabase"]});
# 尝试使用上面创建的用户信息进行连接。
> db.auth('root', 'Root_123')
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值