熊立
|
1.系统环境 CentOS 7 安装过更新 # yum upgrade
2.安装docker见上一篇文章
# docker images
[root@CentOS ~]# docker ps -l
[root@CentOS ~]# docker run -i -t centos /bin/bash
# docker ps -l
装好软件之后 # docker commit 1b60a96a84e8 xiongli/mysql
3.mysql下载 最新版: mysql-5.6.20.tar.gz 网站:http://dev.mysql.com/downloads/mysql/ 下载命令: # wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.20.tar.gz cmake # wget http://www.cmake.org/files/v3.0/cmake-3.0.1.tar.gz
4.docker 安装 CentOS 镜像 # docker pull centos
安装 mysql [root@CentOS ~]# docker run -i -t centos /bin/bashbash-4.2# 因为只有一个窗口,运行起来输命令不方便,现在安装ssh,并且用其他主机通过ssh连接进来,安装,没有 docker commit 不可以关闭主docker 窗口,否则,安装全部要重新开始。 # yum install openssh 下面两个用不了,可以用命令启动 # systemctl start sshd.service # systemctl enable sshd.service
在这个命令下面安装,步骤如下: # cd /root/
# wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.20.tar.gz
# tar zxvf cmake-3.0.1.tar.gz
# cp support-files/mysqld_multi.server /etc/init.d/mysqld
环境变量 # vi /etc/profile
追加
# source /etc/profile
配置 my.cnf # vi /etc/my.cnf
[mysqld_multi]
初始化 # /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/mysql/3306 # /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/mysql/3307
启动 启动命令 # mysql start # /etc/init.d/mysqld start 1-2
查询状态 # /etc/init.d/mysqld report 1 # /etc/init.d/mysqld report 2
提交到 docker images # docker commit 1b60a96a84e8 xiongli/mysql 注意:要退出安装的 docker # docker run -i -t centos /bin/bash # exit 然后通过 这个命令可以查看 镜像的id
# docker ps -a
查看 commit 的镜像
# docker images
使用提交的镜像 # docker run -i -t xiongli/mysql /bin/bash
5.docker 安装 ubuntu # docker pull ubuntu 安装顺序和上面的过程一样,这里不再详细展开
6.docker pull安装mysql # docker search mysql 找到所需要的 mysql 版本和镜像名,执行下面命令进行安装 # docker pull sawarame/mysql5.6.19 安装完成之后,启动 sawarame/mysql5.6.19 # docker images
|
Tom
|
楼主啊,你那个sshd服务是拿什么命令启动的啊?????service 没有,安装也不行;systemctl也没有;/etc/rc.d/init.d/下面什么都没有
|
熊立
|
哦 是这样的 你做一个脚本 比如这个 当然 这个 xiongli/mysql 是可以下载的 # docker pull xiongli/mysql 这个机器 是 做监控的,好些cacti 是采集不到数据,所以没有传到docker上面
$ cat /opt/bootstrap.sh #!/bin/bash# author: xiongli # Email: xionglihdfs@163.com PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH echo "welcome to xiongli/cacti_nagios" echo "" echo "the system is Ubuntu 14.04.1 LTS" echo "ssh info: " echo "the ssh connect username is admin." echo "the password of admin is admin." echo "the admin has sudo su privileges, so it is super admin." echo "" echo "mysql info: " echo "the mysql user is 'root' and 'cacti'" echo "their password is 'xiongli', but user cacti has all privileges on cacti.* to cacti@'localhost' an cacti@'127.0.0.1'." echo "" echo "cacti web info: " echo "the username of cacti web is 'admin'." echo "the password of admin is 'xiongli'." echo "the host template of general linux is 'General Linux'." echo "" echo "nagios web info: " echo "the username of cacti web is 'admin'." echo "the password of admin is 'xiongli'." echo "" echo "the start ssh command is 'docker run -d -p 1022:22 --name cacti xiongli/cacti_nagios /opt/bootstrap.sh'." echo "the start ssh + apache + cacti + nagios command is 'docker run -d -p 1022:22 -p3306:3306 -p 80:80 --name cacti xiongli/cacti_nagios /opt/bootstrap.sh'." echo "and so on." echo "" # start ssh /etc/init.d/ssh start # lnmp start /etc/init.d/mysql start /etc/init.d/apache2 start # snmpd start /etc/init.d/snmpd start # nagios start /etc/init.d/nagios start sleep 99999999999999999999999999999999999999999999999999999 sleep 99999999999999999999999999999999999999999999999999999 sleep 99999999999999999999999999999999999999999999999999999 启动的话很简单啦 docker cacti + nagios start:# docker run -d -p 1025:22 -p 80:80 -p 3306:3306 --name cacti_nagios_1 xiongli/cacti_nagios /opt/bootstrap.sh |
熊立
|
对了 你如果是用的 Centos 7版本的话,安装软件会提示少个s y s t e mctl类似的软件,还有s y s t e md之类的,但是怎么也装不上去,所以玩centos7 的可要注意下,尽量用 Ubuntu 来入门,因为他还是选择 service 来管理服务项。要不就把centos7降级成centos6。 |