目录
1- Alpine Linux源管理
1.1- 国内源
- 清华大学:https://mirror.tuna.tsinghua.edu.cn/alpine/
- 阿里云:https://mirrors.aliyun.com/alpine/3.
- 中科大:http://mirrors.ustc.edu.cn/alpine/
1.2- 配置
_ _ _ 将 /etc/apk/repositories 文件中 Alpine 默认的源地址 http://dl-cdn.alpinelinux.org/ 替换为 http://mirrors.ustc.edu.cn/ 即可。
sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
直接编辑 /etc/apk/repositories 文件:
https://mirrors.ustc.edu.cn/alpine/v3.5/main
https://mirrors.ustc.edu.cn/alpine/v3.5/community
使用 latest-stable 指向最新的稳定版本:
https://mirrors.ustc.edu.cn/alpine/latest-stable/main
https://mirrors.ustc.edu.cn/alpine/latest-stable/community
最后:
apk update
1.3- 执行命令
echo http://mirrors.ustc.edu.cn/alpine/v3.7/main >/etc/apk/repositories
echo http://mirrors.ustc.edu.cn/alpine/v3.7/community >>/etc/apk/repositories
echo http://mirrors.ustc.edu.cn/alpine/edge/main >>/etc/apk/repositories
echo http://mirrors.ustc.edu.cn/alpine/edge/community >>/etc/apk/repositories
echo http://mirrors.ustc.edu.cn/alpine/edge/testing >>/etc/apk/repositories
或者:
echo 'http://mirrors.ustc.edu.cn/alpine/v3.7/main
http://mirrors.ustc.edu.cn/alpine/v3.7/community
http://mirrors.ustc.edu.cn/alpine/edge/main
http://mirrors.ustc.edu.cn/alpine/edge/community
http://mirrors.ustc.edu.cn/alpine/edge/testing' >/etc/apk/repositories
2- Alpine包管理
_ _ _ Alpine使用apk进行包管理
2.1- apk命令
2.1.1- apk update
apk update #更新最新镜像源列表
2.1.2- apk search
apk search #查找所以可用软件包
apk search -v #查找所以可用软件包及其描述内容
apk search -v 'acf*' #通过软件包名称查找软件包
apk search -v -d 'docker' #通过描述文件查找特定的软件包
2.1.3- apk add
apk add openssh #安装一个软件
apk add openssh openntp vim #安装多个软件
apk add --no-cache mysql-client #不使用本地镜像源缓存,相当于先执行update,再执行add
apk add -u #升级指定软件包
2.1.4- apk info
apk info #列出所有已安装的软件包
apk info -a zlib #显示完整的软件包信息
apk info -r zlib #列出所有包的依赖
apk info -s zlib #显示软件包大小
apk info -d zlib #显示软件包的描述
apk info --who-owns /sbin/lbu #显示指定文件属于的包
apk info -L zlib #列出软件包的内容
apk info -e zlib #检测软件包的安装
apk info -R zlib #列出指定包的依赖
2.1.5- apk upgrade
apk upgrade #升级所有软件
apk upgrade openssh #升级指定软件
apk upgrade openssh openntp vim #升级多个软件
apk add --upgrade busybox #指定升级部分软件包
2.1.6- apk del
apk del openssh #删除一个软件
3- Alpine服务管理
_ _ _ 使用的是RC系列命令进行服务管理.
3.1- rc-update
用于不同运行级增加或者删除服务:
rc-update --help
Usage: rc-update [options] add <service> [<runlevel>...]
or: rc-update [options] del <service> [<runlevel>...]
or: rc-update [options] [show [<runlevel>...]]
Options: [ asuChqVv ]
-a, --all Process all runlevels
-s, --stack Stack a runlevel instead of a service
-u, --update Force an update of the dependency tree
-h, --help Display this help output
-C, --nocolor Disable color output
-V, --version Display software version
-v, --verbose Run verbosely
-q, --quiet Run quietly (repeat to suppress errors)
3.2- rc-status
用于运行级的状态管理。
rc-status --help
Usage: rc-status [options] <runlevel>...
or: rc-status [options] [-a | -c | -l | -m | -r | -s | -u]
Options: [ aclmrsuChqVv ]
-a, --all Show services from all run levels
-c, --crashed Show crashed services
-l, --list Show list of run levels
-m, --manual Show manually started services
-r, --runlevel Show the name of the current runlevel
-s, --servicelist Show service list
-u, --unused Show services not assigned to any runlevel
-h, --help Display this help output
-C, --nocolor Disable color output
-V, --version Display software version
-v, --verbose Run verbosely
-q, --quiet Run quietly (repeat to suppress errors)
3.3- rc-service
用于管理服务的状态
rc-service --help
Usage: rc-service [options] [-i] <service> <cmd>...
or: rc-service [options] -e <service>
or: rc-service [options] -l
or: rc-service [options] -r <service>
Options: [ ce:ilr:INChqVv ]
-e, --exists <arg> tests if the service exists or not
-c, --ifcrashed if the service is crashed then run the command
- -i, --ifexists if the service exists then run the command
-I, --ifinactive if the service is inactive then run the command
-N, --ifnotstarted if the service is not started then run the command
-l, --list list all available services
-r, --resolve <arg> resolve the service name to an init script
-h, --help Display this help output
-C, --nocolor Disable color output
-V, --version Display software version
-v, --verbose Run verbosely
-q, --quiet Run quietly (repeat to suppress errors)
3.4- openrc
管理不同的运行级。
openrc --help
Usage: openrc [options] [<runlevel>]
Options: [ a:no:s:SChqVv ]
-n, --no-stop do not stop any services
-o, --override <arg> override the next runlevel to change into
when leaving single user or boot runlevels
-s, --service <arg> runs the service specified with the rest
of the arguments
-S, --sys output the RC system type, if any
-h, --help Display this help output
-C, --nocolor Disable color output
-V, --version Display software version
-v, --verbose Run verbosely
-q, --quiet Run quietly (repeat to suppress errors)
3.5- 案例
rc-update add docker boot #增加docker服务到系统启动时运行
rc-service networking restart #重启网络服务
rc-status -a #列出所有服务