配置用户、ssh、samba、vim、防火墙、mysql

1、开启root账户

刚进入系统root的密码要自己设置:sudo passwd root(参考:https://www.cnblogs.com/Malphite/p/7421791.html

2、配置ssh

配置文件所在位置:/etc/ssh/sshd_config

1、指定端口

默认端口22,可以在配置文件中更改使用端口

2、指定访问用户

默认下,ssh可能不允许自行添加的用户,通过ssh远程访问服务器,可以在配置文件中添加:

AllowUsers:username1 username2     添加多个用户

DenyUsers:username     拒绝访问

AllowGroups:group1 group2        添加整个用户组

DenyGroups:group1    拒绝访问

PermitRootLogin no  #禁止用root账号登录

PermitEmptyPasswords no #禁止用空密码登录

参考:https://www.cnblogs.com/caolicangzhu/p/6766970.html

参考:https://baijiahao.baidu.com/s?id=1596606784211626459&wfr=spider&for=pc

3、指定访问IP

https://www.cnblogs.com/EasonJim/p/8334122.html

3、配置samba

1、创建共享目录

mkdir /home/samba-share

2、更改权限

chmod 777 /home/samba-share

3、修改配置文件

文件位置:/etc/samba/smb.conf

建议先保存当前配置文件:cp -a /etc/samba/smb.conf /etc/samba/smb.conf.back

编辑:vim /etc/samba/smb.conf

简单快速实现文件共享:(参考:https://www.cnblogs.com/adong7639/p/7832046.html,这篇文章在global中设置security = share有问题,因为现在已经不支持了)

[share]

path =  /etc/samba/smb.conf

available = yes

browseable = yes

public = yes

writable = yes

整体流程可看:https://www.linuxidc.com/Linux/2018-11/155466.htm,但是其对文件的设置太过冗余

4、为samba添加、删除、管理用户

smbpasswd -a ubuntu

重启samba:/etc/init.d/samba restart,或service smbd restart

查看当前samba用户:pdbedit -L

删除samba用户:smbpasswd -x ubuntu

参考:https://jingyan.baidu.com/article/3a2f7c2ed314ef26afd611a1.htmlhttps://blog.csdn.net/weixin_40117614/article/details/83621844

4、vim配置

1、文件位置

系统配置文件:/etc/vim/vimrc   影响所有的用户

用户配置文件:~/.vimrc   只会对当前用户的vim有影响  (https://www.cnblogs.com/hawkboy/articles/2991371.html

以下为自己的vimrc文件

set hlsearch
set ignorecase

set ts=4

"set background=dark
set number
set showmatch
set smartindent

"color
hi Comment ctermfg=6
hi String ctermfg=3
hi Type ctermfg=yellow
hi Number ctermfg=darkblue
hi Constant ctermfg=5
hi Statement ctermfg=darkyellow

结合了:https://www.cnblogs.com/benjamin77/p/8427301.htmlhttps://www.cnblogs.com/the-tops/p/5845481.htmlhttps://www.cnblogs.com/zzqcn/p/4537801.html

5、防火墙配置

开启:ufw enable

关闭:ufw disable

状态查询,当开启时可以查看当前有哪些端口开放:ufw status

开放端口:ufw allow 22

开放IP:ufw allow from 192.168.x.x

更多:https://www.linuxidc.com/Linux/2016-12/138259.htmhttps://blog.csdn.net/px96004/article/details/17529881

开启防火墙后要注意将ssh、samba等服务的端口开放,否则这些服务将不能使用

6、mysql数据存储路径设置问题

1、mysql使用端口:3306

2、注意mysql配置文件所在位置为:/etc/mysql/mysql.conf.d/mysqld.cnf,不是/etc/mysql/my.cnf

https://www.cnblogs.com/2016024291-/p/9045548.html

3、打开/etc/mysql/mysql.conf.d/mysqld.cnf,找到:

其中datadir为数据存放路径,将其改为要设置的路径,之后将mysql原路径下的数据全拷贝到新目录下

4、可能出现的问题

1)

再将上述完成后,重新启动mysql服务可能会失败,是因为与AppArmor有关,这个的配置文件里规定了mysql的存储路径,在重启服务时AppArmor服务规定mysql的路径与mysql自己配置文件中的路径冲突,所以会造成mysql服务重启失败

AppArmor中规定mysql存储的文件:/etc/apparmor.d/usr.sbin.mysqld

具体方法直接看:https://www.cnblogs.com/kerrycode/p/9795474.html

2)调用service mysql start一直无法成功

service mysql start、service mysql restart、service mysql stop,命令都是一直等待,没有出现错误,也不会成功,查看错误日志可以发现:InnoDB: Waiting for page_cleaner to finish flushing of buffer pool错误

原因:因为系统的时间设置错误,导致与MySQL数据库的时间不一致造成的MySQL服务死锁

解决方法:将系统设置为正确的时间

系统时区:dpkg-reconfigure tzdata

CST时间:timedatectl set-local-rtc 0

mysql时间:https://blog.csdn.net/weixin_34072458/article/details/92306374

参考:https://www.1cswd.com/connot-stop-mysql/https://superuser.com/questions/1420699/how-to-fix-mariadb-when-it-gets-stuck-during-shutdown-waiting-for-page-cleaner

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值