admin 管理员组

文章数量: 887021


2023年12月19日发(作者:08cms房产门户源码)

('none')ne('show master status;')ct()()def main():repo()mariadb()db1()if __name__ == '__main__':main()

从服务器

从服务器import pexpectimport osimport configparser# HOSTNAME_DB1='db1'# HOSTNAME_DB2='db2'DB1 = '192.168.102.143'# DB2 = '192.168.254.27'DBPASSWORD = '1'def repo():('touch /etc/.d/')with open('/etc/.d/','w',encoding='utf8') as f:('[mariadb]')config = Parser()("/etc/.d/", encoding="utf-8")('mariadb', 'name', 'MariaDB')('mariadb', 'baseurl', '/mariadb/yum/10.3/centos7-amd64/')('mariadb', 'gpgkey', '/mariadb/yum/RPM-GPG-KEY-MariaDB')('mariadb', 'gpgcheck', '1')(open('/etc/.d/','w'))def mariadb():a = ('yum install MariaDB -y')if a == 0:b = ('systemctl start mariadb &> /dev/null')if b == 0:print('mariadb启动成功')child = ('mysql_secure_installation')('enter for none')ne('')('Y/n')ne('y')('New')ne(DBPASSWORD)('Re-enter')ne(DBPASSWORD)('successfully')ne('')ne('')ne('')ne('')def db2():config = Parser()("/etc/.d/", encoding="utf-8")('mysqld', 'server-id', '2')(open('/etc/.d/','w'))b = ('systemctl restart mariadb')if b == 0:

bin = 'mysql-bin.000001'pos = 765# ('mysql -uroot -p%s' % DBPASSWORD)# ('''mysql -uroot -p%s -e "CHANGE MASTER TO MASTER_HOST='%s', MASTER_USER='slave',MASTER_PASSWORD='slave', MASTER_LOG_FILE='%s', MASTER_LOG_POS=%s;"''' % (DBPASSWORD,DB1,bin,pos))# ("mysql -uroot -p%s -e 'start slave;'" % DBPASSWORD)child = ('mysql -uroot -p%s' % DBPASSWORD)('none')ne("CHANGE MASTER TO MASTER_HOST='%s', MASTER_USER='slave', MASTER_PASSWORD='slave',MASTER_LOG_FILE='%s', MASTER_LOG_POS=%s;" % (DB1,bin,pos))('none')ne( 'start slave;' )ct()()def main():repo()mariadb()db2()if __name__ == '__main__':main()


本文标签: 门户 源码