一. 准备工作
yum update
yum -y install python-devel mysql-devel gcc wget bzip2 python-setuptools
二. 安装anaconda
-
下载
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2019.03-Linux-x86_64.sh
-
执行安装
bash Anaconda3-2019.03-Linux-x86_64.sh
安装过程中会出现的提示
# 1.协议要求 Do you accept the license terms? [yes|no] >>> yes # 2.安装位置(默认/root/anaconda3) [/root/anaconda3] >>> # 此处修改anaconda的安装绝对路径 # 3.自动添加环境变量(推荐no) >by running conda init? [yes|no] >no
-
手动修改环境变量
vim ~/.bashrc # 文件末尾添加如下内容 export PATH="/root/anaconda3/bin:$PATH" # 路径替换为安装路径 vim /etc/profile # 文件末尾添加如下内容 export PATH="/root/anaconda3/bin:$PATH" # 路径替换为安装路径 #保存退出,刷新系统 source /etc/profile
-
验证安装是否成功
source activate # 进入conda环境 出现(base)则说明安装成功 source deactivate # 退出conda环境
三. 安装MySQL
-
检查&删除 MariaDB
# 检查 shell> rpm -qa|grep mariadb mariadb-server-5.5.60-1.el7_5.x86_64 mariadb-5.5.60-1.el7_5.x86_64 mariadb-libs-5.5.60-1.el7_5.x86_64 # 删除 shell> rpm -e --nodeps mariadb-server shell> rpm -e --nodeps mariadb shell> rpm -e --nodeps mariadb-libs
-
检查&删除 MySQL
# 检查 shell> rpm -qa|grep mysql # 删除 shell> rpm -e --nodeps xxx
-
下载MySQL源
官网:https://dev.mysql.com/downloads/repo/yum/# 查看系统版本 shell> cat /etc/redhat-release CentOS Linux release 7.7.1908 (Core) # 选择对应的版本进行下载,例如CentOS 7当前在官网查看最新Yum源的下载地址为: # https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm shell> wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
-
安装MySQL源
shell> sudo rpm -Uvh platform-and-version-specific-package-name.rpm # 例如CentOS7当前最新MySQL源安装: shell> sudo rpm -Uvh mysql80-community-release-el7-3.noarch.rpm
通过
yum repolist enabled | grep "mysql.*-community.*"
可以看到mysql相关资源shell> yum repolist enabled | grep "mysql.*-community.*" !mysql-connectors-community/x86_64 MySQL Connectors Community 108 !mysql-tools-community/x86_64 MySQL Tools Community 90 !mysql80-community/x86_64 MySQL 8.0 Community Server 113
-
安装MySQL
shell> sudo yum install mysql-community-server
该命令会安装MySQL服务器 (mysql-community-server) 及其所需的依赖、相关组件,包括mysql-community-client、mysql-community-common、mysql-community-libs等
安装时间根据带宽决定 -
操作MySQL服务(启动/停止/重启/状态)
# 启动 shell> sudo systemctl start mysqld.service # 查看状态 shell> sudo systemctl status mysqld.service # 停止 shell> sudo systemctl stop mysqld.service # 重启 shell> sudo systemctl restart mysqld.service
-
修改密码
# 查看默认密码 shell> sudo grep 'temporary password' /var/log/mysqld.log # 修改密码 shell> mysql -uroot -p mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
出现这个错误提示是因为密码太简单了- 使用复杂密码,MySQL默认的密码策略是要包含数字、字母及特殊字符
- 如果只是测试用,不想用那么复杂的密码,可以修改默认策略,即
validate_password_policy
(以及validate_password_length
等相关参数),使其支持简单密码的设定,具体方法可以自行百度 - 修改配置文件
/etc/my.cnf
,添加validate_password=OFF
,保存并重启MySQL
-
允许root远程访问 && navicat连接MySQL8+时出现2059错误解决方法
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; # 'root'可以改为你自己定义的用户名, # 'localhost'指的是该用户开放的IP,可以是'localhost'(仅本机访问,相当于127.0.0.1),可以是具体的'*.*.*.*'(具体某一IP),也可以是'%'(所有IP均可访问)。 # 'password'是你想使用的验证密码
-
设置编码为utf8 & 设置开机启动
# 查看编码 mysql> SHOW VARIABLES LIKE 'character%'; # 编辑/etc/my.cnf,[mysqld]节点增加以下代码 [mysqld] character_set_server=utf8 init-connect='SET NAMES utf8' # 开机启动 shell> systemctl enable mysqld shell> systemctl daemon-reload
四. 安装redis
- 更新yum源
sudo yum install epel-release sudo yum update
- 安装
sudo yum -y install redis
- 启动
sudo systemctl start redis
- 常用操作
systemctl start redis.service #启动redis服务器 systemctl stop redis.service #停止redis服务器 systemctl restart redis.service #重新启动redis服务器 systemctl status redis.service #获取redis服务器的运行状态 systemctl enable redis.service #开机启动redis服务器 systemctl disable redis.service #开机禁用redis服务器
五. 安装supervisor
- 安装
easy_install supervisor
- 创建配置文件
echo_supervisord_conf > /etc/supervisord.conf
六. 安装Git
- 安装
yum install git
- 生成密钥
ssh-keygen -t rsa -C “your email address”
- GitHub添加公钥
公钥位置:/root/.ssh/id_rsa.pub
- 测试
shell > ssh git@github.com Are you sure you want to continue connecting (yes/no)? shell > yes Hi xxx! You’ve successfully authenticated, but GitHub does not provide shell accessConnection to github.com closed.
- init后使用
七. 安装MySQLdb
- 安装
yum -y install mysql-devel libffi-devel pip install mysqlclient
- 检查
(base)shell> python >>> import MySQLdb >>>
八. 安装各种Python包
-
celery
安装:install celery
-bash: celery: command not found 解决方法
export PATH=/anaconda3/bin:$PATH # 路径替换为python包所在目录 # 避免重启丢失 sudo echo 'export PATH=/ananaconda3/bin:$PATH' >> /etc/profile.d/python3.sh
-
uwsgi
安装pip install uwsgi
-
scrapy
安装pip install scrapy scrapyd scrapyd-client python-scrapyd-api
九. 配置迁移
- 获取文件
scp -P 22 user@ip:SourceFilePath ReceviePath
- 获取目录
scp -P 22 -r user@ip:SourceFilePath ReceviePath
- 将本地文件上传到服务器上
scp -P 2223 SourceFile user@ip:RecevieFile
- 将本地目录上传到服务器上
scp -P 2223 -r SourceDirPath user@ip:RecevieDirPath