Bo's Oracle Station

查看: 1382|回复: 0

课程第37/38次

[复制链接]

27

主题

27

帖子

183

积分

超级版主

Rank: 8Rank: 8

积分
183
发表于 2019-10-17 20:56:34 | 显示全部楼层 |阅读模式
本帖最后由 secoug 于 2019-10-20 09:12 编辑

创建用户:
  1. create user zhang3@'desktop3.example.com' identified by 'redhat';
复制代码

远程连接(在192.168.0.3做):
  1. mysql  -u zhang3 -h 192.168.0.103 -p
复制代码



查看权限表:
  1. use mysql;
  2. select user,host,password from user;
复制代码
  1. MariaDB [mysql]> create user li4 identified by  'redhat';
  2. Query OK, 0 rows affected (0.02 sec)

  3. MariaDB [mysql]> create user wang5@localhost identified by 'redhat';
  4. Query OK, 0 rows affected (0.03 sec)

  5. MariaDB [mysql]> select  user, host , password from user;
  6. +--------+----------------------+-------------------------------------------+
  7. | user   | host                 | password                                  |
  8. +--------+----------------------+-------------------------------------------+
  9. | root   | localhost            | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
  10. | zhang3 | desktop3.example.com | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
  11. | root   | 127.0.0.1            | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
  12. | root   | ::1                  | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
  13. | li4    | %                    | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
  14. | wang5  | localhost            | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
  15. +--------+----------------------+-------------------------------------------+
  16. 6 rows in set (0.01 sec)

  17. MariaDB [mysql]> create user ma6@'%' identified by 'redhat';
  18. Query OK, 0 rows affected (0.00 sec)

  19. MariaDB [mysql]> select  user, host , password from user;
  20. +--------+----------------------+-------------------------------------------+
  21. | user   | host                 | password                                  |
  22. +--------+----------------------+-------------------------------------------+
  23. | root   | localhost            | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
  24. | zhang3 | desktop3.example.com | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
  25. | root   | 127.0.0.1            | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
  26. | root   | ::1                  | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
  27. | li4    | %                    | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
  28. | wang5  | localhost            | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
  29. | ma6    | %                    | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 |
  30. +--------+----------------------+-------------------------------------------+
  31. 7 rows in set (0.00 sec)

  32. MariaDB [mysql]>
复制代码
RH124: 上完
1 2 3 4 5 6 7 8 9 10  11  12 13  14  15 16

RH134: 上完 1 2 3 4 5 6 7  8 9 10 11 12 13 14 15

RH254:
上完
1 2 3 4 5 6 7 8  9  10  11 12 13 14  15

docker的配置:
  1. yum-config-manager   --add-repo https://download.docker.com/linux/centos/docker-ce.repo
复制代码
1.png


2.png


下载images用的Dockerfile:
  1. FROM php:7.3.10-apache
  2. COPY src/ /var/www/html
  3. EXPOSE 80
复制代码
  1. docker build -t php1  ./
复制代码
  1. docker run -p 80:80 php1
复制代码
  1. [root@desktop3 ~]# docker ps -a
  2. CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                NAMES
  3. f476803934f0        php1                "docker-php-entryp..."   48 seconds ago      Up 45 seconds       0.0.0.0:80->80/tcp   flamboyant_hawking
  4. [root@desktop3 ~]# cd /var/lib/docker/
  5. [root@desktop3 docker]# ls
  6. containers  image  network  overlay2  plugins  swarm  tmp  trust  volumes
  7. [root@desktop3 docker]# cd image/
  8. [root@desktop3 image]# ls
  9. overlay2
  10. [root@desktop3 image]# cd overlay2/
  11. [root@desktop3 overlay2]# ls
  12. distribution  imagedb  layerdb  repositories.json
  13. [root@desktop3 overlay2]# cd ..
  14. [root@desktop3 image]# ls
复制代码

新的运行docker的方式(挂接目录):
  1. docker run -p 80:80  -v /root/docker/php/src/:/var/www/html/   php1
  2. AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
  3. AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
  4. [Sun Oct 20 00:46:49.665122 2019] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.3.10 configured -- resuming normal operations
  5. [Sun Oct 20 00:46:49.665320 2019] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
