Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to create an environment using Docker

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the knowledge of "how to use Docker to create an environment". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Environmental preparation

Hardware requirements: memory: > = 4G, hard disk: > = 20g, network unblocked

System requirements: Centos6.x, enable SSH, recommend using Docker, or use physical or virtual machine (Vmware, Virtualbox or Hyper-V)

Basic environment: complete installation of JDK8, Scala2.10.x,MySQL, Mongo

1. Create an environment using Docker (recommended / optional)

Ignore this action if you are using a physical or virtual machine.

Download Docker

Linux is installed directly using package management tools (installation of Centos6 and below is more troublesome), Windows or Mac is installed using Docker toolbox (already in the resource list)

Add Mirror

Install from the official warehouse:

# download scala basic image docker pull gudaoxuri/scala_2.10# download mysql image docker pull mysql# download Mongo image docker pull mongo

If the network is too slow, you can use the downloaded image in the resource list to install:

# add scala basic image docker load-I / images/scala_2.10_image.tar# locally add mysql image docker load-I / images/mysql_image.tar# add mongo image docker load-I / images/mongo_image.tar locally

Create a container

# create mysql container, open port 3306, user name root, password 123456docker run-- name mysql-e MYSQL_ROOT_PASSWORD=123456-p 3306 MYSQL_ROOT_PASSWORD=123456-p 3306-d mysql# create mongo container, open port 27017, no need to authenticate docker run-- name mongo-p 27017 123456docker run-d mongo# create scala basic container Several important ports docker run-- name bd-lab-h bd- d\-p 2181\-p 6066 bd-\-p 7077 bd- 7077\-p 8041 8041\-p 19888 888\-p 60010 60010\-p 60030\-p 4040 4040\-p 80808080\-that are needed to open up the service of big data -p 8081 8081\-p 9000UR 9000\-p 7203VR 7203\-p 9092RV 9092\-p 50010RV 50010\-p 50070RV 50070\-p 50075RV 50075\-p 10000Rd 10000\-p 28081Rose 28081\-p 222Rou 22\-v / c/Users/i/docker_data/bd-lab:/opt/res\ gudaoxuri/scala_2.10

Container description

Gudaoxuri/scala_2.10 image opens the SSH service, user name root, password 123456, port number 222,

-v means to add a data map, which is used to obtain the downloaded frame package of the host.

Docker containers are used in subsequent environments. Unless otherwise specified, containers are based on gudaoxuri/scala_2.10 images. two。 Create an environment using Virtual box (optional)

Download CentOS6.x

Http://mirrors.163.com/centos/6.7/isos/x86_64/CentOS-6.7-x86_64-minimal.iso

Install CentOS to Virtual box

Matters needing attention

The network uses bridge mode

Choose Chinese (avoid garbled code)

Hostname using bd

Configure IP and DNS after installation

Installation complete, configure the network

Vi / etc/sysconfig/network-scripts/ifcfg-eth0

ONBOOT=yesBOOTPROTO=staticIPADDR=NETMASK=GATEWAY=ifup eth0

Vi / etc/resolv.conf

Nameserver 180.76.76.76nameserver 8.8.8.8

test

Ifconfigping www.baidu.com

Install the necessary tools

# Test environment You can close the firewall chkconfig iptables offservice iptables stopyum install-y wget# and install javawget-P / opt/env/-- no-check-certificate-- no-cookies-- header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u60-b27/jdk-8u60-linux-x64.tar.gztar-xzf / opt/env/jdk-8u60-linux-x64.tar.gz-C / opt/env/rm-rf / opt/env/ Jdk-8u60-linux-x64.tar.gzmv / opt/env/jdk1.8.0_60 / opt/env/javaecho "export JAVA_HOME=/opt/env/java" > > / etc/profile# install Scalawget-P / opt/env/ http://downloads.typesafe.com/scala/2.10.6/scala-2.10.6.tgztar-xzf / opt/env/scala-2.10.6.tgz-C / opt/env/rm-rf / opt/env/scala-2. 10.6.tgzmv / opt/env/scala-2.10.6 / opt/env/scalaecho "export SCALA_HOME=/opt/env/scala" > > / etc/profileecho 'export PATH=$PATH:$JAVA_HOME/bin:$SCALA_HOME/bin' > > / etc/profilesource / etc/profile# install MySQLyum install-y mysql-server mysql mysql-develservice mysqld start# mysqladmin-u root password 123456mysql-u root-pgrant all on *. * to'root'@'%' identified by' 123456' Flush privileges;# installs Mongovi / etc/yum.repos.d/mongodb-org-3.2.repo [mongodb-org-3.2] name=MongoDB Repository baseurl= https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/ gpgcheck=1 enabled=1 gpgkey= https://www.mongodb.org/static/pgp/server-3.2.ascyum install-y mongodb-orgvi / etc/mongod.conf bind_ip = 0.0.0.0service mongod start

Folder sharing

Vi / etc/selinux/config SELLINUX=disabledyum install-y sambavi / etc/samba/smb.conf # enable anonymous access security = share # modify the access directory [public] comment = Public Stuff path = / share availabe = yes browseable = yes public = yes writable = yes printable = no write list = + staffmkdir / sharechmod 777 / share/etc/init.d/smb start3. Basic environment creation

SSH to the experimental environment

# create a user user Password 123456adduser userpasswd usermkdir-p / opt/workspaces/chown user: / opt/workspaces/# enter the user account su-user# to the workspace cd / opt/workspaces# create each framework lib directory mkdir frameworks# create each framework data directory mkdir data# create each framework log directory mkdir logs# create application package directory mkdir apps# create SSH key-free login ssh-keygen-t dsa-P'- f ~ /. Ssh/id_dsacat ~ / .ssh/id_dsa.pub > > ~ / .ssh/authorized_keyschmod 0600 ~ / .ssh/authorized_keys

If there are no special instructions, follow-up operations will use the user account "how to use Docker to create an environment". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report