实操笔记

操作系统:

  查看主机设置:hostnamectl status

  修改主机名称(不能带空白及特殊字符):hostnamectl --static set-hostname <host-name>

  查看操作系统版本:cat /etc/redhat-release

  修改主机ip:编辑/etc/sysconfig/network-scripts/ifcfg-eth0,ifcfg-eth0是ifconfig中看到的网卡名称

BOOTPROTO="static"
IPADDR=10.211.55.6
NETMASK=255.255.255.0
GATEWAY=10.211.55.1
NM_CONTROLLED=NO

  重启网络服务:systemctl restart network.service

  关闭ipv6:vi /etc/default/grub,在GRUB_CMDLINE_LINUX加上的后面句首加上ipv6.disable=1,如GRUB_CMDLINE_LINUX="ipv6.disable=1 rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet"运行grub2-mkconfig -o /boot/grub2/grub.cfg重新生成grub.cfg文件运行lsmod|grep ipv6检查效果。

  关闭防火墙:

systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)

   sshd版本过高,导致低版本无法登陆(高版本默认关闭一些加密算法)问题的解决:在/etc/ssh/sshd_config文件末尾加入:

KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1

  

 

ansible:

  host配置格式:

[db]
10.211.55.7 ansible_ssh_user=app ansible_ssh_pass=abc123 ansible_ssh_sudo_pass=abc123
10.211.55.8 ansible_ssh_user=app ansible_ssh_pass=abc123 ansible_ssh_sudo_pass=abc123
10.211.55.9 ansible_ssh_user=app ansible_ssh_pass=abc123 ansible_ssh_sudo_pass=abc123
10.211.55.10 ansible_ssh_user=app ansible_ssh_pass=abc123 ansible_ssh_sudo_pass=abc123

数据库:

  服务器本地登陆数据库:mysql -u root -p -S /tmp/mysql_1234.sock

  mysql赋权:

  GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'lxh' WITH GRANT OPTION; # 所有的地址都可以使用root用户,密码为lxh远程访问所有的数据库
  flush privileges;
 
原文地址:https://www.cnblogs.com/badwood316/p/8447930.html