复制代码
docker run 就是把image变成container的过程,所有选项:
  1. [root@server3 src]# docker run --help

  2. Usage:  docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

  3. Run a command in a new container

  4. Options:
  5.       --add-host list                  Add a custom host-to-IP mapping (host:ip)
  6.   -a, --attach list                    Attach to STDIN, STDOUT or STDERR
  7.       --blkio-weight uint16            Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)
  8.       --blkio-weight-device list       Block IO weight (relative device weight) (default [])
  9.       --cap-add list                   Add Linux capabilities
  10.       --cap-drop list                  Drop Linux capabilities
  11.       --cgroup-parent string           Optional parent cgroup for the container
  12.       --cidfile string                 Write the container ID to the file
  13.       --cpu-period int                 Limit CPU CFS (Completely Fair Scheduler) period
  14.       --cpu-quota int                  Limit CPU CFS (Completely Fair Scheduler) quota
  15.       --cpu-rt-period int              Limit CPU real-time period in microseconds
  16.       --cpu-rt-runtime int             Limit CPU real-time runtime in microseconds
  17.   -c, --cpu-shares int                 CPU shares (relative weight)
  18.       --cpus decimal                   Number of CPUs
  19.       --cpuset-cpus string             CPUs in which to allow execution (0-3, 0,1)
  20.       --cpuset-mems string             MEMs in which to allow execution (0-3, 0,1)
  21.   -d, --detach                         Run container in background and print container ID
  22.       --detach-keys string             Override the key sequence for detaching a container
  23.       --device list                    Add a host device to the container
  24.       --device-cgroup-rule list        Add a rule to the cgroup allowed devices list
  25.       --device-read-bps list           Limit read rate (bytes per second) from a device (default [])
  26.       --device-read-iops list          Limit read rate (IO per second) from a device (default [])
  27.       --device-write-bps list          Limit write rate (bytes per second) to a device (default [])
  28.       --device-write-iops list         Limit write rate (IO per second) to a device (default [])
  29.       --disable-content-trust          Skip image verification (default true)
  30.       --dns list                       Set custom DNS servers
  31.       --dns-option list                Set DNS options
  32.       --dns-search list                Set custom DNS search domains
  33.       --domainname string              Container NIS domain name
  34.       --entrypoint string              Overwrite the default ENTRYPOINT of the image
  35.   -e, --env list                       Set environment variables
  36.       --env-file list                  Read in a file of environment variables
  37.       --expose list                    Expose a port or a range of ports
  38.       --gpus gpu-request               GPU devices to add to the container ('all' to pass all GPUs)
  39.       --group-add list                 Add additional groups to join
  40.       --health-cmd string              Command to run to check health
  41.       --health-interval duration       Time between running the check (ms|s|m|h) (default 0s)
  42.       --health-retries int             Consecutive failures needed to report unhealthy
  43.       --health-start-period duration   Start period for the container to initialize before starting health-retries countdown
  44.                                        (ms|s|m|h) (default 0s)
  45.       --health-timeout duration        Maximum time to allow one check to run (ms|s|m|h) (default 0s)
  46.       --help                           Print usage
  47.   -h, --hostname string                Container host name
  48.       --init                           Run an init inside the container that forwards signals and reaps processes
  49.   -i, --interactive                    Keep STDIN open even if not attached
  50.       --ip string                      IPv4 address (e.g., 172.30.100.104)
  51.       --ip6 string                     IPv6 address (e.g., 2001:db8::33)
  52.       --ipc string                     IPC mode to use
  53.       --isolation string               Container isolation technology
  54.       --kernel-memory bytes            Kernel memory limit
  55.   -l, --label list                     Set meta data on a container
  56.       --label-file list                Read in a line delimited file of labels
  57.       --link list                      Add link to another container
  58.       --link-local-ip list             Container IPv4/IPv6 link-local addresses
  59.       --log-driver string              Logging driver for the container
  60.       --log-opt list                   Log driver options
  61.       --mac-address string             Container MAC address (e.g., 92:d0:c6:0a:29:33)
  62.   -m, --memory bytes                   Memory limit
  63.       --memory-reservation bytes       Memory soft limit
  64.       --memory-swap bytes              Swap limit equal to memory plus swap: '-1' to enable unlimited swap
  65.       --memory-swappiness int          Tune container memory swappiness (0 to 100) (default -1)
  66.       --mount mount                    Attach a filesystem mount to the container
  67.       --name string                    Assign a name to the container
  68.       --network network                Connect a container to a network
  69.       --network-alias list             Add network-scoped alias for the container
  70.       --no-healthcheck                 Disable any container-specified HEALTHCHECK
  71.       --oom-kill-disable               Disable OOM Killer
  72.       --oom-score-adj int              Tune host's OOM preferences (-1000 to 1000)
  73.       --pid string                     PID namespace to use
  74.       --pids-limit int                 Tune container pids limit (set -1 for unlimited)
  75.       --privileged                     Give extended privileges to this container
  76.   -p, --publish list                   Publish a container's port(s) to the host
  77.   -P, --publish-all                    Publish all exposed ports to random ports
  78.       --read-only                      Mount the container's root filesystem as read only
  79.       --restart string                 Restart policy to apply when a container exits (default "no")
  80.       --rm                             Automatically remove the container when it exits
  81.       --runtime string                 Runtime to use for this container
  82.       --security-opt list              Security Options
  83.       --shm-size bytes                 Size of /dev/shm
  84.       --sig-proxy                      Proxy received signals to the process (default true)
  85.       --stop-signal string             Signal to stop a container (default "SIGTERM")
  86.       --stop-timeout int               Timeout (in seconds) to stop a container
  87.       --storage-opt list               Storage driver options for the container
  88.       --sysctl map                     Sysctl options (default map[])
  89.       --tmpfs list                     Mount a tmpfs directory
  90.   -t, --tty                            Allocate a pseudo-TTY
  91.       --ulimit ulimit                  Ulimit options (default [])
  92.   -u, --user string                    Username or UID (format: <name|uid>[:<group|gid>])
  93.       --userns string                  User namespace to use
  94.       --uts string                     UTS namespace to use
  95.   -v, --volume list                    Bind mount a volume
  96.       --volume-driver string           Optional volume driver for the container
  97.       --volumes-from list              Mount volumes from the specified container(s)
  98.   -w, --workdir string                 Working directory inside the container
