各种源的配置总结

各种源的配置总结

由于各种原因,访问国外服务器站点总是很慢,这时候我们就需要配置一个国内的镜像。

pip源

对于Mac和Linux系统,pip的配置文件为 ~/.pip/pip.conf,对于Windows用户,配置文件为C:\Users\xxx\pip\pip.ini。如果你还没有看到相应的目录的话,需要手动创建一个。

添加如下内容到配置文件:

[global]	
index-url=http://mirrors.aliyun.com/pypi/simple/

国内可用的pip源有:

  • http://mirrors.aliyun.com/pypi/simple/

  • http://pypi.douban.com/simple/

  • https://pypi.tuna.tsinghua.edu.cn/simple

选其中一个替换index-url的内容就行。

Linux发行源

Ubuntu 18.04

每次建一个ubuntu服务器,第一件事一定都是apt-get update。这个命令做的,并不会安装什么软件,而是拉取所有的package list,只有这样你通过apt-get install安装package的时候,他才会知道你要的包到底有没有,有的话又在哪里?

默认情况下使用的是国外的repositories,速度回很慢,这个时候就需要使用国内的源了。

配置文件为/etc/opt/sources.list

下面这个文件中阿里云云服务器ubuntu 18.04镜像,/etc/opt/sources.list原文内容。

## Note, this file is written by cloud-init on first boot of an instance	
## modifications made here will not survive a re-bundle.	
## if you wish to make changes you can:	
## a.) add 'apt_preserve_sources_list: true' to /etc/cloud/cloud.cfg	
##     or do the same in user-data	
## b.) add sources in /etc/apt/sources.list.d	
## c.) make changes to template file /etc/cloud/templates/sources.list.tmpl	
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to	
# newer versions of the distribution.	
deb http://mirrors.cloud.aliyuncs.com/ubuntu/ bionic main	
deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ bionic main	
## Major bug fix updates produced after the final release of the	
## distribution.	
deb http://mirrors.cloud.aliyuncs.com/ubuntu/ bionic-updates main	
deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ bionic-updates main	
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu	
## team. Also, please note that software in universe WILL NOT receive any	
## review or updates from the Ubuntu security team.	
deb http://mirrors.cloud.aliyuncs.com/ubuntu/ bionic universe	
deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ bionic universe	
deb http://mirrors.cloud.aliyuncs.com/ubuntu/ bionic-updates universe	
deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ bionic-updates universe	
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu	
## team, and may not be under a free licence. Please satisfy yourself as to	
## your rights to use the software. Also, please note that software in	
## multiverse WILL NOT receive any review or updates from the Ubuntu	
## security team.	
# deb http://mirrors.cloud.aliyuncs.com/ubuntu/ bionic multiverse	
# deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ bionic multiverse	
# deb http://mirrors.cloud.aliyuncs.com/ubuntu/ bionic-updates multiverse	
# deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ bionic-updates multiverse	
## Uncomment the following two lines to add software from the 'backports'	
## repository.	
## N.B. software from this repository may not have been tested as	
## extensively as that contained in the main release, although it includes	
## newer versions of some applications which may provide useful features.	
## Also, please note that software in backports WILL NOT receive any review	
## or updates from the Ubuntu security team.	
# deb http://mirrors.cloud.aliyuncs.com/ubuntu/ bionic-backports main restricted universe multiverse	
# deb-src http://mirrors.cloud.aliyuncs.com/ubuntu/ bionic-backports main restricted universe multiverse	
## Uncomment the following two lines to add software from Canonical's	
## 'partner' repository.	
## This software is not part of Ubuntu, but is offered by Canonical and the	
## respective vendors as a service to Ubuntu users.	
# deb http://archive.canonical.com/ubuntu bionic partner	
# deb-src http://archive.canonical.com/ubuntu bionic partner	
deb http://mirrors.cloud.aliyuncs.com/ubuntu bionic-security main	
deb-src http://mirrors.cloud.aliyuncs.com/ubuntu bionic-security main	
deb http://mirrors.cloud.aliyuncs.com/ubuntu bionic-security universe	
deb-src http://mirrors.cloud.aliyuncs.com/ubuntu bionic-security universe	
# deb http://mirrors.cloud.aliyuncs.com/ubuntu bionic-security multiverse	
# deb-src http://mirrors.cloud.aliyuncs.com/ubuntu bionic-security

保险起见可以先把原来的文件备份一下。

比如说你要做一个ubuntu docker镜像,就可以使用

COPY sources.list /etc/opt/sources.list

将docker镜像的源配置文件修改一下,这样安装速度会有显著提升。

centos

和ubuntu的方法大同小异,不同的是centos的源配置文件在/etc/yum.repos.d/CentOS-Base.repo。可以wget命令来获取远程的阿里云centos源配置文件:

# CentOS 5	
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo	
# CentOS 6	
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo	
# CentOS 7	
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

debian

debain的源配置文件也在 /etc/apt/sources.list,但是切记不要把Ubuntu的源配置文件添加到这里面去了。

deb http://mirrors.163.com/debian/ stretch main	
deb http://mirrors.163.com/debian/ stretch-updates main non-free contrib	
deb-src http://mirrors.163.com/debian/ stretch-updates main non-free contrib	
deb http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib	
deb http://httpredir.debian.org/debian stretch-backports main contrib non-free

docker源

mac的配置很简单,进入在docker 的daemon设置,在 Registry mirrors中加入一个新的列表项

https://registry.docker-cn.com

选择Apply & Restart Docker 重启后即可使用中国官方镜像源加速。

对于Linux,docker的源配置文件为/etc/docker/daemon.json,如果没有这个文件的话就创建一个,添加以下内容:

{	
  "registry-mirrors": ["https://registry.docker-cn.com"]	
}

github加速

这个的解决方案没有上面这些那么简单,需要安装ssr和proxychain4,这里涉及到了天朝的盲区,就不展开了,有兴趣的小伙伴可以去搜索下试试~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
MyBatis是一个支持多数据配置的Java持久层框架。在MyBatis的配置文件中,可以通过配置多个数据来实现多数据配置。 首先,在配置文件中定义多个数据。可以使用<dataSource>标签定义每个数据配置信息,包括数据库的驱动类名、连接地址、用户名、密码等信息。 然后,在配置文件中通过<environments>标签来配置多数据。可以使用<environment>标签定义每个环境,包括指定数据的ID和对应的事务管理器。 接着,在配置文件中使用<mapper>标签来指定每个数据对应的Mapper文件。可以在<mapper>标签的namespace属性中指定Mapper文件的命名空间。 最后,在代码中通过SqlSessionFactoryBuilder来创建SqlSessionFactory,并在创建SqlSession时指定要使用的数据的ID。可以使用SqlSessionFactory的openSession方法来创建SqlSession,并在参数中指定要使用的数据的ID。 总结起来,使用MyBatis实现多数据配置的步骤如下: 1. 在配置文件中定义多个数据配置信息。 2. 配置多数据环境。 3. 指定每个数据对应的Mapper文件。 4. 在代码中创建SqlSessionFactory,并指定要使用的数据的ID。 5. 使用SqlSessionFactory创建SqlSession,并在参数中指定要使用的数据的ID。 通过以上的配置,就可以实现在一个应用中使用多个数据。在实际应用中,可以根据需要配置多个数据,例如主从库读写分离、分库分表等场景。同时,可以根据需要在代码中动态切换数据,实现更灵活的数据访问控制。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值