运维工具
系统备份和恢复
Clonezilla
install clonezilla network boot system
clonezilla push setting
clonezilla pxelinux.cfg default config
clonezilla pxe boot password
kickstart
kickstart centos5.6-i386 config
kickstart auto install
kickstart example
Cobbler
cobbler backups-restore
aomei 傲梅
傲梅集中备份
傲梅备份 分类
系统监控工具
collectd
collectd 收集系统性能
NMON monitor
Nmon monitor system
njmon script initd code
nmon 2 data to influx db
Zabbix
zabbix 3.2 install on centos 6
zabbix firewall
zabbix support windows
Supervisor
supervisor shell script
supervisor config example
boot supervisrd with systemd on centos7
webhook and github to do file sync with supervisor
日志管理系统
Grafana
grafana install on centos 6
grafana install plugin
grafana influx version
Filebeat
filebeat yum install
Kibana
kibana yum install
Logstash
logstash install on centos
Elasticsearch
yum install elasticsearch 6.8
elasticsearch install on Centos 6.7
ELK init env config
Elasticsearch 错误集锦
Rsyslog
centos 6 rsyslog 日志实时同步
Rsyslog mysql log to master analyzer
Deploy
Jumpserver
jumpserver 0.3.2 install on centos 6
jumpserver 0.3.2 docker install on centos 7
jumpserver 0.5 install on centos 7
Opsmanage
opsmanage install centos7
Jenkins
jenkins install on centos 6
install plugin in jenkins…
jenkins set time execution
tomcat jenkins ansible
jenkins ansible ad-hoc command
jenkins ansible playbook project
jenkins publish over_ssh
Paramike
PSSH
Centos7部署工具pssh
Ansible
how to install ansible with yum
bit rpm install ansible
source to install ansible
ansible init system centos 6
ansible using method
ansible install httpd servers
copy code with ansible-playbook
ansible ping host actived
ansible add username
ansible config parameter
ansible config write format
ansible api study
ansible hosts config ssh
ansible get nmon data
ansible setup filter information
yum repo with ansible-playbook
ansible gitlab ci runner
ansible get data list
ansible get text content
ansible get linux release debug infor
ansible support windows pywinrm
Saltshaker
saltshaker use docker
how to install saltstack
saltshaker manual install
salt install and config
salt init system
deploy saltshaker on centos7
salt file config desc
salt cmdb
saltshaker dj mq mysql build
salt data to mysql
Rsync
rsync + inotify 数据实时同步
代码仓库
Gitlab
yum install gitlab
gitlab-ce and runner
gitlib api example
gitlab config
gitlab ce and ee
Gogs
Gitea
虚拟化系统
Vmware
centos 6 install vmware 14
Vagrant
从零开始创建基础 Box
打包我的 BOX
Vagrantfile Config
Vagrant简易教程
给 Vagrant 从 VirtualBox换用 VMware 或 虚拟机
优化 vagrantFile config
Vagrant 主机定义
vagrant SSH
Vagrant 搭建 说明
WSL
pycharm 安装支持 WSL
windows-WSL 安装
Docker
how to install docker on centos 6
docker config source daoclound
how to use docker by step
how to creat docker subnet
gogs deploy on docker
jenkins use docker to deploy
mysql use docker to deploy
docker-example-1
docker-example-2
mac-osx-toolbox-install-docker
Data DB
Influx DB
InfluxDB install on centos
Mysql DB
centos 6 install mysql 5.5
mysql 5.7 install centos 6
install percona mysql 5.6 with yum
centos 7 install mysql config
mysql data rsync from master/slave
About me
本文档使用 MrDoc 发布
-
+
首页
从零开始创建基础 Box
# create base box - 新建系统 - 优化系统 - 打包 - 测试 --- 除此之外,每个提供商可能需要额外的软件。例如,如果您正在为VirtualBox创建一个box,那么您将希望包含VirtualBox来添加,以便共享文件夹能够正常工作。但是如果您正在制作AWS基础盒,则不需要这样做。 创建一个box > 创建box实际上是特定于提供程序的。这意味着,根据您是否使用VirtualBox、VMware、AWS等,创建box的过程是不同的。因此,本文档创建box是不完整的指南,主机为 virtualbox --- > Vagrant 的目标是简化在本地创建开发环境,只用两个简单的命令,你就可以安装你的第一个 vagrant 环境 ## Easy start # vagrant init cenos6-x64 https://cloud.centos.org/centos/6/vagrant/x86_64/images/CentOS-6-x86_64-Vagrant-2001_01.VirtualBox.box  # vagrant up  # vagrant ssh  --- ## Provider-specific - VMware Base Boxes - VirtualBox Base Boxes - Packer and Vagrant Cloud --- ## 安装操作系统 安装 centos6 很简单。跟着屏幕上的提示走即可。当提示设置的时候默认即可。 以下面的设置新建虚拟机: 1. 名字:centos-6-mini 2. 类型:Linux 3. 版本:Centos-610-x64 4. 内存:1024MB (to taste) 5. 新建虚拟硬盘:[Type: VMDK, Size: 60 GB] --- ### 硬盘空间设置 > When creating a base box, make sure the user will have enough disk space to do interesting things, without being annoying. 例如,在VirtualBox中,您应该创建一个具有较大最大大小的动态调整大小的驱动器。 --- ### 内存使用 > 与磁盘空间一样,找到默认内存量的正确平衡也很重要。 对于大多数提供程序,用户可以使用Vagrantfile修改内存,因此默认情况下不要使用太多。如果一个用户从一个基本的box里出来,立即需要许多GB的内存,那么这将是一个糟糕的用户体验(并且有点令人震惊)。相反,选择一个值,如512MB,这通常足以在漫游机器上玩耍和做有趣的事情,但在需要时很容易增加。 --- ### VM电脑外设优化 (Audio, USB...) > Disable any non-necessary hardware in a base box . 如音频和USB控制器。这些通常对于使用vagrantfile是不必要的,同样,在大多数情况下可以通过vagrantfile文件轻松添加。 - 禁用音频 - 禁用 USB - 确保网络适配器 1 设置为 NAT - 增加端口转发规则:【名字:SSH,协议:TCP,主机地址:空白,主机端口:2222,客户机地址:空白,客户机端口:22】 ### 系统初始化 ```bash /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/selinux/config chkconfig iptalbes off chkconfig iptables off chkconfig ip6tables off chkconfig postfix off > SELINUX=disabled # disabled > ONBOOT=yes # yes > #HWADDR=**** # 删除 > #UUID=***** # 删除 ``` # yum install epel-release -y # yum install -y screen vim wget curl htop lrzsz tree gcc kernel kernel-devel --- ### Default User Settings > Just about every aspect of Vagrant can be modified. However。 - Vagrant确实期望一些默认设置,这些默认设置将导致您的基本框“只是工作”。如果您打算公开分发您的盒子,您应该将这些设置为默认设置。 - 如果您正在创建一个供私人使用的box,那么您应该尽量不要遵循这些规则,因为它们会打开您的box,带来安全风险(已知的用户、密码、专用密钥等)。 --- ### "vagrant" User > By default, Vagrant expects a "vagrant" user to SSH into the machine as. 应该使用Vagrant默认使用的不安全密钥对设置此用户,以便尝试SSH。另外,尽管缺省情况下Vagrant使用基于密钥的身份验证,但通常将“Vagrant”用户的密码设置为“Vagrant”。这让人们可以在需要时以该用户的身份手动登录 ```bash [root@centos-6-mini ~]# useradd vagrant [root@centos-6-mini ~]# passwd vagrant Changing password for user vagrant. New password: vagrant BAD PASSWORD: it is based on a dictionary word BAD PASSWORD: is too simple Retype new password: vagrant passwd: all authentication tokens updated successfully. ``` --- ### To configure SSH > 使用不安全的密钥对进行访问. place the public key into the ~/.ssh/authorized_keys file for the "vagrant" user. Note that OpenSSH is very picky about file permissions. Therefore, make sure that ~/.ssh has 0700 permissions and the authorized keys file has 0600 permissions. #### vagarnt key ```bash ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key ``` #### auto deploy key ```bash mkdir -p /home/vagrant/.ssh chmod 0700 /home/vagrant/.ssh wget --no-check-certificate \ https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub \ -O /home/vagrant/.ssh/authorized_keys chmod 0600 /home/vagrant/.ssh/authorized_keys chown -R vagrant /home/vagrant/.ssh ``` #### sshd config # vim /etc/ssh/sshd_config ```bash AuthorizedKeysFile .ssh/authorized_keys ``` # service sshd restart --- ### Root Password: "vagrant" > Vagrant does not actually use or expect any root password. However, having a generally well known root password makes it easier for the general public to modify the machine if needed. Publicly available base boxes usually use a root password of "vagrant" to keep things easy. ```bash [root@centos-6-mini ~]# passwd Changing password for user root. New password: vagrant BAD PASSWORD: it is based on a dictionary word BAD PASSWORD: is too simple Retype new password: vagrant passwd: all authentication tokens updated successfully. ``` --- ### Password-less Sudo > This is important!. Many aspects of Vagrant expect the default SSH user to have passwordless sudo configured. This lets Vagrant configure networks, mount synced folders, install software, and more. 安装sudo之后,对其进行配置(通常使用visudo),以允许“vagantfile”用户使用无密码的sudo。这可以通过以下行在配置文件的结尾: # vagrant ALL=(ALL) NOPASSWD: ALL 设置 vagrant 用户运行 sudo 时无提示密码,我发现的最有效率的方法是这样把它加入 sudoers --- ### SSH Tweaks > In order to keep SSH speedy even when your machine or the Vagrant machine is not connected to the internet. 在SSH服务器配置中将UseDNS配置设置为no。 # vim /etc/ssh/sshd_config # UseDNS no > This avoids a reverse DNS lookup on the connecting SSH client which can take many seconds. --- ### 安装 Guest Tools Guest Tools 帮助操作系统处理共享文件夹并“优化客户系统以获得更好的性能与可用性”。2 再次确认安装 Guest Tools 需要的内核,输入命令: # yum install -y kernel kernel-devel > 在 VirtualBox 中,浏览在顶部的“设备”菜单,在下拉列表中,点击“插入 Guest Addition CD 镜像”。 这会把一个 ISO 镜像插入客户服务器的虚拟 CDROM 中。运行这些命令,挂载你的 cdrom 然后运行脚本。注意:那些关于 cdrom 只读的消息没关系。 # mount /dev/cdrom /mnt # cd /mnt # ./VBoxLinuxAdditions.run --- ### 更新操作系统 们制作 box 的一个原因就是为了节省时间,更新时间当然是其中一部分。所以先来更新吧 # yum update -y # yum clean all ### 优化权限以及网卡 # chmod -R 777 /mnt # udev 删除 # rm -f /etc/udev/rules.d/70-persistent-net.rules ### 确认 NFS 安装 # yum install nfs-utils -y --- ## Packaging the Box ### 将磁盘“零化”。“这会修复下属磁盘的碎片化问题 # dd if=/dev/zero of=/EMPTY bs=1M # rm -f /EMPTY ### 打包系统为 box # cd vagrant-box # vagrant package --base centos-6-mini --output "centos-6-mini.box" ```ruby vagrant package --base "centos-6-mini" --output "centos-6-mini.box" ==> centos-6-mini: Exporting VM... ==> centos-6-mini: Compressing package to: D:/VirtualBox/cmdb/box/centos-6-mini.box ``` ### Packaging the box into a box file is provider-specific. # vagrant box add --name "centos-6-mini" /path/to/the/centos-6-mini.box ```ruby ==> box: Box file was not detected as metadata. Adding it directly... ==> box: Adding box 'centos-6-mini' (v0) for provider: box: Unpacking necessary files from: file://D:/VirtualBox/cmdb/box/centos-6-mini.box box: ==> box: Successfully added box 'centos-6-mini' (v0) for 'virtualbox'! ``` ### 验证 # vagrant box list ```ruby cenos6-x64 (virtualbox, 0) centos-6-mini (virtualbox, 0) ``` ### init system # vagrant init centos-6-mini ```ruby A `Vagrantfile` has been placed in this directory. You are now ready to `vagrant up` your first virtual environment! Please read the comments in the Vagrantfile as well as documentation on `vagrantup.com` for more information on using Vagrant. ``` ### 开机 # vagrant up ### SSH # vagrant ssh --- If you made a box for some other provider, be sure to specify the --provider option to vagrant up. If the up succeeded, then your box worked! --- done
Bobby
2021年12月20日 07:54
分享文档
收藏文档
阅读
124
上一篇
下一篇
微信扫一扫
复制链接
手机扫一扫进行分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码