vitess基礎鏡像構建流程Centos

如下列出了構建vitess使用的Centos鏡像的簡單流程,因爲較早基礎版本是Centos7.2的,從新構建能夠基於最新的Centos版本構建python

1.基礎鏡像拉取mysql

#拉取官方版本
docker pull centos:7.2.1511
官方鏡像地址: https://hub.docker.com/_/centos/

2. 修改鏡像源,能夠選擇阿里雲的源地址或者內部源地址sql

CentOS-7.2-Base.repodocker

[CentOS]
name=CentOS-7.2 - Base

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

epel.repojson

[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
[epel-debuginfo]
name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch/debug
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1
[epel-source]
name=Extra Packages for Enterprise Linux 7 - $basearch - Source
#baseurl=http://download.fedoraproject.org/pub/epel/7/SRPMS
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=1

3. 依賴程序安裝vim

#安裝vim
yum install vim -y
  
#安裝wget
yum install wget -y
  
#安裝rzsz
yum install lrzsz -y
  
#安裝ssh
yum install openssh-server -y
  
#安裝net-tools(包含netstat)
yum install net-tools -y
  
#重置鏡像默認密碼
echo root:xxxxxxxxxxxxxxxx | chpasswd
  
#安裝sudu權限
yum install sudo -y
  
#添加操做用戶admin
useradd admin
  
#修改admin默認密碼
echo admin:xxxxxxxxxxxx | chpasswd
  
#添加jeduser用戶sudu權限
#在vim /etc/sudoers文件中root下面添加一行,增長admin的sudo權限
#root    ALL=(ALL)       ALL
admin ALL=(ALL)       ALL
  
#因爲ssh須要依賴於一些key,須要更新key不然ssh沒法啓動
#Could not load host key: /etc/ssh/ssh_host_rsa_key
#Could not load host key: /etc/ssh/ssh_host_ecdsa_key
#Could not load host key: /etc/ssh/ssh_host_ed25519_key
ssh-keygen -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key
ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ""
ssh-keygen -t dsa -f /etc/ssh/ssh_host_ed25519_key 
  
#安裝tcpdump
yum install tcpdump -y
 
#安裝lsof
yum install lsof -y
  
#安裝dstat
yum install dstat -y
  
#安裝scp
yum install openssh-clients
  
#安裝perf
yum install perf -y
  
#安裝sysstat
yum install sysstat -y
  
#安裝perl相關
yum install perl-DBI -y
yum install perl-DBD-MySQL -y
yum install perl-Time-HiRes -y
yum install perl-IO-Socket-SSL
  
#安裝percona-toolkit
yum install perl-TermReadKey -y
yum install perl-Digest-MD5 -y
#官網下載最新版本
#https://www.percona.com/downloads/percona-toolkit/LATEST/
wget https://www.percona.com/downloads/percona-toolkit/3.0.5/binary/redhat/7/x86_64/percona-toolkit-3.0.5-1.el7.x86_64.rpm
rpm -i percona-toolkit-3.0.5-1.el7.x86_64.rpm
  
#安裝percona-xtrabackup
yum install percona-xtrabackup -y
 
#安裝bzip2
yum install bzip2 -y
  
#安裝jq,解析json工具
yum install jq
 
#安裝mysql
wget https://repo.mysql.com/mysql57-community-release-el7-11.noarch.rpm
yum localinstall mysql57-community-release-el7-11.noarch.rpm
yum install mysql-community-server.x86_64 -y
 
  
#安裝python-setuptools
yum install python-setuptools -y
  
#安裝orzdba
  
#處理ssh啓動腳本
#因爲debian和centos文件位置不一致,因此這裏直接在centos中加入/etc/init.d/ssh腳本,經過腳本調用/usr/sbin/sshd,確保兩個系統調用一致;這樣調用模板就能夠統一
#如下內容根據須要選擇 #ssh腳本內容以下 /usr/sbin/sshd

4 添加證書centos

#根據須要添加須要的證書,若是不須要就忽略
#切換到admin
su admin
  
#添加信任證書
echo ssh-rsa xxxxxxxxxxxxxxxxxxxxxxxxxxxxx >> /home/admin/.ssh/authorized_keys
    
#修改證書受權文件權限
chmod 644 /home/admin/.ssh/authorized_keys

5. 提交鏡像bash

構建完鏡像以後直接獲取鏡像ID而後提交成基礎鏡像
提交後能夠壓縮鏡像大小
docker commit 7541391ae047 vitesss/centos:7.2.1511
相關文章
相關標籤/搜索