centos7下安装 python3&pip3&mysql&salt-ssh

这是一篇安装记录的博客。

是在centos7的环境下安装python3,pip3,mysql,salt-ssh 的步骤。

1 安装mysql

在CentOS中默认安装有MariaDB,这个是MySQL的分支,但为了需要,还是要在系统中安装MySQL,而且安装完成之后可以直接覆盖掉MariaDB。

a 下载安装mysql 官方的  yum repository

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server
systemctl start  mysqld.service

systemctl status mysqld.service
grep "password" /var/log/mysqld.log
mysql -uroot -p

首次登陆后需要修改mysql root用户的密码,再重新登陆后才能操作。
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';

MySQL5.7.12新密码登录方式及密码策略,没有的了password字段,改为了authentication_string这个字段
mysql> select user,host,authentication_string,password_expired from user;
想要远程登陆的话需要修改host字段,并且防火墙放通3306端口。

但此时还有一个问题,就是因为安装了Yum Repository,以后每次yum操作都会自动更新,需要把这个卸载掉
yum -y remove mysql57-community-release-el7-10.noarch

2 安装salt-ssh

  a.安装epel源、salt-ssh

   yum -y install epel-release

 yum -y install salt-ssh
 

3 安装python3 

  a  从python.org 的官网下载python3.6.5的源码包

  b  yum install gcc  下载编译工具

  c  yum install  zlib*  所以对于错误:zipimport.ZipImportError: can’t decompress data,是因为缺少zlib 的相关工具包导致的

  d  yum install openssl -y                  ImportError: cannot import name HTTPSHandler   解决pip的这个报错问题.

      yum install openssl-devel -y

  e    进入python3 的下载的源码目录

  ./configure --prefix=/opt/Python #安装目录可以自己定义无所谓。
  make && make install

  f   ln -s /opt/Python/bin/python3 /usr/bin/python3

4 安装 pip for python3

 1.首先安装setuptools 通过官方模块库来下载:https://pypi.python.org/pypi
    wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26
    进入解压后的源码目录中
    python3 setup.py install
 2 直接下载安装 pip
    wget --no-check-certificate https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb
    进入解压后的源码目录中
    python3 setup.py install

5 pip3 install salt-ssh

  升级pip到pip-9.0.3 

  pip install --upgrade pip  

  pip3 install salt-ssh

  补充: 实际上并不需要 pip3 install salt-ssh,因为在    yum install  salt-ssh 中会安装   python3 对应的salt-ssh的版本  ,并会安装 python3 中调用 salt-ssh的组件,详情看 步骤6 中的测试

 1 [root@localhost ~]# pip3 install salt-ssh
 2 Collecting salt-ssh
 3   Using cached https://files.pythonhosted.org/packages/c5/35/a13f80a0e45df4193776a5b45c807f449e73fad41fed6dc25690d8c46da7/salt-ssh-2018.3.1.tar.gz
 4   Ignoring tornado: markers 'python_version < "3"' don't match your environment
 5 Collecting Jinja2 (from salt-ssh)
 6   Downloading https://files.pythonhosted.org/packages/7f/ff/ae64bacdfc95f27a016a7bed8e8686763ba4d277a78ca76f32659220a731/Jinja2-2.10-py2.py3-none-any.whl (126kB)
 7     100% |████████████████████████████████| 133kB 345kB/s
 8 Collecting msgpack!=0.5.5,>=0.5 (from salt-ssh)
 9   Downloading https://files.pythonhosted.org/packages/22/4e/dcf124fd97e5f5611123d6ad9f40ffd6eb979d1efdc1049e28a795672fcd/msgpack-0.5.6-cp36-cp36m-manylinux1_x86_64.whl (315kB)
10     100% |████████████████████████████████| 317kB 548kB/s
11 Collecting PyYAML (from salt-ssh)
12   Downloading https://files.pythonhosted.org/packages/4a/85/db5a2df477072b2902b0eb892feb37d88ac635d36245a72a6a69b23b383a/PyYAML-3.12.tar.gz (253kB)
13     100% |████████████████████████████████| 256kB 78kB/s
14 Collecting MarkupSafe (from salt-ssh)
15   Downloading https://files.pythonhosted.org/packages/4d/de/32d741db316d8fdb7680822dd37001ef7a448255de9699ab4bfcbdf4172b/MarkupSafe-1.0.tar.gz
16 Collecting requests>=1.0.0 (from salt-ssh)
17   Downloading https://files.pythonhosted.org/packages/65/47/7e02164a2a3db50ed6d8a6ab1d6d60b69c4c3fdf57a284257925dfc12bda/requests-2.19.1-py2.py3-none-any.whl (91kB)
18     100% |████████████████████████████████| 92kB 174kB/s
19 Collecting tornado<5.0,>=4.2.1; python_version >= "3.4" (from salt-ssh)
20   Downloading https://files.pythonhosted.org/packages/e3/7b/e29ab3d51c8df66922fea216e2bddfcb6430fb29620e5165b16a216e0d3c/tornado-4.5.3.tar.gz (484kB)
21     100% |████████████████████████████████| 491kB 116kB/s
22 Collecting certifi>=2017.4.17 (from requests>=1.0.0->salt-ssh)
23   Downloading https://files.pythonhosted.org/packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl (150kB)
24     100% |████████████████████████████████| 153kB 174kB/s
25 Collecting chardet<3.1.0,>=3.0.2 (from requests>=1.0.0->salt-ssh)
26   Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
27     100% |████████████████████████████████| 143kB 144kB/s
28 Collecting idna<2.8,>=2.5 (from requests>=1.0.0->salt-ssh)
29   Downloading https://files.pythonhosted.org/packages/4b/2a/0276479a4b3caeb8a8c1af2f8e4355746a97fab05a372e4a2c6a6b876165/idna-2.7-py2.py3-none-any.whl (58kB)
30     100% |████████████████████████████████| 61kB 162kB/s
31 Collecting urllib3<1.24,>=1.21.1 (from requests>=1.0.0->salt-ssh)
32   Downloading https://files.pythonhosted.org/packages/bd/c9/6fdd990019071a4a32a5e7cb78a1d92c53851ef4f56f62a3486e6a7d8ffb/urllib3-1.23-py2.py3-none-any.whl (133kB)
33     100% |████████████████████████████████| 143kB 205kB/s
34 Installing collected packages: MarkupSafe, Jinja2, msgpack, PyYAML, certifi, chardet, idna, urllib3, requests, tornado, salt-ssh
35   Running setup.py install for MarkupSafe ... done
36   Running setup.py install for PyYAML ... done
37   The script chardetect is installed in '/usr/Python3/bin' which is not on PATH.
38   Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
39   Found existing installation: tornado 5.0.2
40     Uninstalling tornado-5.0.2:
41       Successfully uninstalled tornado-5.0.2
42   Running setup.py install for tornado ... done
43   Running setup.py install for salt-ssh ... done
44 Successfully installed Jinja2-2.10 MarkupSafe-1.0 PyYAML-3.12 certifi-2018.4.16 chardet-3.0.4 idna-2.7 msgpack-0.5.6 requests-2.19.1 salt-ssh-2018.3.1 tornado-4.5.3 urllib3-1.23
pip3 install salt-ssh输出内容

6 安装salt-ssh

   安装epel源、salt-ssh

   yum -y install epel-release

   wget -i -c https://repo.saltstack.com/py3/redhat/salt-py3-repo-latest-2.el7.noarch.rpm

   yum install -y salt-py3-repo-latest-2.el7.noarch.rpm

   yum -y install salt-ssh

   防止检查更新

   yum remove -y salt-py3-repo-latest-2.el7.noarch.rpm

   安装过程 会装 python3.4 salt-ssh 的python3 版本,tonado,salt python-six  等等组件。

   

1 1 vi /etc/salt/roster
2      配置要管通过salt-ssh理的服务器
3 2 配置完成后  
4   salt://   等价于   /srv/salt
5  python3.4
6     
7     from salt.client.ssh.client import SSHClient
8     client = SSHClient()
9     client.cmd('*', 'cp.get_file', ('salt://123.text', '/data/s1111111.conf'))

 


posted @ 2018-06-25 11:28  hexintong  阅读(355)  评论(0编辑  收藏  举报