Ubuntu系统搭建及环境部署

Ubuntu系统搭建及环境部署

    • 1 制作系统(系统盘安装)
      • 1.1 选择版本,并下载
      • 1.2 刻录系统盘
      • 1.3 制作系统
    • 2 配置
      • 2.1 root登陆
      • 2.2 更新国内源

1 制作系统(系统盘安装)

ubuntu中文官网

1.1 选择版本,并下载

在官网选择合适的系统版本,下载到本地

例如,ubuntu-22.04.2-live-server-amd64.iso

1.2 刻录系统盘

笔者使用UltraISO软件进行刻录
① 打开系统文件
Ubuntu系统搭建及环境部署_第1张图片
② 写入系统盘(U盘)
Ubuntu系统搭建及环境部署_第2张图片
③ 选择写入方式
Ubuntu系统搭建及环境部署_第3张图片
④ 写入

1.3 制作系统

插入优盘后,选择优盘启动
DOS界面选择Ubuntu

Install Ubuntu

选择安装磁盘,及安装内容,建议把第三方软件等等自带包一并安装

新建用户

设置时区等

2 配置

2.1 root登陆

由于ubuntu默认root无法直接登录系统,但是由于新制作的系统有很多配置需要root更改,而每次通过sudo修改都很麻烦,所以这里修改配置使root可以登录

ubuntu server

sudo su
vim /etc/ssh/sshd_config
 
# 在 sshd_config 文件里的 “Authentication” 部分加上以下内容
PermitRootLogin yes
# 完成以后退出 vim 并保存
 
service sshd restart # 重启 ssh 服务以应用更改
passwd root # 直接修改 Root 用户的密码

这样重新登陆 ssh 就可以用 Root 登陆了。

ubuntu 桌面版

① 修改文件/usr/share/lightdm/lightdm.conf.d/50-unity-greeter.conf文件,增加两行:

sudo vi /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf 

greeter-show-manual-login=true 
all-guest=false 

② 进入/etc/pam.d目录,修改gdm-autologin和gdm-password文件

vi gdm-autologin 
#注释掉auth required pam_succeed_if.so user != root quiet_success这一行,保存 
vi gdm-password 
#注释掉 auth required pam_succeed_if.so user != root quiet_success这一行,保存

③ 修改/root/.profile文件

sudo vi /root/.profile 
#将文件末尾的mesg n || true这一行修改成tty -s&&mesg n || true, 保存

④ 重启系统,输入root用户名和密码,登录系统。
⑤ root自动登录

vim /etc/gdm3/custom.conf
#将[daemon]
AutomaticLoginEnable=True
AutomaticLogin=root
#设置为root用户自动登录

2.2 更新国内源

① 备份源文件

cp   /etc/apt/sources.list   /etc/apt/sources.list.bak

② 修改源文件sources.list

  • 终端执行命令:
    sudo  chmod  777  /etc/apt/sources.list
    
    更改文件权限使其可编辑;
    
  • 执行命令:
    sudo  gedit   /etc/apt/sources.list  
    
    打开文件进行编辑;
    
  • 删除原来的文件内容,根据系统版本复制下面的任意一个到其中并保存;

阿里源

ubuntu 18.XX

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
 
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
 
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
 
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
 
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

ubuntu 20.XX

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
 
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
 
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
 
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
 
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

在终端执行

apt-get update				#更新软件列表,换源完成
apt-get upgrade				#upgrade 是升级已安装的所有软件包,升级之后的版本就是本地索引里的,
							#因此,在执行 upgrade 之前一定要执行 update, 这样才能是最新的。

安装软件,包括:
mysql
https://blog.csdn.net/hwx865/article/details/90287715
zabbix/password

zabbix+grafana
https://www.zabbix.com/download?zabbix=6.0&os_distribution=ubuntu&os_version=20.04&components=agent&db=&ws=
Admin/zabbix
https://grafana.com/grafana/download?pg=get&plcmt=selfmanaged-box1-cta1
admin/admin

samba
https://blog.csdn.net/qq_41004932/article/details/117486105

rsync

jenkins
https://editor.csdn.net/md/?articleId=128900050#113__111
admin/admin@123

python

ansible
apt install ansible

docker
https://blog.csdn.net/u012563853/article/details/125295985

nfs
https://blog.csdn.net/iriczhao/article/details/126149918

root@tencent-MS-7E06:~# fdisk /dev/nvme0n1

Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/nvme0n1: 3.65 TiB, 4000787030016 bytes, 7814037168 sectors
Disk model: KINGSTON SFYRD4000G                     
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 47CD55C7-5E46-4669-9B0C-41ED9D0146E0

Device             Start        End   Sectors   Size Type
/dev/nvme0n1p1      2048    1050623   1048576   512M EFI System
/dev/nvme0n1p2   1050624  501051391 500000768 238.4G Linux swap
/dev/nvme0n1p3 501051392  696363007 195311616  93.1G Linux filesystem
/dev/nvme0n1p4 696363008  891674623 195311616  93.1G Linux filesystem
/dev/nvme0n1p5 891674624  895580159   3905536   1.9G Linux filesystem
/dev/nvme0n1p6 895580160 1090891775 195311616  93.1G Linux filesystem

Command (m for help): n
Partition number (7-128, default 7): 
First sector (1090891776-7814037134, default 1090891776): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (1090891776-7814037134, default 7814037134): 

Created a new partition 7 of type 'Linux filesystem' and of size 3.1 TiB.

Command (m for help): w
The partition table has been altered.
Syncing disks.

