Oracle VM Virtual Box安装CentOS 7过程
启动网络服务
1 | ip addr |
关机/重启命令
- Linux centos重启命令:
- 1、reboot 普通重启
- 2、shutdown -r now 立刻重启(root用户使用)
- 3、shutdown -r 10 过10分钟自动重启(root用户使用)
- 4、shutdown -r 20:35 在时间为20:35时候重启(root用户使用)
- 如果是通过shutdown命令设置重启的话,可以用shutdown -c命令取消重启
- Linux centos关机命令:
- 1、halt 立刻关机
- 2、poweroff 立刻关机
- 3、shutdown -h now 立刻关机(root用户使用)
- 4、shutdown -h 10 10分钟后自动关机
Putty连接
安装Docker
1 | $ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo |
由于国内访问不到docker官方镜像,可以通过aliyun的源来完成。
1 | $ sudo systemctl start docker |
Docker镜像
Redis
https://hub.docker.com/_/redis/
1 | docker pull redis |
1 | $ docker pull registry.docker-cn.com/myname/myrepo:mytag |
例如:
1 | $ docker pull registry.docker-cn.com/library/ubuntu:16.04 |
1 | $ docker pull registry.docker-cn.com/library/redis:5.0-rc-alpine3.8 |
1 | [root@localhost /]# docker pull registry.docker-cn.com/library/redis |
1 | docker run -d -p 6379:6379 --name myredis registry.docker-cn.com/library/redis |
1 | docker run -d -p 192.168.1.105:6379:6379 --name myredis registry.docker-cn.com/library/redis /bin/bash |
1 | $ docker ps // 查看所有正在运行容器 |
1 | vi /etc/sysconfig/iptables |
启动一个服务:systemctl start firewalld.service
关闭一个服务:systemctl stop firewalld.service
重启一个服务:systemctl restart firewalld.service
显示一个服务的状态:systemctl status firewalld.service
在开机时启用一个服务:systemctl enable firewalld.service
在开机时禁用一个服务:systemctl disable firewalld.service
查看服务是否开机启动:systemctl is-enabled firewalld.service
查看已启动的服务列表:systemctl list-unit-files|grep enabled
查看启动失败的服务列表:systemctl –failed
1 | firewall-cmd --zone=public --add-port=80/tcp --permanent |
Windows 查看某个端口是否被占用:
1 | netstat -aon|findstr "8080" |
RabbitMQ
1 | docker pull registry.docker-cn.com/library/rabbitmq:3.6-management |
移除镜像:
1 | docker ps -a |
Elasticsearch
1 | docker search elasticsearch |
容器重命名
docker rename myelasticsearch1 myelasticsearch
spring-data-elasticsearch
spring data elasticsearch | elasticsearch |
---|---|
3.1.x | 6.2.2 |
3.0.x | 5.5.0 |
2.1.x | 2.4.0 |
2.0.x | 2.2.0 |
1.3.x | 1.5.2 |
1 | docker pull registry.docker-cn.com/library/elasticsearch:2.4 |
MySQL
1 | docker pull mysql |
error: database is uninitialized and password option is not specified
You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
进入MySQL终端
1 | docker exec -it 63ca57bd6dc5 /bin/bash |
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.12 MySQL Community Server - GPL
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
查看已经创建的容器1
docker ps -a
查看正在运行的容器1
docker ps -s
docker stop mymysql
docker rm mymysql
docker rmi 6a834f03bd02
防火墙开启3306端口
1 | firewall-cmd --query-port=3306/tcp |
1 | exit |
MySQL Workbench连接
Gogs
https://github.com/gogs/gogs/tree/master/docker
# Pull image from Docker Hub.
$ docker pull gogs/gogs:0.11.66
# Create local directory for volume.
$ mkdir -p /var/gogs
# Use `docker run` for the first time.
$ docker run --name=mygogs -p 10022:22 -p 10080:3000 -v /var/gogs:/data gogs/gogs:0.11.66
# Use `docker start` if you have stopped it.
$ docker start gogs
$ mysql -u root -p
mysql> # (输入密码)
mysql> create user 'gogs'@'localhost' identified by '密码';
mysql> grant all privileges on gogs.* to 'gogs'@'localhost';
mysql> flush privileges;
mysql> exit;
然后访问 http://192.168.1.105:10080/
Bingo: