You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2.9 KiB
2.9 KiB
| title | date | draft | toc | images | tags | categories |
|---|---|---|---|---|---|---|
| Centos部署笔记 | 2019-09-12T20:50:05+08:00 | false | true | <nil> | [centos] | server |
本文记录笔记全部基于CentOS7版本。
系统安装
权限控制和分区
- 登录报错
-- lniwn: /home/lniwn: change directory failed: Permission denied Logging in with /home="/".
首先确认权限:
chown -R lniwn:lniwn /home/lniwn
chmod -R 700 /home/lniwn
然后确认SELinux配置,恢复文件上下文:
restorecon -R /home
- 挂载/home分区到指定的磁盘
# 分区
parted
select /dev/sdb1 # 切换磁盘
mklabel gpt # 创建分区表
mkpart extended 1 100% # 分区
mkfs.ext4 /dev/sdb1 # 格式化磁盘
print # 打印当前分区概况
exit
# /home转移
mkdir -p /srv/home
mount /dev/sdb1 /srv/home
cp -aR /home/* /srv/home/
diff -r /home /srv/home
rm -rf /home/*
umount /srv/home
mount /dev/sdb1 /home
# 开机自动挂载
blkid /dev/sdb1
# 编辑/etc/fstab文件,添加如下行
UUID=e087e709-20f9-42a4-a4dc-d74544c490a6 /home ext4 defaults 0 2
- UUID – specifies the block device, you can alternatively use the device file /dev/sdb1.
- /home – this is the mount point.
- etx4 – describes the filesystem type on the device/partition.
- defaults – mount options, (here this value means rw, suid, dev, exec, auto, nouser, and async).
- 0 – used by dump tool, 0 meaning don’t dump if filesystem is not present.
- 2 – used by fsck tool for discovering filesystem check order, this value means check this device after root filesystem.
-
关闭SELinux
检查状态
sestatus禁用
setenforce 0编辑文件
/etc/selinux/config,将SELINUX值修改为disabled。重启系统生效。
SSH默认端口修改
-
修改sshd默认端口
打开配置文件
vim /etc/ssh/sshd_config修改端口号
Port 12456防火墙增加端口白名单
firewall-cmd --zone=public --add-port 123456/tcp --permanent刷新防火墙配置
firewall-cmd --reload重启sshd服务
systemctl restart sshd切记:使用新端口正常连接后,再断开原有的连接,否则可能会永远连不上ssh了
启动模式修改
-
切换GUI和CLI启动模式
systemctl set-default multi-user.targetsystemctl set-default graphical.target获取当前启动模式
systemctl get-default从CLI启动图形界面
startx -
配置启动时自动连接网络
cd /etc/sysconfig/network-scripts/ sed -i -e 's@^ONBOOT="no@ONBOOT="yes@' ifcfg-eth0
应用安装
mongodb安装
官方安装文档https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/