先停止keepalived
systemctl stop keepalived
更改root密码
登录到root用户下sudo passwd root(用户名)
#passwd
更改vnc密码
#vncpasswd
修改服务器名称
hostnamectl set-hostname server881052
vi /etc/hosts
keepalived都绑定ip:将网卡设为混杂模式
ip a ///查看网卡名
ifconfig eno16777984 promisc // eno16777984 根据网卡名修改
systemctl restart network
出现错误处理方式:
systemctl stop NetworkManager
systemctl disable NetworkManager
重启服务器
systemctl start NetworkManager
开组播:firewall-cmd --direct --permanent --add-rule ipv4 filter INPUT 0 --in-interface eno16777984 --destination 224.0.0.18 --protocol vrrp -j ACCEPT
firewall-cmd --reload
关闭selinux
vi /etc/selinux/config
修改selinux=disabled
重启
修改keepalived日志
vim /etc/rsyslog.conf
添加 local0.* /home/log/keepalived/keepalived.log
其他电脑部署
scp -r /etc/keepalived/* root@172.69.1.203:/etc/keepalived/
keepalive scripts中的sh文件要chmod 777 *.*<<chmod 777 /etc/keepalived/scripts>>
备机修改/etc/keepalived/keepalived.conf priority 90 virtual_router_id 244 #虚拟IP(0-255)
正式机虚拟 virtual_router_id从50开始
修改redis密码 /usr/local/redis/redis.conf requirepass=redis244 masterauth=redis244
备机要修改slaveof为主机ip,主机注释掉这一项
备机修改/etc/keepalived/scripts redis_master.sh和redis_backup.sh slaveof 均为主机ip 主机改为备机ip
修改service_check.sh中redis密码
修改 vim /usr/lib/systemd/system/redis.service 中的redis停止密码 ,参数-a
修改atlas配置/usr/local/mysql-proxy/conf/my.cnf
正式机必须改
#管理接口密码
admin-password = Admin8810203
#数据库连接密码
pwds = root:la1Ux+Bu4zo=
proxy-address = 0.0.0.0:1234
admin-address = 0.0.0.0:2345
开1234端口
firewall-cmd --add-port=1234/tcp --permanent
firewall-cmd --reload
添加mkdir /home/log/atlas 文件夹
tomcat要开启apr模式,参见Tomcat目录下的开启apr模式文章
修改vi /usr/local/tomcat/conf/context.xml 中redis密码
修改vi /usr/local/tomcat/conf/server.xml
cas的nginx一定要用带sticky插件的,可复制172.69.1.202、203 /usr/local/nginx-1.12中的
修改/usr/local/nginx/conf.d/*.conf 文件 中 upstream 服务器ip server_name域名
如果用到websocket 在location中添加
# WebSocket support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
修改tomcat数据库及url连接
修改/usr/local/tomcat/conf/server.xml 更改默认文档
<Context path="/" docBase="/usr/local/tomcat/webapps/amo" reloadable="true" debug="0"></Context>
jdbc连接要用atlas连接端口如 ip:1234
cas 修改/usr/local/tomcat/webapps/ssocas/WEB-INF/classes/application.properties文件的数据库连接及redis服务器地址和密码
创建日志目录
mkdir /home/log/mysqllog
mkdir /home/log/mysqllog/mysql-bin
修改vi /etc/my.cnf
#设置服务器ID(1到232-1),不能重复,用ip最后一段,测试机从200开始,正式机从50,100开始
#重点注意,如果是新数据库需要复制其他数据库的数据,server-id不能再用原来的id
#参考http://www.cnblogs.com/gomysql/p/5852607.html
server-id = 209
#所有日志文件改到日志目录/home/log/mysqllog
修改tomcat日志文件夹权限
cd /home/log/mysqllog
chown -R mysql:mysql ./
vi /home/log/mysqllog/log.log
chown -R mysql:mysql /home/log/mysqllog/log.log
chmod 777 /home
chmod 777 /home/log
chmod 777 /home/log/mysqllog/log.log
chgrp -R mysql /home/log/mysqllog
删除/usr/local/mysql/data下的所有东西
创建mysql服务:/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
启动mysql服务:mysqld_safe --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data &
mysql -uroot -p
在日志中找到初始密码
SET PASSWORD FOR root@localhost= PASSWORD('admin');
**mysql8.0以前的版本可以使用grant在授权的时候隐式的创建用户,8.0以后已经不支持,所以必须先创建用户,然后再授权,命令如下:**
mysql> CREATE USER ‘root’@‘172.69.6.163’ IDENTIFIED BY ‘Admin20190702’;
Query OK, 0 rows affected (0.04 sec)
mysql> GRANT ALL PRIVILEGES ON . TO ‘root’@‘172.69.6.163’ WITH GRANT OPTION;
Query OK, 0 rows affected (0.03 sec)
mysql>flush privileges;
mysql8.0以前的版本命令:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
给指定ip连接数据库权限:GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.69.6.163'IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
收回权限:revoke ALL PRIVILEGES ON *.* from 'root'@'172.69.6.163';
flush privileges;
在主服务器上创建拥有复制权限的帐户:
mysql –uroot -p
mysql>GRANT replication slave,replication client ON *.* TO 'repuser'@'172.69.1.244' IDENTIFIED BY 'repadmin';
FLUSH PRIVILEGES;
SHOW MASTER STATUS; #记录下当前主服务器所使用的二进制文件及position
在从服务器上操作,从服务器连接主服务器、启动复制线程
mysql> change master to master_host='172.88.10.103',master_user='repuser',master_password='repadmin',master_log_file='mysql-bin.000001',master_log_pos=0; #这里的偏移量指定为“0”,零表示从开二进制日志的开头开始进行复制
mysql> SHOW SLAVE STATUS\G #查看slave的状态信息,IO thread和sql thread线程都还没有启动
mysql> START SLAVE; #启动复制线程
mysql> SHOW SLAVE STATUS\G #两个线程已启动
设置mysql备份
修改/home/data_backup/mysql_scripts/mysql_databak.sh
参看mysql备份并自动上传,在ftp服务器建目录,修改脚本中的ftp文件夹名称和备份的数据库名称
设置各项自动重启
参见系统自动启动文档
重启tomcat redis nginx keepalived
重启服务器
systemctl restart redis
systemctl restart nginx
systemctl restart rsyslog
systemctl restart keepalived
systemctl restart mysql
systemctl restart tomcat