复制代码

把运行过的容器保存成镜像:
  1. [root@server3 src]# docker commit -m "test"  dazzling_sinoussi  php3
  2. sha256:5b696601db416e96e12d84c8bb15084d8904f440a991f809531cf901ca3bc6eb
  3. [root@server3 src]# docker images
  4. REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
  5. php3                latest              5b696601db41        6 seconds ago       415MB
  6. php2                latest              f01313fcc2d6        12 minutes ago      415MB
  7. php1                latest              6e5bea28e640        2 days ago          415MB
  8. php                 7.3.10-apache       8648812a79f5        2 weeks ago         415MB
复制代码
后台运行:
  1. [root@server3 src]# docker run -d -p 80:80 -v /root/docker/php//src/:/var/www/html/  php3
  2. bd5be870982c80a9a7b60d49b5082f62686f2caa466b0f3450d0b7d70baee0f8






  3. [root@server3 src]#
  4. [root@server3 src]#
  5. [root@server3 src]#
  6. [root@server3 src]#
复制代码

备份和恢复docker的镜像:
  1. [root@server3 src]# docker ps
  2. CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS                NAMES
  3. bd5be870982c        php3                "docker-php-entrypoi…"   About a minute ago   Up About a minute   0.0.0.0:80->80/tcp   vibrant_cannon
  4. [root@server3 src]# docker stop bd5be870982c
  5. bd5be870982c
  6. [root@server3 src]# docker save --output php3.tar php3
复制代码
  1. [root@server3 src]# docker load --help

  2. Usage:  docker load [OPTIONS]

  3. Load an image from a tar archive or STDIN

  4. Options:
  5.   -i, --input string   Read from tar archive file, instead of STDIN
  6.   -q, --quiet          Suppress the load output
复制代码


















回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-5-9 22:40 , Processed in 0.049185 second(s), 27 queries .

快速回复 返回顶部 返回列表