ubuntu
Ubuntu镜像下载
1 2
| http://cdimage.ubuntu.com/releases/ #ubuntu server(服务器版) http://releases.ubuntu.com/ #ubuntu desktop(桌⾯版)
|
Ubuntu Server系统基础配置
更改主机名:
1 2
| ubuntu-node.example.com
|
更改网卡名称为eth0
如果没有在安装系统之前传递内核参数将⽹卡名称更改为eth*,则可以在 安装系统之后使⽤以下⽅式修改
1 2 3 4 5 6
| GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"
update-grub reboot
|
配置root远程登录
默认情况下,ubuntu不允许root⽤⼾远程ssh,如果有实际场景需要允许 root⽤⼾远程ssh,则需要设置root密码,并且编辑 /etc/ssh/sshd_config
⽂件修改如下 :
1 2 3 4 5 6 7 8 9 10
| vim /etc/ssh/sshd_config 32 33 PermitRootLogin yes 57 58 PasswordAuthentication yes
su - root passwd systemctl restart sshd
|
Ubuntu 18.04网络配置
单网卡静态IP地址
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| vim /etc/netplan/01-netcfg.yaml network: version: 2 renderer: networkd ethernets: eth0: dhcp4: no dhcp6: no addresses: [10.0.0.121/24] gateway4: 10.0.0.2 nameservers: search: [neteagles.cn, neteagles.com] addresses: [223.5.5.5, 223.6.6.6]
netplan apply
vim ~/.vimrc set paste
|
配置多网卡静态IP
ubuntu 18.04配置多⽹卡静态IP以及静态路由
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| vim /etc/netplan/01-netcfg.yaml network: version: 2 renderer: networkd ethernets: eth0: dhcp4: no dhcp6: no addresses: [10.0.0.121/24] gateway4: 10.0.0.2 nameservers: search: [neteagles.cn, neteagles.com] addresses: [223.5.5.5, 223.6.6.6] eth1: dhcp4: no dhcp6: no addresses: [192.168.10.100/24] routes: - to: 172.20.0.0/16 via: 192.168.10.2 - to: 10.20.0.0/16 via: 192.168.10.2 - to: 10.2.0.0/16 via: 192.168.10.2 - to: 10.8.0.0/16 via: 192.168.10.2
netplan apply
|
单网卡桥接
ubuntu 18.04的单⽹卡桥接配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| network: version: 2 renderer: networkd ethernets: eth0: dhcp4: no dhcp6: no bridges: br0: dhcp4: no dhcp6: no addresses: [172.18.3.18/16] gateway4: 172.18.0.1 nameservers: addresses: [223.6.6.6] interfaces: - eth0
|
多⽹卡桥接
ubuntu 18.04多⽹卡的桥接配置,将br0和br1分别桥接到eth0和eth1。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| network: version: 2 renderer: networkd ethernets: eth0: dhcp4: no dhcp6: no eth0: dhcp4: no dhcp6: no bridges: br0: dhcp4: no dhcp6: no addresses: [172.18.3.18/16] gateway4: 172.18.0.1 nameservers: addresses: [223.6.6.6] interfaces: - eth0 br1: dhcp4: no dhcp6: no addresses: [10.20.3.18/16] routes: - to: 172.20.0.0/16 via: 10.20.0.1 - to: 10.20.0.0/16 via: 10.20.0.1 - to: 10.2.0.0/16 via: 10.20.0.1 - to: 10.8.0.0/16 via: 10.20.0.1 interfaces: - eth1
|
双⽹卡绑定
七种bond模式说明
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| 特点:传输数据包顺序是依次传输(即:第1个包⾛eth0,下⼀个包就⾛eth1….⼀直循环下去,直到最后⼀个传输完毕),此模式提供负载平衡和容错能⼒。
特点:只有⼀个设备处于活动状态,当⼀个宕掉另⼀个⻢上由备份转换为主设备。mac地址是外部可⻅得,从外⾯看来,bond的MAC地址是唯⼀的,以避免switch(交换机)发⽣混乱。此模式只提供了容错能⼒;由此可⻅此算法的优点是可以提供⾼⽹络连接的可⽤性,但是它的资源利⽤率较低,只有⼀个接⼝处于⼯作状态,在有 N 个⽹络接⼝的情况下,资源利⽤率为1/N。
特点:基于指定的传输HASH策略传输数据包。缺省的策略是:(源MAC地址 XOR⽬标MAC地址) % slave数量。其他的传输策略可以通过xmit_hash_policy选项指定,此模式提供负载平衡和容错能⼒。
特点:在每个slave接⼝上传输每个数据包,此模式提供了容错能⼒。
特点:创建⼀个聚合组,它们共享同样的速率和双⼯设定。根据802.3ad规范将多个slave⼯作在同⼀个激活的聚合下。 必要条件: 条件1:ethtool⽀持获取每个slave的速率和双⼯设定。 条件2:switch(交换机)⽀持IEEE 802.3ad Dynamic link aggregation。 条件3:⼤多数switch(交换机)需要经过特定配置才能⽀持802.3ad模式。
特点:不需要任何特别的switch(交换机)⽀持的通道bonding。在每个slave上根据当前的负载(根据速度计算)分配外出流量。如果正在接受数据的slave出故障了,另⼀个slave接管失败的slave的MAC地址。该模式的必要条件:ethtool⽀持获取每个slave的速率
特点:该模式包含了balance-tlb模式,同时加上针对IPV4流量的接收负载均衡(receive load balance, rlb),⽽且不需要任何switch(交换机)的⽀持。
|
ubuntu 18.04的双⽹卡绑定配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| 需要提前安装好bridge命令
network: version: 2 renderer: networkd ethernets: eth0: dhcp4: no dhcp6: no eth1: dhcp4: no dhcp6: no bonds: bond0: interfaces: - eth0 - eth1 addresses: [172.18.3.18/16] gateway4: 172.18.0.1 nameservers: addresses: [223.6.6.6,223.5.5.5] parameters: mode: active-backup mii-monitor-interval: 100
|
双⽹卡绑定+桥接
⽹卡绑定⽤于提供⽹卡接⼝冗余以及⾼可⽤和端⼝聚合功能,桥接⽹卡再 给需要桥接设备的服务使⽤
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| network: version: 2 renderer: networkd ethernets: eth0: dhcp4: no dhcp6: no eth1: dhcp4: no dhcp6: no bonds: bond0: interfaces: - eth0 - eth1 parameters: mode: active-backup mii-monitor-interval: 100 bridges: br0: dhcp4: no dhcp6: no addresses: [172.18.3.18/16] gateway4: 172.18.0.1 nameservers: addresses: [223.6.6.6,223.5.5.5] interfaces: - bond0
|
内外多⽹卡绑定
多⽹络情况下实现⽹卡绑定
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| network: version: 2 renderer: networkd ethernets: eth0: dhcp4: no dhcp6: no eth1: dhcp4: no dhcp6: no eth2: dhcp4: no dhcp6: no eth3: dhcp4: no dhcp6: no bonds: bond0: interfaces: - eth0 - eth1 addresses: [172.18.3.18/16] gateway4: 172.18.0.1 nameservers: addresses: [223.6.6.6,223.5.5.5] parameters: mode: active-backup mii-monitor-interval: 100 bond1: interfaces: - eth2 - eth3 addresses: [10.20.3.18/16] parameters: mode: active-backup mii-monitor-interval: 100 routes: - to: 172.20.0.0/16 via: 10.20.0.1 - to: 10.20.0.0/16 via: 10.20.0.1 - to: 10.2.0.0/16 via: 10.20.0.1 - to: 10.8.0.0/16 via: 10.20.0.1
|
内⽹多⽹卡绑定+桥接
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| network: version: 2 renderer: networkd ethernets: eth0: dhcp4: no dhcp6: no eth1: dhcp4: no dhcp6: no eth2: dhcp4: no dhcp6: no eth3: dhcp4: no dhcp6: no bonds: bond0: interfaces: - eth0 - eth1 parameters: mode: active-backup mii-monitor-interval: 100 bond1: interfaces: - eth2 - eth3 parameters: mode: active-backup mii-monitor-interval: 100 bridges: br0: dhcp4: no dhcp6: no addresses: [172.18.3.18/16] gateway4: 172.18.0.1 nameservers: addresses: [223.6.6.6,223.5.5.5] interfaces: - bond0 br1: dhcp4: no dhcp6: no interfaces: - bond1 addresses: [10.20.3.18/16] routes: - to: 172.20.0.0/16 via: 10.20.0.1 - to: 10.20.0.0/16 via: 10.20.0.1 - to: 10.2.0.0/16 via: 10.20.0.1 - to: 10.8.0.0/16 via: 10.20.0.1
|
Ubuntu软件包管理
修改软件仓库
阿⾥云仓库地址:https://opsx.alibaba.com/mirror
中科⼤:http://mirrors.ustc.edu.cn/help/ubuntu.html
清华⼤学:https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/
华为:https://mirrors.huaweicloud.com/
设置为清华源:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| 18.04LTS: Ubuntu 的软件源配置文件是 /etc/apt/sources.list。将系统自带的该文件做个备份,将该文件替换为下面内容:
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
20.04LTS:
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
apt update
|
apt/apt-get
1 2 3 4 5 6 7 8 9 10 11 12 13
| apt list apt search NAME apt show apache2 apt install apache2 apt remove apache2 apt autoremove apache2 apt update apt purge apache2 apt upgrade apt full-upgrade apt edit-sources apt-cache madison nginx apt install nginx=1.14.0-0ubuntu1.6
|
dpkg安装包管理
1 2 3 4 5 6 7
| dpkg -i gitlab-ce_11.9.8-ce.0_amd64.deb dpkg -r gitlab-ce dpkg -r -P gitlab-ce dpkg -I gitlab-ce_11.9.8-ce.0_amd64.deb dpkg -c gitlab-ce_11.9.8-ce.0_amd64.deb dpkg -l dpkg -L tree
|
设置oracle JDK环境
1 2 3 4 5 6 7 8 9 10 11 12
| cd /usr/local/src tar xf jdk-8u212-linux-x64.tar.gz ln -sv /usr/local/src/jdk1.8.0_212 /usr/local/jdk
vim /etc/profile export JAVA_HOME=/usr/local/jdk export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH export CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar
source /etc/profile java -version
|
安装OpenJDK:
1
| apt install openjdk-8-jdk
|
安装常用系统命令:
1 2 3 4 5 6
| apt install purge ufw lxd lxd-client lxcfs lxc-common apt install iproute2 ntpdate tcpdump telnet traceroute nfs-kernel-server nfs-common lrzsz tree openssl libssl-dev libpcre3 libpcre3-dev zlib1g-dev ntpdate tcpdump telnet traceroute gcc openssh-server lrzsz tree openssl libssl-dev libpcre3 libpcre3-dev zlib1g-dev ntpdate tcpdump telnet traceroute iotop unzip zip libevent-dev
apt install procps (top 命令) apt install iputils-ping (ping 命令) apt install net-tools (网络工具)
|
系统资源限制优化
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| vim /etc/security/limits.conf
root soft core unlimited root hard core unlimited root soft nproc 1000000 root hard nproc 1000000 root soft nofile 1000000 root hard nofile 1000000 root soft memlock 32000 root hard memlock 32000 root soft msgqueue 8192000 root hard msgqueue 8192000
* soft core unlimited * hard core unlimited * soft nproc 1000000 * hard nproc 1000000 * soft nofile 1000000 * hard nofile 1000000 * soft memlock 32000 * hard memlock 32000 * soft msgqueue 8192000 * hard msgqueue 8192000
|
内核参数优化
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| vim /etc/sysctl.conf net.ipv4.conf.default.rp_filter = 1 net.ipv4.ip_nonlocal_bind = 1 net.ipv4.ip_forward = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1 net.bridge.bridge-nf-call-arptables = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
net.ipv4.tcp_mem = 786432 1048576 1572864 net.ipv4.tcp_rmem = 4096 87380 4194304 net.ipv4.tcp_wmem = 4096 16384 4194304 net.ipv4.tcp_window_scaling = 1 net.ipv4.tcp_sack = 1
net.core.wmem_default = 8388608 net.core.rmem_default = 8388608 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 net.core.netdev_max_backlog = 262144 net.core.somaxconn = 20480 net.core.optmem_max = 81920
net.ipv4.tcp_max_syn_backlog = 262144 net.ipv4.tcp_syn_retries = 3 net.ipv4.tcp_retries1 = 3 net.ipv4.tcp_retries2 = 15
net.ipv4.tcp_timestamps = 0 net.ipv4.tcp_tw_reuse = 0 net.ipv4.tcp_tw_recycle = 0 net.ipv4.tcp_fin_timeout = 1 net.ipv4.tcp_max_tw_buckets = 20000 net.ipv4.tcp_max_orphans = 3276800 net.ipv4.tcp_synack_retries = 1 net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_keepalive_time = 300 net.ipv4.tcp_keepalive_intvl = 30 net.ipv4.tcp_keepalive_probes = 3 net.ipv4.ip_local_port_range = 10001 65000
vm.overcommit_memory = 0 vm.swappiness = 10
|
Ubuntu Desktop版本使用
环境配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| 1、设置软件源及安装常⽤命令: https://opsx.alibaba.com/mirror
sudo apt install build-essential cmake pkg-config qt4-qmake libqt4-dev desktop-file-utils \ libavformat-dev libavcodec-dev libavutil-dev libswscale-dev libasound2-dev libpulse-dev libjack-jackd2-dev \ libgl1-mesa-dev libglu1-mesa-dev libx11-dev libxfixes-dev libxext-dev libxi-dev libxinerama-dev
2、系统更新及配置中⽂语⾔环境:
3、安装搜狗拼⾳输⼊法 https://pinyin.sogou.com/linux/?r=pinyin
4、安装转码器ffmpeg: 多媒体视频处理⼯具FFmpeg有⾮常强⼤的功能包括视频采集功能、视频格式转 换、视频抓图、给视频加⽔印等。 sudo apt-get install ffmpeg
5、安装视频播放器: smplayer https://www.jianshu.com/p/f24252c632d0 sudo apt-get install smplayer
6、办公软件WPS: https://www.wps.cn/product/wpslinux
7、单机VNC⼯具: x11vnc server
8、RealVNC v6.6: ⽀持多个⽤⼾同时连接 https://www.realvnc.com/en/connect/download/vnc/linux/
9、⽂本编辑器: visual studio code
10、markdown⼯具: https://www.typora.io/ sudo apt-get install typora=0.9.60-1
11、Ubuntu 桌⾯3D特效: sudo apt-get install compiz-plugins compizconfig-settings-manager
12、左侧菜单在底栏显⽰: ~$ gsettings set com.canonical.Unity.Launcher launcher-position Bottom
13、VMware workstion桥接⽹卡设置 https://kb.vmware.com/s/article/287?lang=zh_CN chmod a+rw /dev/vmnet0
14、远程⼯具: SecureCRT
15、python开发: pycharm
16、java开发: Eclipse Intellij IDEA
|