root@tencent-MS-7E06:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev             32G     0   32G   0% /dev
tmpfs           6.3G  2.5M  6.3G   1% /run
/dev/nvme0n1p3   92G  1.7G   85G   2% /
/dev/nvme0n1p4   92G  5.9G   81G   7% /usr
tmpfs            32G   97M   32G   1% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs            32G     0   32G   0% /sys/fs/cgroup
/dev/nvme0n1p5  1.8G  152M  1.6G   9% /boot
/dev/nvme0n1p6   92G   73M   87G   1% /home
/dev/nvme0n1p1  511M  6.1M  505M   2% /boot/efi
tmpfs           6.3G   32K  6.3G   1% /run/user/125
/dev/loop0       30M   30M     0 100% /snap/snapd/8542
tmpfs           6.3G  108K  6.3G   1% /run/user/1000
/dev/loop1       55M   55M     0 100% /snap/core18/1880
/dev/loop2      256M  256M     0 100% /snap/gnome-3-34-1804/36
/dev/loop3       63M   63M     0 100% /snap/gtk-common-themes/1506
/dev/loop4       50M   50M     0 100% /snap/snap-store/467
root@tencent-MS-7E06:~# lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0         7:0    0  29.9M  1 loop /snap/snapd/8542
loop1         7:1    0    55M  1 loop /snap/core18/1880
loop2         7:2    0 255.6M  1 loop /snap/gnome-3-34-1804/36
loop3         7:3    0  62.1M  1 loop /snap/gtk-common-themes/1506
loop4         7:4    0  49.8M  1 loop /snap/snap-store/467
sda           8:0    0   5.5T  0 disk 
sdb           8:16   0   5.5T  0 disk 
nvme0n1     259:0    0   3.7T  0 disk 
├─nvme0n1p1 259:1    0   512M  0 part /boot/efi
├─nvme0n1p2 259:2    0 238.4G  0 part [SWAP]
├─nvme0n1p3 259:3    0  93.1G  0 part /
├─nvme0n1p4 259:4    0  93.1G  0 part /usr
├─nvme0n1p5 259:5    0   1.9G  0 part /boot
├─nvme0n1p6 259:6    0  93.1G  0 part /home
└─nvme0n1p7 259:8    0   3.1T  0 part 
nvme1n1     259:7    0   3.7T  0 disk 
root@tencent-MS-7E06:~# mkfs -t ext4 /dev/nvme0n1p7 
mke2fs 1.45.5 (07-Jan-2020)
Discarding device blocks: done                            
Creating filesystem with 840393169 4k blocks and 210100224 inodes
Filesystem UUID: 29a27fb2-a3c6-4647-81c8-f57649e35f95
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
	102400000, 214990848, 512000000, 550731776, 644972544

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done       

root@tencent-MS-7E06:~# mkfs -t ext4 /dev/sda
mke2fs 1.45.5 (07-Jan-2020)
/dev/sda contains a ext4 file system
	last mounted on Wed Mar 15 10:59:57 2023
Proceed anyway? (y,N) y
Creating filesystem with 1465130646 4k blocks and 183144448 inodes
Filesystem UUID: be7212bf-0593-4115-8896-7d09c9b288d6
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
	102400000, 214990848, 512000000, 550731776, 644972544

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done       

root@tencent-MS-7E06:~# mkfs -t ext4 /dev/sdb
mke2fs 1.45.5 (07-Jan-2020)
/dev/sdb contains a ext4 file system
	last mounted on Wed Mar 15 10:59:57 2023
Proceed anyway? (y,N) y
Creating filesystem with 1465130646 4k blocks and 183144448 inodes
Filesystem UUID: 531478cd-c96e-4b36-9d43-23b629781299
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
	102400000, 214990848, 512000000, 550731776, 644972544

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done       
root@tencent-MS-7E06:~# mkdir /mnt/{sda,sdb,nvme0,nvme1}
root@tencent-MS-7E06:~# mount /dev/sda /mnt/sda
root@tencent-MS-7E06:~# mount /dev/sdb /mnt/sdb
root@tencent-MS-7E06:~# mount /dev/nvme1n1 /mnt/nvme1
root@tencent-MS-7E06:~# mount /dev/nvme0n1p7 /mnt/nvme0
nvme0n1p7
root@tencent-MS-7E06:~# mount /dev/nvme0n1p7 /mnt/nvme0
root@tencent-MS-7E06:~# cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
#                
# / was on /dev/nvme0n1p3 during installation
UUID=137fa314-e16d-4ea1-bb86-1e8cd0440ea1 /               ext4    errors=remount-ro 0       1
# /boot was on /dev/nvme0n1p5 during installation
UUID=7b2080ac-7d92-40ad-b5f7-d822c93b7110 /boot           ext4    defaults        0       2
# /boot/efi was on /dev/nvme0n1p1 during installation
UUID=FD5E-0CBA  /boot/efi       vfat    umask=0077      0       1
# /home was on /dev/nvme0n1p6 during installation
UUID=688205e3-fa39-4cd7-9941-d702eb6ba0d4 /home           ext4    defaults        0       2
# /usr was on /dev/nvme0n1p4 during installation
UUID=a36bb7bc-fc3f-4545-8720-394e1d5ba16a /usr            ext4    defaults        0       2
# swap was on /dev/nvme0n1p2 during installation
UUID=75d2a9d9-faa4-4148-aef8-fe72034aa154 none            swap    sw              0       0
/dev/sda	/mnt/sda	ext4	defaults	0	0
/dev/sdb	/mnt/sdb	ext4	defaults	0	0
/dev/nvme0n1p7	/mnt/nvme0	ext4	defaults	0	0
/dev/nvme1n1	/mnt/nvme1	ext4	defaults	0	0

你可能感兴趣的:(#,Ubuntu,ubuntu,linux,运维)